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=W1 %s
177 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
180 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
183 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
186 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
189 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
190 // ZP: -fpack-struct=1
192 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
193 // ZP2: -fpack-struct=2
195 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
198 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
199 // FI: "-include" "asdf.h"
201 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
202 // FI_: "-include" "asdf.h"
204 // We forward any unrecognized -W diagnostic options to cc1.
205 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
207 // WJoined: "-Wunused-pragmas"
209 // We recognize -f[no-]strict-aliasing.
210 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
211 // DEFAULTSTRICT: "-relaxed-aliasing"
212 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
213 // STRICT-NOT: "-relaxed-aliasing"
214 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
215 // NOSTRICT: "-relaxed-aliasing"
217 // For some warning ids, we can map from MSVC warning to Clang warning.
218 // RUN: %clang_cl -wd4005 -wd4996 -wd4910 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
220 // Wno: "-Wno-macro-redefined"
221 // Wno: "-Wno-deprecated-declarations"
222 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
224 // Ignored options. Check that we don't get "unused during compilation" errors.
225 // RUN: %clang_cl /c \
228 // RUN: /cgthreads4 \
229 // RUN: /cgthreads8 \
231 // RUN: /errorReport:foo \
246 // RUN: /volatile:iso \
251 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
252 // IGNORED-NOT: argument unused during compilation
253 // IGNORED-NOT: no such file or directory
254 // Don't confuse /openmp- with the /o flag:
255 // IGNORED-NOT: "-o" "penmp-.obj"
257 // Ignored options and compile-only options are ignored for link jobs.
259 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
260 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
261 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
262 // LINKUNUSED-NOT: argument unused during compilation
264 // Support ignoring warnings about unused arguments.
265 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
266 // UNUSED-NOT: argument unused during compilation
268 // Unsupported but parsed options. Check that we don't error on them.
269 // (/Zs is for syntax-only)
270 // RUN: %clang_cl /Zs \
278 // RUN: /Fafilename \
281 // RUN: /favor:blend \
285 // RUN: /FpDebug\main.pch \
309 // RUN: /homeparams \
317 // RUN: /Qfast_transcendentals \
319 // RUN: /Qimprecise_fwaits \
321 // RUN: /Qvec-report:2 \
324 // RUN: /volatile:ms \
331 // RUN: /Ycstdafx.h \
335 // RUN: /Yustdafx.h \
343 // RUN: /ZW:nostdlib \
346 // We support -Xclang for forwarding options to cc1.
347 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
349 // Xclang: "hellocc1"
351 // RTTI is on by default. /GR- controls -fno-rtti-data.
352 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
353 // NoRTTI: "-fno-rtti-data"
354 // NoRTTI-NOT: "-fno-rtti"
355 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
356 // RTTI-NOT: "-fno-rtti-data"
357 // RTTI-NOT: "-fno-rtti"
359 // thread safe statics are off for versions < 19.
360 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
361 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
362 // NoThreadSafeStatics: "-fno-threadsafe-statics"
364 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
365 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
367 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
369 // Zi: "-debug-info-kind=line-tables-only"
371 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
373 // Z7: "-debug-info-kind=line-tables-only"
375 // This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
376 // later on the command line, so it should win. Interestingly the cc1 arguments
377 // came out right, but had wrong semantics, because an invariant assumed by
378 // CompilerInvocation was violated: it expects that at most one of {gdwarfN,
379 // line-tables-only} appear. If you assume that, then you can safely use
380 // Args.hasArg to test whether a boolean flag is present without caring
381 // where it appeared. And for this test, it appeared to the left of -gdwarf
382 // which made it "win". This test could not detect that bug.
383 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
384 // Z7_gdwarf: "-gcodeview"
385 // Z7_gdwarf: "-debug-info-kind=limited"
386 // Z7_gdwarf: "-dwarf-version=4"
388 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
391 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
394 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
395 // ENV-CL: "-ffunction-sections"
397 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
398 // ENV-_CL_-NOT: "-ffunction-sections"
400 // Accept "core" clang options.
401 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
403 // RUN: --driver-mode=cl \
404 // RUN: -fcolor-diagnostics \
405 // RUN: -fno-color-diagnostics \
406 // RUN: -fdiagnostics-color \
407 // RUN: -fno-diagnostics-color \
408 // RUN: -fdiagnostics-parseable-fixits \
409 // RUN: -ferror-limit=10 \
410 // RUN: -fmsc-version=1800 \
411 // RUN: -fno-strict-aliasing \
412 // RUN: -fstrict-aliasing \
413 // RUN: -fsyntax-only \
414 // RUN: -fms-compatibility \
415 // RUN: -fno-ms-compatibility \
416 // RUN: -fms-extensions \
417 // RUN: -fno-ms-extensions \
418 // RUN: -mllvm -disable-llvm-optzns \
419 // RUN: -Wunused-variable \
420 // RUN: -fmacro-backtrace-limit=0 \
421 // RUN: -Werror /Zs -- %s 2>&1