]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Driver/cl-options.c
Vendor import of clang trunk r300422:
[FreeBSD/FreeBSD.git] / test / Driver / cl-options.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
5 // Alias options:
6
7 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
8 // c: -c
9
10 // RUN: %clang_cl /C -### -- %s 2>&1 | FileCheck -check-prefix=C %s
11 // C: error: invalid argument '-C' only allowed with '/E, /P or /EP'
12
13 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
14 // C_P: "-E"
15 // C_P: "-C"
16
17 // RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \
18 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=D %s
19 // D: "-D" "foo=bar"
20 // D: "-D" "bar=baz"
21 // D: "-D" "MYDEF=value"
22 // D: "-D" "MYDEF2=foo#bar"
23 // D: "-D" "MYDEF3=a=b"
24 // D: "-D" "MYDEF4="
25
26 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
27 // E: "-E"
28 // E: "-o" "-"
29
30 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
31 // EP: "-E"
32 // EP: "-P"
33 // EP: "-o" "-"
34
35 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
36 // fpexcept-NOT: -menable-unsafe-fp-math
37
38 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
39 // fpexcept_: -menable-unsafe-fp-math
40
41 // RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
42 // fpfast: -menable-unsafe-fp-math
43 // fpfast: -ffast-math
44
45 // RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
46 // fpprecise-NOT: -menable-unsafe-fp-math
47 // fpprecise-NOT: -ffast-math
48
49 // RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
50 // fpstrict-NOT: -menable-unsafe-fp-math
51 // fpstrict-NOT: -ffast-math
52
53 // RUN: %clang_cl /Z7 -gcolumn-info -### -- %s 2>&1 | FileCheck -check-prefix=gcolumn %s
54 // gcolumn: -dwarf-column-info
55
56 // RUN: %clang_cl /Z7 -gno-column-info -### -- %s 2>&1 | FileCheck -check-prefix=gnocolumn %s
57 // gnocolumn-NOT: -dwarf-column-info
58
59 // RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
60 // gdefcolumn-NOT: -dwarf-column-info
61
62 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
63 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
64 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
65 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
66 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
67 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
68 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
69
70 // RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
71 // RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
72 // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
73 // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
74
75 // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
76 // GA: -ftls-model=local-exec
77
78 // RTTI is on by default; just check that we don't error.
79 // RUN: %clang_cl /Zs /GR -- %s 2>&1
80
81 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
82 // GR_: -fno-rtti
83
84 // Security Buffer Check is on by default.
85 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
86 // GS-default: "-stack-protector" "2"
87
88 // RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
89 // GS: "-stack-protector" "2"
90
91 // RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
92 // GS_-NOT: -stack-protector
93
94 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
95 // Gy: -ffunction-sections
96
97 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
98 // Gy_-NOT: -ffunction-sections
99
100 // RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
101 // Gs: "-mstack-probe-size=0"
102 // RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
103 // Gs0: "-mstack-probe-size=0"
104 // RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
105 // Gs4096: "-mstack-probe-size=4096"
106
107 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
108 // Gw: -fdata-sections
109
110 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
111 // Gw_-NOT: -fdata-sections
112
113 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
114 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
115 // SLASH_I: "-I" "myincludedir"
116
117 // RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
118 // RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
119 // Clang's resource header directory should be first:
120 // SLASH_imsvc: "-internal-isystem" "{{[^"]*}}lib{{(64)?/|\\\\}}clang{{[^"]*}}include"
121 // SLASH_imsvc: "-internal-isystem" "myincludedir"
122
123 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
124 // J: -fno-signed-char
125
126 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
127 // O: /Ofoo
128
129 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
130 // Ob0: -fno-inline
131
132 // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
133 // RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
134 // RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
135 // Ob2-NOT: warning: argument unused during compilation: '/O2'
136 // Ob2: -finline-functions
137
138 // RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
139 // RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
140 // Ob1: -finline-hint-functions
141
142 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
143 // Od: -O0
144
145 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
146 // Oi-NOT: -fno-builtin
147
148 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
149 // Oi_: -fno-builtin
150
151 // RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
152 // RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
153 // Os-NOT: -mdisable-fp-elim
154 // Os: -momit-leaf-frame-pointer
155 // Os: -Os
156
157 // RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
158 // RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
159 // Ot-NOT: -mdisable-fp-elim
160 // Ot: -momit-leaf-frame-pointer
161 // Ot: -O2
162
163 // RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
164 // RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
165 // Ox-NOT: -mdisable-fp-elim
166 // Ox: -momit-leaf-frame-pointer
167 // Ox: -O2
168
169 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
170 // PR24003: -mdisable-fp-elim
171 // PR24003: -momit-leaf-frame-pointer
172 // PR24003: -Os
173
174 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
175 // Oy_2: -momit-leaf-frame-pointer
176 // Oy_2: -O2
177
178 // RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1
179
180 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
181 // Oy_: -mdisable-fp-elim
182
183 // RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
184 // Qvec: -vectorize-loops
185
186 // RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
187 // Qvec_-NOT: -vectorize-loops
188
189 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
190 // showIncludes: --show-includes
191
192 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
193 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
194 // showIncludes_E: warning: argument unused during compilation: '--show-includes'
195
196 // /source-charset: should warn on everything except UTF-8.
197 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
198 // source-charset-utf-16: invalid value 'utf-16'
199
200 // /execution-charset: should warn on everything except UTF-8.
201 // RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
202 // execution-charset-utf-16: invalid value 'utf-16'
203 //
204 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
205 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
206 // U: "-U" "mymacro"
207
208 // RUN: %clang_cl /validate-charset -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset %s
209 // validate-charset: -Winvalid-source-encoding
210
211 // RUN: %clang_cl /validate-charset- -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset_ %s
212 // validate-charset_: -Wno-invalid-source-encoding
213
214 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
215 // VD2: -vtordisp-mode=2
216
217 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
218 // VMG: "-fms-memptr-rep=virtual"
219
220 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
221 // VMS: "-fms-memptr-rep=single"
222
223 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
224 // VMM: "-fms-memptr-rep=multiple"
225
226 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
227 // VMV: "-fms-memptr-rep=virtual"
228
229 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
230 // VMB: '/vmg' not allowed with '/vmb'
231
232 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
233 // VMX: '/vms' not allowed with '/vmm'
234
235 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
236 // VOLATILE-ISO-NOT: "-fms-volatile"
237
238 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
239 // VOLATILE-MS: "-fms-volatile"
240
241 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
242 // W0: -w
243
244 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
245 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
246 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
247 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
248 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
249 // W1: -Wall
250 // W4: -WCL4
251
252 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
253 // WX: -Werror
254
255 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
256 // WX_: -Wno-error
257
258 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
259 // w: -w
260
261 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
262 // ZP: -fpack-struct=1
263
264 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
265 // ZP2: -fpack-struct=2
266
267 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
268 // Zs: -fsyntax-only
269
270 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
271 // FI: "-include" "asdf.h"
272
273 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
274 // FI_: "-include" "asdf.h"
275
276 // RUN: %clang_cl /TP /c -### -- %s 2>&1 | FileCheck -check-prefix=NO-GX %s
277 // NO-GX-NOT: "-fcxx-exceptions" "-fexceptions"
278
279 // RUN: %clang_cl /TP /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
280 // GX: "-fcxx-exceptions" "-fexceptions"
281
282 // RUN: %clang_cl /TP /c /GX /GX- -### -- %s 2>&1 | FileCheck -check-prefix=GX_ %s
283 // GX_-NOT: "-fcxx-exceptions" "-fexceptions"
284
285 // We forward any unrecognized -W diagnostic options to cc1.
286 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
287 // WJoined: "-cc1"
288 // WJoined: "-Wunused-pragmas"
289
290 // We recognize -f[no-]strict-aliasing.
291 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
292 // DEFAULTSTRICT: "-relaxed-aliasing"
293 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
294 // STRICT-NOT: "-relaxed-aliasing"
295 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
296 // NOSTRICT: "-relaxed-aliasing"
297
298 // We recognize -f[no-]delayed-template-parsing.
299 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
300 // DELAYEDDEFAULT: "-fdelayed-template-parsing"
301 // RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
302 // DELAYEDON: "-fdelayed-template-parsing"
303 // RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
304 // DELAYEDOFF-NOT: "-fdelayed-template-parsing"
305
306 // For some warning ids, we can map from MSVC warning to Clang warning.
307 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
308 // Wno: "-cc1"
309 // Wno: "-Wno-macro-redefined"
310 // Wno: "-Wno-unused-parameter"
311 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
312 // Wno: "-Wno-deprecated-declarations"
313
314 // Ignored options. Check that we don't get "unused during compilation" errors.
315 // RUN: %clang_cl /c \
316 // RUN:    /analyze- \
317 // RUN:    /bigobj \
318 // RUN:    /cgthreads4 \
319 // RUN:    /cgthreads8 \
320 // RUN:    /d2FastFail \
321 // RUN:    /d2Zi+ \
322 // RUN:    /errorReport:foo \
323 // RUN:    /execution-charset:utf-8 \
324 // RUN:    /FC \
325 // RUN:    /Fdfoo \
326 // RUN:    /FS \
327 // RUN:    /Gd \
328 // RUN:    /GF \
329 // RUN:    /GS- \
330 // RUN:    /kernel- \
331 // RUN:    /nologo \
332 // RUN:    /openmp- \
333 // RUN:    /RTC1 \
334 // RUN:    /sdl \
335 // RUN:    /sdl- \
336 // RUN:    /source-charset:utf-8 \
337 // RUN:    /utf-8 \
338 // RUN:    /vmg \
339 // RUN:    /volatile:iso \
340 // RUN:    /w12345 \
341 // RUN:    /wd1234 \
342 // RUN:    /Zo \
343 // RUN:    /Zo- \
344 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
345 // IGNORED-NOT: argument unused during compilation
346 // IGNORED-NOT: no such file or directory
347 // Don't confuse /openmp- with the /o flag:
348 // IGNORED-NOT: "-o" "penmp-.obj"
349
350 // Ignored options and compile-only options are ignored for link jobs.
351 // RUN: touch %t.obj
352 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
353 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
354 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
355 // LINKUNUSED-NOT: argument unused during compilation
356
357 // Support ignoring warnings about unused arguments.
358 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
359 // UNUSED-NOT: argument unused during compilation
360
361 // Unsupported but parsed options. Check that we don't error on them.
362 // (/Zs is for syntax-only)
363 // RUN: %clang_cl /Zs \
364 // RUN:     /AIfoo \
365 // RUN:     /clr:pure \
366 // RUN:     /docname \
367 // RUN:     /EHsc \
368 // RUN:     /F \
369 // RUN:     /FA \
370 // RUN:     /FAc \
371 // RUN:     /Fafilename \
372 // RUN:     /FAs \
373 // RUN:     /FAu \
374 // RUN:     /favor:blend \
375 // RUN:     /Fifoo \
376 // RUN:     /Fmfoo \
377 // RUN:     /FpDebug\main.pch \
378 // RUN:     /Frfoo \
379 // RUN:     /FRfoo \
380 // RUN:     /FU foo \
381 // RUN:     /Fx \
382 // RUN:     /G1 \
383 // RUN:     /G2 \
384 // RUN:     /GA \
385 // RUN:     /Gd \
386 // RUN:     /Ge \
387 // RUN:     /Gh \
388 // RUN:     /GH \
389 // RUN:     /GL \
390 // RUN:     /GL- \
391 // RUN:     /Gm \
392 // RUN:     /Gm- \
393 // RUN:     /Gr \
394 // RUN:     /GS \
395 // RUN:     /GT \
396 // RUN:     /guard:cf \
397 // RUN:     /guard:cf- \
398 // RUN:     /GX \
399 // RUN:     /Gv \
400 // RUN:     /Gz \
401 // RUN:     /GZ \
402 // RUN:     /H \
403 // RUN:     /homeparams \
404 // RUN:     /hotpatch \
405 // RUN:     /kernel \
406 // RUN:     /LN \
407 // RUN:     /MP \
408 // RUN:     /o foo.obj \
409 // RUN:     /ofoo.obj \
410 // RUN:     /openmp \
411 // RUN:     /Qfast_transcendentals \
412 // RUN:     /QIfist \
413 // RUN:     /Qimprecise_fwaits \
414 // RUN:     /Qpar \
415 // RUN:     /Qvec-report:2 \
416 // RUN:     /u \
417 // RUN:     /V \
418 // RUN:     /volatile:ms \
419 // RUN:     /wfoo \
420 // RUN:     /WL \
421 // RUN:     /Wp64 \
422 // RUN:     /X \
423 // RUN:     /Y- \
424 // RUN:     /Yc \
425 // RUN:     /Ycstdafx.h \
426 // RUN:     /Yd \
427 // RUN:     /Yl- \
428 // RUN:     /Ylfoo \
429 // RUN:     /Yustdafx.h \
430 // RUN:     /Z7 \
431 // RUN:     /Za \
432 // RUN:     /Ze \
433 // RUN:     /Zg \
434 // RUN:     /Zi \
435 // RUN:     /ZI \
436 // RUN:     /Zl \
437 // RUN:     /ZW:nostdlib \
438 // RUN:     -- %s 2>&1
439
440 // We support -Xclang for forwarding options to cc1.
441 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
442 // Xclang: "-cc1"
443 // Xclang: "hellocc1"
444
445 // Files under /Users are often confused with the /U flag. (This could happen
446 // for other flags too, but this is the one people run into.)
447 // RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
448 // SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
449 // SlashU: note: Use '--' to treat subsequent arguments as filenames
450
451 // RTTI is on by default. /GR- controls -fno-rtti-data.
452 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
453 // NoRTTI: "-fno-rtti-data"
454 // NoRTTI-NOT: "-fno-rtti"
455 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
456 // RTTI-NOT: "-fno-rtti-data"
457 // RTTI-NOT: "-fno-rtti"
458
459 // thread safe statics are off for versions < 19.
460 // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
461 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
462 // NoThreadSafeStatics: "-fno-threadsafe-statics"
463
464 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
465 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
466
467 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
468 // Zi: "-gcodeview"
469 // Zi: "-debug-info-kind=limited"
470
471 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
472 // Z7: "-gcodeview"
473 // Z7: "-debug-info-kind=limited"
474
475 // RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
476 // Z7GMLT: "-gcodeview"
477 // Z7GMLT: "-debug-info-kind=line-tables-only"
478
479 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
480 // ZGMLT: "-gcodeview"
481 // ZGMLT: "-debug-info-kind=line-tables-only"
482
483 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
484 // BreproDefault: "-mincremental-linker-compatible"
485
486 // RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
487 // Brepro-NOT: "-mincremental-linker-compatible"
488
489 // RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
490 // Brepro_: "-mincremental-linker-compatible"
491
492 // This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
493 // later on the command line, so it should win. Interestingly the cc1 arguments
494 // came out right, but had wrong semantics, because an invariant assumed by
495 // CompilerInvocation was violated: it expects that at most one of {gdwarfN,
496 // line-tables-only} appear. If you assume that, then you can safely use
497 // Args.hasArg to test whether a boolean flag is present without caring
498 // where it appeared. And for this test, it appeared to the left of -gdwarf
499 // which made it "win". This test could not detect that bug.
500 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
501 // Z7_gdwarf: "-gcodeview"
502 // Z7_gdwarf: "-debug-info-kind=limited"
503 // Z7_gdwarf: "-dwarf-version=4"
504
505 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
506 // CXX11: -std=c++11
507
508 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
509 // CXX14: -std=c++14
510
511 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
512 // STDCXX14: -std=c++14
513
514 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
515 // STDCXXLATEST: -std=c++1z
516
517 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
518 // ENV-CL: "-ffunction-sections"
519
520 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
521 // ENV-_CL_-NOT: "-ffunction-sections"
522
523 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
524
525 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
526 // LTO: -flto
527
528 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s
529 // LTO-THIN: -flto=thin
530
531 // RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s
532 // LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
533
534 // Accept "core" clang options.
535 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
536 // RUN: %clang_cl \
537 // RUN:     --driver-mode=cl \
538 // RUN:     -fcolor-diagnostics \
539 // RUN:     -fno-color-diagnostics \
540 // RUN:     -fdiagnostics-color \
541 // RUN:     -fno-diagnostics-color \
542 // RUN:     -fdiagnostics-parseable-fixits \
543 // RUN:     -fdiagnostics-absolute-paths \
544 // RUN:     -ferror-limit=10 \
545 // RUN:     -fmsc-version=1800 \
546 // RUN:     -fno-strict-aliasing \
547 // RUN:     -fstrict-aliasing \
548 // RUN:     -fsyntax-only \
549 // RUN:     -fms-compatibility \
550 // RUN:     -fno-ms-compatibility \
551 // RUN:     -fms-extensions \
552 // RUN:     -fno-ms-extensions \
553 // RUN:     -Xclang -disable-llvm-passes \
554 // RUN:     -resource-dir asdf \
555 // RUN:     -resource-dir=asdf \
556 // RUN:     -Wunused-variable \
557 // RUN:     -fmacro-backtrace-limit=0 \
558 // RUN:     -fstandalone-debug \
559 // RUN:     -flimit-debug-info \
560 // RUN:     -flto \
561 // RUN:     -Werror /Zs -- %s 2>&1
562
563
564 void f() { }