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