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 // RTTI is on by default; just check that we don't error.
34 // RUN: %clang_cl /Zs /GR -- %s 2>&1
36 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
39 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
40 // Gy: -ffunction-sections
42 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
43 // Gy_-NOT: -ffunction-sections
45 // RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
46 // Gs: "-mstack-probe-size=0"
47 // RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
48 // Gs0: "-mstack-probe-size=0"
49 // RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
50 // Gs4096: "-mstack-probe-size=4096"
52 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
53 // Gw: -fdata-sections
55 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
56 // Gw_-NOT: -fdata-sections
58 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
59 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
60 // SLASH_I: "-I" "myincludedir"
62 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
63 // J: -fno-signed-char
65 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
68 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
71 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
74 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
75 // Oi-NOT: -fno-builtin
77 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
80 // RUN: %clang_cl /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
83 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
86 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
89 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
91 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
92 // Oy_: -mdisable-fp-elim
94 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
95 // showIncludes: --show-includes
97 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
98 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
99 // showIncludes_E: warning: argument unused during compilation: '--show-includes'
101 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
102 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
105 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
106 // VD2: -vtordisp-mode=2
108 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
109 // VMG: "-fms-memptr-rep=virtual"
111 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
112 // VMS: "-fms-memptr-rep=single"
114 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
115 // VMM: "-fms-memptr-rep=multiple"
117 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
118 // VMV: "-fms-memptr-rep=virtual"
120 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
121 // VMB: '/vmg' not allowed with '/vmb'
123 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
124 // VMX: '/vms' not allowed with '/vmm'
126 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
127 // VOLATILE-ISO-NOT: "-fms-volatile"
129 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
130 // VOLATILE-MS: "-fms-volatile"
132 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
135 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
136 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
137 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
138 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
139 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
142 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
145 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
148 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
151 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
152 // ZP: -fpack-struct=1
154 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
155 // ZP2: -fpack-struct=2
157 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
160 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
161 // FI: "-include" "asdf.h"
163 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
164 // FI_: "-include" "asdf.h"
166 // We forward any unrecognized -W diagnostic options to cc1.
167 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
169 // WJoined: "-Wunused-pragmas"
171 // We recognize -f[no-]strict-aliasing.
172 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
173 // DEFAULTSTRICT: "-relaxed-aliasing"
174 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
175 // STRICT-NOT: "-relaxed-aliasing"
176 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
177 // NOSTRICT: "-relaxed-aliasing"
179 // For some warning ids, we can map from MSVC warning to Clang warning.
180 // RUN: %clang_cl -wd4005 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
182 // Wno: "-Wno-macro-redefined"
183 // Wno: "-Wno-deprecated-declarations"
185 // Ignored options. Check that we don't get "unused during compilation" errors.
186 // RUN: %clang_cl /c \
188 // RUN: /cgthreads4 \
189 // RUN: /cgthreads8 \
191 // RUN: /errorReport:foo \
206 // RUN: /volatile:iso \
211 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
212 // IGNORED-NOT: argument unused during compilation
213 // IGNORED-NOT: no such file or directory
214 // Don't confuse /openmp- with the /o flag:
215 // IGNORED-NOT: "-o" "penmp-.obj"
217 // Ignored options and compile-only options are ignored for link jobs.
219 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
220 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
221 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
222 // LINKUNUSED-NOT: argument unused during compilation
224 // Support ignoring warnings about unused arguments.
225 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
226 // UNUSED-NOT: argument unused during compilation
228 // Unsupported but parsed options. Check that we don't error on them.
229 // (/Zs is for syntax-only)
230 // RUN: %clang_cl /Zs \
238 // RUN: /Fafilename \
241 // RUN: /favor:blend \
245 // RUN: /FpDebug\main.pch \
246 // RUN: /fp:precise \
270 // RUN: /homeparams \
278 // RUN: /Qfast_transcendentals \
280 // RUN: /Qimprecise_fwaits \
282 // RUN: /Qvec-report:2 \
285 // RUN: /volatile:ms \
292 // RUN: /Ycstdafx.h \
296 // RUN: /Yustdafx.h \
304 // RUN: /ZW:nostdlib \
307 // We support -Xclang for forwarding options to cc1.
308 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
310 // Xclang: "hellocc1"
312 // RTTI is on by default. /GR- controls -fno-rtti-data.
313 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
314 // NoRTTI: "-fno-rtti-data"
315 // NoRTTI-NOT: "-fno-rtti"
316 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
317 // RTTI-NOT: "-fno-rtti-data"
318 // RTTI-NOT: "-fno-rtti"
320 // Accept "core" clang options.
321 // (/Zs is for syntax-only)
323 // RUN: --driver-mode=cl \
324 // RUN: -ferror-limit=10 \
325 // RUN: -fmsc-version=1800 \
326 // RUN: -fno-strict-aliasing \
327 // RUN: -fstrict-aliasing \
328 // RUN: -mllvm -disable-llvm-optzns \
329 // RUN: -Wunused-variables \
330 // RUN: /Zs -- %s 2>&1