1 // Don't attempt slash switches on msys bash.
2 // REQUIRES: shell-preserves-root
4 // Note: %s must be preceded by --, otherwise it may be interpreted as a
5 // command-line option, e.g. on Mac where %s is commonly under /Users.
10 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
13 // RUN: %clang_cl /C -### -- %s 2>&1 | FileCheck -check-prefix=C %s
14 // C: error: invalid argument '-C' only allowed with '/E, /P or /EP'
16 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
20 // RUN: %clang_cl /Dfoo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
21 // RUN: %clang_cl /D foo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
24 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
28 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
33 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
34 // fpexcept-NOT: -menable-unsafe-fp-math
36 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
37 // fpexcept_: -menable-unsafe-fp-math
39 // RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
40 // fpfast: -menable-unsafe-fp-math
41 // fpfast: -ffast-math
43 // RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
44 // fpprecise-NOT: -menable-unsafe-fp-math
45 // fpprecise-NOT: -ffast-math
47 // RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
48 // fpstrict-NOT: -menable-unsafe-fp-math
49 // fpstrict-NOT: -ffast-math
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 -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
101 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
104 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
107 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
109 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
110 // Oy_: -mdisable-fp-elim
112 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
113 // showIncludes: --show-includes
115 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
116 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
117 // showIncludes_E: warning: argument unused during compilation: '--show-includes'
119 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
120 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
123 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
124 // VD2: -vtordisp-mode=2
126 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
127 // VMG: "-fms-memptr-rep=virtual"
129 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
130 // VMS: "-fms-memptr-rep=single"
132 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
133 // VMM: "-fms-memptr-rep=multiple"
135 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
136 // VMV: "-fms-memptr-rep=virtual"
138 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
139 // VMB: '/vmg' not allowed with '/vmb'
141 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
142 // VMX: '/vms' not allowed with '/vmm'
144 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
145 // VOLATILE-ISO-NOT: "-fms-volatile"
147 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
148 // VOLATILE-MS: "-fms-volatile"
150 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
153 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
154 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
155 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
156 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
157 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
160 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
163 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
166 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
169 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
170 // ZP: -fpack-struct=1
172 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
173 // ZP2: -fpack-struct=2
175 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
178 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
179 // FI: "-include" "asdf.h"
181 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
182 // FI_: "-include" "asdf.h"
184 // We forward any unrecognized -W diagnostic options to cc1.
185 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
187 // WJoined: "-Wunused-pragmas"
189 // We recognize -f[no-]strict-aliasing.
190 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
191 // DEFAULTSTRICT: "-relaxed-aliasing"
192 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
193 // STRICT-NOT: "-relaxed-aliasing"
194 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
195 // NOSTRICT: "-relaxed-aliasing"
197 // For some warning ids, we can map from MSVC warning to Clang warning.
198 // RUN: %clang_cl -wd4005 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
200 // Wno: "-Wno-macro-redefined"
201 // Wno: "-Wno-deprecated-declarations"
203 // Ignored options. Check that we don't get "unused during compilation" errors.
204 // RUN: %clang_cl /c \
206 // RUN: /cgthreads4 \
207 // RUN: /cgthreads8 \
209 // RUN: /errorReport:foo \
224 // RUN: /volatile:iso \
229 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
230 // IGNORED-NOT: argument unused during compilation
231 // IGNORED-NOT: no such file or directory
232 // Don't confuse /openmp- with the /o flag:
233 // IGNORED-NOT: "-o" "penmp-.obj"
235 // Ignored options and compile-only options are ignored for link jobs.
237 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
238 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
239 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
240 // LINKUNUSED-NOT: argument unused during compilation
242 // Support ignoring warnings about unused arguments.
243 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
244 // UNUSED-NOT: argument unused during compilation
246 // Unsupported but parsed options. Check that we don't error on them.
247 // (/Zs is for syntax-only)
248 // RUN: %clang_cl /Zs \
256 // RUN: /Fafilename \
259 // RUN: /favor:blend \
263 // RUN: /FpDebug\main.pch \
287 // RUN: /homeparams \
295 // RUN: /Qfast_transcendentals \
297 // RUN: /Qimprecise_fwaits \
299 // RUN: /Qvec-report:2 \
302 // RUN: /volatile:ms \
309 // RUN: /Ycstdafx.h \
313 // RUN: /Yustdafx.h \
321 // RUN: /ZW:nostdlib \
324 // We support -Xclang for forwarding options to cc1.
325 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
327 // Xclang: "hellocc1"
329 // RTTI is on by default. /GR- controls -fno-rtti-data.
330 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
331 // NoRTTI: "-fno-rtti-data"
332 // NoRTTI-NOT: "-fno-rtti"
333 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
334 // RTTI-NOT: "-fno-rtti-data"
335 // RTTI-NOT: "-fno-rtti"
337 // thread safe statics are off for versions < 19.
338 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
339 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
340 // NoThreadSafeStatics: "-fno-threadsafe-statics"
342 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
343 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
345 // Accept "core" clang options.
346 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
348 // RUN: --driver-mode=cl \
349 // RUN: -ferror-limit=10 \
350 // RUN: -fmsc-version=1800 \
351 // RUN: -fno-strict-aliasing \
352 // RUN: -fstrict-aliasing \
353 // RUN: -mllvm -disable-llvm-optzns \
354 // RUN: -Wunused-variable \
355 // RUN: -fmacro-backtrace-limit=0 \
356 // RUN: -Werror /Zs -- %s 2>&1