Clang Project

clang_source_code/test/Driver/cl-outputs.c
1// Note: %s must be preceded by --, otherwise it may be interpreted as a
2// command-line option, e.g. on Mac where %s is commonly under /Users.
3
4// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
5// RUN: %clang_cl /c -flto -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
6// DEFAULT: "-o" "cl-outputs.obj"
7
8// RUN: %clang_cl /Fo -### -- %s 2>&1 | FileCheck -check-prefix=FoEMPTY %s
9// FoEMPTY:  "-o" "cl-outputs.obj"
10
11// RUN: %clang_cl /Foa -### -- %s 2>&1 | FileCheck -check-prefix=FoNAME %s
12// RUN: %clang_cl /Foa -flto -### -- %s 2>&1 | FileCheck -check-prefix=FoNAME %s
13// FoNAME:  "-o" "a.obj"
14
15// RUN: %clang_cl /Foa.ext /Fob.ext -### -- %s 2>&1 | FileCheck -check-prefix=FoNAMEEXT %s
16// FoNAMEEXT:  "-o" "b.ext"
17
18// RUN: %clang_cl /Fofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FoDIR %s
19// FoDIR:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
20
21// RUN: %clang_cl /Fofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FoDIRNAME %s
22// FoDIRNAME:  "-o" "foo.dir{{[/\\]+}}a.obj"
23
24// RUN: %clang_cl /Fofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FoDIRNAMEEXT %s
25// FoDIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
26
27// RUN: %clang_cl /Fo.. -### -- %s 2>&1 | FileCheck -check-prefix=FoCRAZY %s
28// FoCRAZY:  "-o" "..obj"
29
30// RUN: %clang_cl /Foa.obj -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEERROR %s
31// CHECK-MULTIPLESOURCEERROR: error: cannot specify '/Foa.obj' when compiling multiple source files
32
33// RUN: %clang_cl /Fomydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK %s
34// CHECK-MULTIPLESOURCEOK: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
35
36// RUN: %clang_cl /Fo -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK2 %s
37// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
38// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
39
40// RUN: %clang_cl /c /oa -### -- %s 2>&1 | FileCheck -check-prefix=oNAME1 %s
41// oNAME1:  "-o" "a.obj"
42
43// RUN: %clang_cl /c /o a -### -- %s 2>&1 | FileCheck -check-prefix=oNAME2 %s
44// oNAME2:  "-o" "a.obj"
45
46// RUN: %clang_cl /c /oa.ext /ob.ext -### -- %s 2>&1 | FileCheck -check-prefix=oNAMEEXT1 %s
47// oNAMEEXT1:  "-o" "b.ext"
48
49// RUN: %clang_cl /c /o a.ext /ob.ext -### -- %s 2>&1 | FileCheck -check-prefix=oNAMEEXT2 %s
50// oNAMEEXT2:  "-o" "b.ext"
51
52// RUN: %clang_cl /c /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=oDIR1 %s
53// oDIR1:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
54
55// RUN: %clang_cl /c /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=oDIR2 %s
56// oDIR2:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
57
58// RUN: %clang_cl /c /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAME1 %s
59// oDIRNAME1:  "-o" "foo.dir{{[/\\]+}}a.obj"
60
61// RUN: %clang_cl /c /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAME2 %s
62// oDIRNAME2:  "-o" "foo.dir{{[/\\]+}}a.obj"
63
64// RUN: %clang_cl /c /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAMEEXT1 %s
65// oDIRNAMEEXT1:  "-o" "foo.dir{{[/\\]+}}a.ext"
66
67// RUN: %clang_cl /c /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAMEEXT2 %s
68// oDIRNAMEEXT2:  "-o" "foo.dir{{[/\\]+}}a.ext"
69
70// RUN: %clang_cl /c /o.. -### -- %s 2>&1 | FileCheck -check-prefix=oCRAZY1 %s
71// oCRAZY1:  "-o" "..obj"
72
73// RUN: %clang_cl /c /o .. -### -- %s 2>&1 | FileCheck -check-prefix=oCRAZY2 %s
74// oCRAZY2:  "-o" "..obj"
75
76// RUN: not %clang_cl /c %s -### /o 2>&1 | FileCheck -check-prefix=oMISSINGARG %s
77// oMISSINGARG: error: argument to '/o' is missing (expected 1 value)
78
79// RUN: %clang_cl /c /omydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-oMULTIPLESOURCEOK1 %s
80// CHECK-oMULTIPLESOURCEOK1: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
81
82// RUN: %clang_cl /c /o mydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-oMULTIPLESOURCEOK2 %s
83// CHECK-oMULTIPLESOURCEOK2: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
84
85
86// RUN: %clang_cl /c /obar /Fofoo -### -- %s 2>&1 | FileCheck -check-prefix=FooRACE1 %s
87// FooRACE1: "-o" "foo.obj"
88
89// RUN: %clang_cl /c /Fofoo /obar -### -- %s 2>&1 | FileCheck -check-prefix=FooRACE2 %s
90// FooRACE2: "-o" "bar.obj"
91
92
93// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTEXE %s
94// DEFAULTEXE: cl-outputs.exe
95
96// RUN: %clang_cl /LD -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTDLL %s
97// RUN: %clang_cl /LDd -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTDLL %s
98// DEFAULTDLL: "-out:cl-outputs.dll"
99// DEFAULTDLL: "-implib:cl-outputs.lib"
100
101// RUN: %clang_cl /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
102// FeNOEXT: "-out:foo.exe"
103
104// RUN: %clang_cl /Fe -### -- %s 2>&1 | FileCheck -check-prefix=FeEMPTY %s
105// FeEMPTY-NOT: argument to '/Fe' is missing
106// FeEMPTY: "-out:cl-outputs.exe"
107
108// RUN: %clang_cl /Fefoo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
109// RUN: %clang_cl /Fefoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
110// FeNOEXTDLL: "-out:foo.dll"
111// FeNOEXTDLL: "-implib:foo.lib"
112
113// RUN: %clang_cl /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
114// FeEXT: "-out:foo.ext"
115
116// RUN: %clang_cl /LD /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXTDLL %s
117// RUN: %clang_cl /LDd /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXTDLL %s
118// FeEXTDLL: "-out:foo.ext"
119// FeEXTDLL: "-implib:foo.lib"
120
121// RUN: %clang_cl /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIR %s
122// FeDIR: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
123
124// RUN: %clang_cl /LD /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRDLL %s
125// RUN: %clang_cl /LDd /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRDLL %s
126// FeDIRDLL: "-out:foo.dir{{[/\\]+}}cl-outputs.dll"
127// FeDIRDLL: "-implib:foo.dir{{[/\\]+}}cl-outputs.lib"
128
129// RUN: %clang_cl /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAME %s
130// FeDIRNAME: "-out:foo.dir{{[/\\]+}}a.exe"
131
132// RUN: %clang_cl /LD /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEDLL %s
133// RUN: %clang_cl /LDd /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEDLL %s
134// FeDIRNAMEDLL: "-out:foo.dir{{[/\\]+}}a.dll"
135// FeDIRNAMEDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
136
137// RUN: %clang_cl /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXT %s
138// FeDIRNAMEEXT: "-out:foo.dir{{[/\\]+}}a.ext"
139
140// RUN: %clang_cl /LD /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXTDLL %s
141// RUN: %clang_cl /LDd /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXTDLL %s
142// FeDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
143// FeDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
144
145// RUN: %clang_cl /Fefoo /Febar -### -- %s 2>&1 | FileCheck -check-prefix=FeOVERRIDE %s
146// FeOVERRIDE: "-out:bar.exe"
147
148
149// RUN: %clang_cl /obar /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeoRACE1 %s
150// FeoRACE1: "-out:foo.exe"
151
152// RUN: %clang_cl /Fefoo /obar -### -- %s 2>&1 | FileCheck -check-prefix=FeoRACE2 %s
153// FeoRACE2: "-out:bar.exe"
154
155
156// RUN: %clang_cl /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXT1 %s
157// FeoNOEXT1: "-out:foo.exe"
158
159// RUN: %clang_cl /o foo -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXT2 %s
160// FeoNOEXT2: "-out:foo.exe"
161
162// RUN: %clang_cl /o foo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXTDLL %s
163// RUN: %clang_cl /ofoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXTDLL %s
164// FeoNOEXTDLL: "-out:foo.dll"
165// FeoNOEXTDLL: "-implib:foo.lib"
166
167// RUN: %clang_cl /ofoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXT1 %s
168// FeoEXT1: "-out:foo.ext"
169
170// RUN: %clang_cl /o foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXT2 %s
171// FeoEXT2: "-out:foo.ext"
172
173// RUN: %clang_cl /LD /o foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXTDLL %s
174// RUN: %clang_cl /LDd /ofoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXTDLL %s
175// FeoEXTDLL: "-out:foo.ext"
176// FeoEXTDLL: "-implib:foo.lib"
177
178// RUN: %clang_cl /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIR1 %s
179// FeoDIR1: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
180
181// RUN: %clang_cl /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIR2 %s
182// FeoDIR2: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
183
184// RUN: %clang_cl /LD /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRDLL %s
185// RUN: %clang_cl /LDd /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRDLL %s
186// FeoDIRDLL: "-out:foo.dir{{[/\\]+}}cl-outputs.dll"
187// FeoDIRDLL: "-implib:foo.dir{{[/\\]+}}cl-outputs.lib"
188
189// RUN: %clang_cl /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAME1 %s
190// FeoDIRNAME1: "-out:foo.dir{{[/\\]+}}a.exe"
191
192// RUN: %clang_cl /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAME2 %s
193// FeoDIRNAME2: "-out:foo.dir{{[/\\]+}}a.exe"
194
195// RUN: %clang_cl /LD /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEDLL %s
196// RUN: %clang_cl /LDd /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEDLL %s
197// FeoDIRNAMEDLL: "-out:foo.dir{{[/\\]+}}a.dll"
198// FeoDIRNAMEDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
199
200// RUN: %clang_cl /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXT1 %s
201// FeoDIRNAMEEXT1: "-out:foo.dir{{[/\\]+}}a.ext"
202
203// RUN: %clang_cl /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXT2 %s
204// FeoDIRNAMEEXT2: "-out:foo.dir{{[/\\]+}}a.ext"
205
206// RUN: %clang_cl /LD /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXTDLL %s
207// RUN: %clang_cl /LDd /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXTDLL %s
208// FeoDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
209// FeoDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
210
211// RUN: not %clang_cl -### /o 2>&1 | FileCheck -check-prefix=FeoMISSINGARG %s
212// FeoMISSINGARG: error: argument to '/o' is missing (expected 1 value)
213
214// RUN: %clang_cl /ofoo /o bar -### -- %s 2>&1 | FileCheck -check-prefix=FeoOVERRIDE %s
215// FeoOVERRIDE: "-out:bar.exe"
216
217
218// RUN: %clang_cl /FA -### -- %s 2>&1 | FileCheck -check-prefix=FA %s
219// FA: "-o" "cl-outputs.asm"
220// RUN: %clang_cl /FA /Fa -### -- %s 2>&1 | FileCheck -check-prefix=FaEMPTY %s
221// FaEMPTY: "-o" "cl-outputs.asm"
222// RUN: %clang_cl /FA /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
223// RUN: %clang_cl /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
224// FaNAME:  "-o" "foo.asm"
225// RUN: %clang_cl /FA /Faa.ext /Fab.ext -### -- %s 2>&1 | FileCheck -check-prefix=FaNAMEEXT %s
226// FaNAMEEXT:  "-o" "b.ext"
227// RUN: %clang_cl /FA /Fafoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FaDIR %s
228// FaDIR:  "-o" "foo.dir{{[/\\]+}}cl-outputs.asm"
229// RUN: %clang_cl /FA /Fafoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FaDIRNAME %s
230// FaDIRNAME:  "-o" "foo.dir{{[/\\]+}}a.asm"
231// RUN: %clang_cl /FA /Fafoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FaDIRNAMEEXT %s
232// FaDIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
233// RUN: %clang_cl /Faa.asm -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCE %s
234// FaMULTIPLESOURCE: error: cannot specify '/Faa.asm' when compiling multiple source files
235// RUN: %clang_cl /Fa -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCEOK %s
236// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
237// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
238
239// RUN: %clang_cl /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
240// P: "-E"
241// P: "-o" "cl-outputs.i"
242
243// RUN: %clang_cl /P /Fifoo -### -- %s 2>&1 | FileCheck -check-prefix=Fi1 %s
244// Fi1: "-E"
245// Fi1: "-o" "foo.i"
246
247// RUN: %clang_cl /P /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fi2 %s
248// Fi2: "-E"
249// Fi2: "-o" "foo.x"
250
251// To match MSVC behavior /o should be ignored for /P output.
252
253// RUN: %clang_cl /P /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=Fio1 %s
254// Fio1: "-E"
255// Fio1: "-o" "cl-outputs.i"
256
257// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
258// Fio2: "-E"
259// Fio2: "-o" "cl-outputs.i"
260
261// RUN: %clang_cl /P /obar.x /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE1 %s
262// FioRACE1: "-E"
263// FioRACE1: "-o" "foo.x"
264
265// RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
266// FioRACE2: "-E"
267// FioRACE2: "-o" "foo.x"
268