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.
7 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
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'
13 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
17 // RUN: %clang_cl /Dfoo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
18 // RUN: %clang_cl /D foo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
21 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
25 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
30 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
31 // fpexcept-NOT: -menable-unsafe-fp-math
33 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
34 // fpexcept_: -menable-unsafe-fp-math
36 // RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
37 // fpfast: -menable-unsafe-fp-math
38 // fpfast: -ffast-math
40 // RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
41 // fpprecise-NOT: -menable-unsafe-fp-math
42 // fpprecise-NOT: -ffast-math
44 // RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
45 // fpstrict-NOT: -menable-unsafe-fp-math
46 // fpstrict-NOT: -ffast-math
48 // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
49 // GA: -ftls-model=local-exec
51 // RTTI is on by default; just check that we don't error.
52 // RUN: %clang_cl /Zs /GR -- %s 2>&1
54 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
57 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
58 // Gy: -ffunction-sections
60 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
61 // Gy_-NOT: -ffunction-sections
63 // RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
64 // Gs: "-mstack-probe-size=0"
65 // RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
66 // Gs0: "-mstack-probe-size=0"
67 // RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
68 // Gs4096: "-mstack-probe-size=4096"
70 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
71 // Gw: -fdata-sections
73 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
74 // Gw_-NOT: -fdata-sections
76 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
77 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
78 // SLASH_I: "-I" "myincludedir"
80 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
81 // J: -fno-signed-char
83 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
86 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
89 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
92 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
93 // Oi-NOT: -fno-builtin
95 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
98 // RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
99 // RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
100 // Os-NOT: -mdisable-fp-elim
101 // Os: -momit-leaf-frame-pointer
104 // RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
105 // RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
106 // Ot-NOT: -mdisable-fp-elim
107 // Ot: -momit-leaf-frame-pointer
110 // RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
111 // RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
112 // Ox-NOT: -mdisable-fp-elim
113 // Ox: -momit-leaf-frame-pointer
116 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
117 // PR24003: -mdisable-fp-elim
118 // PR24003: -momit-leaf-frame-pointer
121 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
123 // RUN: %clang_cl --target=i686-pc-win32 /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
124 // Oy_: -mdisable-fp-elim
126 // RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
127 // Qvec: -vectorize-loops
129 // RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
130 // Qvec_-NOT: -vectorize-loops
132 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
133 // showIncludes: --show-includes
135 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
136 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
137 // showIncludes_E: warning: argument unused during compilation: '--show-includes'
139 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
140 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
143 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
144 // VD2: -vtordisp-mode=2
146 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
147 // VMG: "-fms-memptr-rep=virtual"
149 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
150 // VMS: "-fms-memptr-rep=single"
152 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
153 // VMM: "-fms-memptr-rep=multiple"
155 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
156 // VMV: "-fms-memptr-rep=virtual"
158 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
159 // VMB: '/vmg' not allowed with '/vmb'
161 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
162 // VMX: '/vms' not allowed with '/vmm'
164 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
165 // VOLATILE-ISO-NOT: "-fms-volatile"
167 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
168 // VOLATILE-MS: "-fms-volatile"
170 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
173 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
174 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
175 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
176 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
177 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
181 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
184 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
187 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
190 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
191 // ZP: -fpack-struct=1
193 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
194 // ZP2: -fpack-struct=2
196 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
199 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
200 // FI: "-include" "asdf.h"
202 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
203 // FI_: "-include" "asdf.h"
205 // We forward any unrecognized -W diagnostic options to cc1.
206 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
208 // WJoined: "-Wunused-pragmas"
210 // We recognize -f[no-]strict-aliasing.
211 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
212 // DEFAULTSTRICT: "-relaxed-aliasing"
213 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
214 // STRICT-NOT: "-relaxed-aliasing"
215 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
216 // NOSTRICT: "-relaxed-aliasing"
218 // For some warning ids, we can map from MSVC warning to Clang warning.
219 // RUN: %clang_cl -wd4005 -wd4996 -wd4910 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
221 // Wno: "-Wno-macro-redefined"
222 // Wno: "-Wno-deprecated-declarations"
223 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
225 // Ignored options. Check that we don't get "unused during compilation" errors.
226 // RUN: %clang_cl /c \
229 // RUN: /cgthreads4 \
230 // RUN: /cgthreads8 \
232 // RUN: /errorReport:foo \
247 // RUN: /volatile:iso \
252 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
253 // IGNORED-NOT: argument unused during compilation
254 // IGNORED-NOT: no such file or directory
255 // Don't confuse /openmp- with the /o flag:
256 // IGNORED-NOT: "-o" "penmp-.obj"
258 // Ignored options and compile-only options are ignored for link jobs.
260 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
261 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
262 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
263 // LINKUNUSED-NOT: argument unused during compilation
265 // Support ignoring warnings about unused arguments.
266 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
267 // UNUSED-NOT: argument unused during compilation
269 // Unsupported but parsed options. Check that we don't error on them.
270 // (/Zs is for syntax-only)
271 // RUN: %clang_cl /Zs \
279 // RUN: /Fafilename \
282 // RUN: /favor:blend \
286 // RUN: /FpDebug\main.pch \
312 // RUN: /homeparams \
320 // RUN: /Qfast_transcendentals \
322 // RUN: /Qimprecise_fwaits \
324 // RUN: /Qvec-report:2 \
327 // RUN: /volatile:ms \
334 // RUN: /Ycstdafx.h \
338 // RUN: /Yustdafx.h \
346 // RUN: /ZW:nostdlib \
349 // We support -Xclang for forwarding options to cc1.
350 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
352 // Xclang: "hellocc1"
354 // RTTI is on by default. /GR- controls -fno-rtti-data.
355 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
356 // NoRTTI: "-fno-rtti-data"
357 // NoRTTI-NOT: "-fno-rtti"
358 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
359 // RTTI-NOT: "-fno-rtti-data"
360 // RTTI-NOT: "-fno-rtti"
362 // thread safe statics are off for versions < 19.
363 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
364 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
365 // NoThreadSafeStatics: "-fno-threadsafe-statics"
367 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
368 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
370 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
372 // Zi: "-debug-info-kind=line-tables-only"
374 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
376 // Z7: "-debug-info-kind=line-tables-only"
378 // This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
379 // later on the command line, so it should win. Interestingly the cc1 arguments
380 // came out right, but had wrong semantics, because an invariant assumed by
381 // CompilerInvocation was violated: it expects that at most one of {gdwarfN,
382 // line-tables-only} appear. If you assume that, then you can safely use
383 // Args.hasArg to test whether a boolean flag is present without caring
384 // where it appeared. And for this test, it appeared to the left of -gdwarf
385 // which made it "win". This test could not detect that bug.
386 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
387 // Z7_gdwarf: "-gcodeview"
388 // Z7_gdwarf: "-debug-info-kind=limited"
389 // Z7_gdwarf: "-dwarf-version=4"
391 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
394 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
397 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
398 // ENV-CL: "-ffunction-sections"
400 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
401 // ENV-_CL_-NOT: "-ffunction-sections"
403 // Accept "core" clang options.
404 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
406 // RUN: --driver-mode=cl \
407 // RUN: -fcolor-diagnostics \
408 // RUN: -fno-color-diagnostics \
409 // RUN: -fdiagnostics-color \
410 // RUN: -fno-diagnostics-color \
411 // RUN: -fdiagnostics-parseable-fixits \
412 // RUN: -ferror-limit=10 \
413 // RUN: -fmsc-version=1800 \
414 // RUN: -fno-strict-aliasing \
415 // RUN: -fstrict-aliasing \
416 // RUN: -fsyntax-only \
417 // RUN: -fms-compatibility \
418 // RUN: -fno-ms-compatibility \
419 // RUN: -fms-extensions \
420 // RUN: -fno-ms-extensions \
421 // RUN: -mllvm -disable-llvm-optzns \
422 // RUN: -Wunused-variable \
423 // RUN: -fmacro-backtrace-limit=0 \
424 // RUN: -Werror /Zs -- %s 2>&1