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