1 // Don't attempt slash switches on msys bash.
2 // REQUIRES: shell-preserves-root
3
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.
6
7
8 // Alias options:
9
10 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
11 // c: -c
12
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'
15
16 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
17 // C_P: "-E"
18 // C_P: "-C"
19
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
22 // D: "-D" "foo=bar"
23
24 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
25 // E: "-E"
26 // E: "-o" "-"
27
28 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
29 // EP: "-E"
30 // EP: "-P"
31 // EP: "-o" "-"
32
33 // RTTI is on by default; just check that we don't error.
34 // RUN: %clang_cl /Zs /GR -- %s 2>&1
35
36 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
37 // GR_: -fno-rtti
38
39 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
40 // Gy: -ffunction-sections
41
42 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
43 // Gy_-NOT: -ffunction-sections
44
45 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
46 // Gw: -fdata-sections
47
48 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
49 // Gw_-NOT: -fdata-sections
50
51 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
52 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
53 // SLASH_I: "-I" "myincludedir"
54
55 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
56 // J: -fno-signed-char
57
58 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
59 // O: -Ofoo
60
61 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
62 // Ob0: -fno-inline
63
64 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
65 // Od: -O0
66
67 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
68 // Oi-NOT: -fno-builtin
69
70 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
71 // Oi_: -fno-builtin
72
73 // RUN: %clang_cl /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
74 // Os: -Os
75
76 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
77 // Ot: -O2
78
79 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
80 // Ox: -O3
81
82 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
83
84 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
85 // Oy_: -mdisable-fp-elim
86
87 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
88 // showIncludes: --show-includes
89
90 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
91 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
92 // showIncludes_E: warning: argument unused during compilation: '--show-includes'
93
94 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
95 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
96 // U: "-U" "mymacro"
97
98 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
99 // VD2: -vtordisp-mode=2
100
101 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
102 // VMG: "-fms-memptr-rep=virtual"
103
104 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
105 // VMS: "-fms-memptr-rep=single"
106
107 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
108 // VMM: "-fms-memptr-rep=multiple"
109
110 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
111 // VMV: "-fms-memptr-rep=virtual"
112
113 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
114 // VMB: '/vmg' not allowed with '/vmb'
115
116 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
117 // VMX: '/vms' not allowed with '/vmm'
118
119 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
120 // W0: -w
121
122 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
123 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
124 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
125 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
126 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
127 // W1: -Wall
128
129 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
130 // WX: -Werror
131
132 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
133 // WX_: -Wno-error
134
135 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
136 // w: -w
137
138 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
139 // ZP: -fpack-struct=1
140
141 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
142 // ZP2: -fpack-struct=2
143
144 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
145 // Zs: -fsyntax-only
146
147 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
148 // FI: "-include" "asdf.h"
149
150 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
151 // FI_: "-include" "asdf.h"
152
153 // We forward any unrecognized -W diagnostic options to cc1.
154 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
155 // WJoined: "-cc1"
156 // WJoined: "-Wunused-pragmas"
157
158 // We recognize -f[no-]strict-aliasing.
159 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
160 // DEFAULTSTRICT: "-relaxed-aliasing"
161 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
162 // STRICT-NOT: "-relaxed-aliasing"
163 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
164 // NOSTRICT: "-relaxed-aliasing"
165
166 // For some warning ids, we can map from MSVC warning to Clang warning.
167 // RUN: %clang_cl -wd4005 -### -- %s 2>&1 | FileCheck -check-prefix=wd4005 %s
168 // wd4005: "-cc1"
169 // wd4005: "-Wno-macro-redefined"
170
171 // Ignored options. Check that we don't get "unused during compilation" errors.
172 // (/Zs is for syntax-only)
173 // RUN: %clang_cl /Zs \
174 // RUN: /analyze- \
175 // RUN: /cgthreads4 \
176 // RUN: /cgthreads8 \
177 // RUN: /d2Zi+ \
178 // RUN: /errorReport:foo \
179 // RUN: /FS \
180 // RUN: /Gd \
181 // RUN: /GF \
182 // RUN: /GS- \
183 // RUN: /kernel- \
184 // RUN: /nologo \
185 // RUN: /Ob1 \
186 // RUN: /Ob2 \
187 // RUN: /RTC1 \
188 // RUN: /sdl \
189 // RUN: /sdl- \
190 // RUN: /vmg \
191 // RUN: /volatile:iso \
192 // RUN: /w12345 \
193 // RUN: /wd1234 \
194 // RUN: /Zo \
195 // RUN: /Zo- \
196 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
197 // IGNORED-NOT: argument unused during compilation
198 // IGNORED-NOT: no such file or directory
199
200 // Ignored options and compile-only options are ignored for link jobs.
201 // RUN: touch %t.obj
202 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
203 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
204 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
205 // LINKUNUSED-NOT: argument unused during compilation
206
207 // Support ignoring warnings about unused arguments.
208 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
209 // UNUSED-NOT: argument unused during compilation
210
211 // Unsupported but parsed options. Check that we don't error on them.
212 // (/Zs is for syntax-only)
213 // RUN: %clang_cl /Zs \
214 // RUN: /AIfoo \
215 // RUN: /clr:pure \
216 // RUN: /docname \
217 // RUN: /EHsc \
218 // RUN: /F \
219 // RUN: /FA \
220 // RUN: /FAc \
221 // RUN: /Fafilename \
222 // RUN: /FAs \
223 // RUN: /FAu \
224 // RUN: /favor:blend \
225 // RUN: /FC \
226 // RUN: /Fdfoo \
227 // RUN: /Fifoo \
228 // RUN: /Fmfoo \
229 // RUN: /FpDebug\main.pch \
230 // RUN: /fp:precise \
231 // RUN: /Frfoo \
232 // RUN: /FRfoo \
233 // RUN: /FU foo \
234 // RUN: /Fx \
235 // RUN: /G1 \
236 // RUN: /G2 \
237 // RUN: /GA \
238 // RUN: /Gd \
239 // RUN: /Ge \
240 // RUN: /Gh \
241 // RUN: /GH \
242 // RUN: /GL \
243 // RUN: /GL- \
244 // RUN: /Gm \
245 // RUN: /Gm- \
246 // RUN: /Gr \
247 // RUN: /GS \
248 // RUN: /Gs1000 \
249 // RUN: /GT \
250 // RUN: /GX \
251 // RUN: /Gv \
252 // RUN: /Gz \
253 // RUN: /GZ \
254 // RUN: /H \
255 // RUN: /homeparams \
256 // RUN: /hotpatch \
257 // RUN: /kernel \
258 // RUN: /LN \
259 // RUN: /MP \
260 // RUN: /o foo.obj \
261 // RUN: /ofoo.obj \
262 // RUN: /openmp \
263 // RUN: /Qfast_transcendentals \
264 // RUN: /QIfist \
265 // RUN: /Qimprecise_fwaits \
266 // RUN: /Qpar \
267 // RUN: /Qvec-report:2 \
268 // RUN: /u \
269 // RUN: /V \
270 // RUN: /volatile:ms \
271 // RUN: /wfoo \
272 // RUN: /WL \
273 // RUN: /Wp64 \
274 // RUN: /X \
275 // RUN: /Y- \
276 // RUN: /Yc \
277 // RUN: /Ycstdafx.h \
278 // RUN: /Yd \
279 // RUN: /Yl- \
280 // RUN: /Ylfoo \
281 // RUN: /Yustdafx.h \
282 // RUN: /Z7 \
283 // RUN: /Za \
284 // RUN: /Ze \
285 // RUN: /Zg \
286 // RUN: /Zi \
287 // RUN: /ZI \
288 // RUN: /Zl \
289 // RUN: /ZW:nostdlib \
290 // RUN: -- %s 2>&1
291
292 // We support -Xclang for forwarding options to cc1.
293 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
294 // Xclang: "-cc1"
295 // Xclang: "hellocc1"
296
297 // RTTI is on by default. /GR- controls -fno-rtti-data.
298 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
299 // NoRTTI: "-fno-rtti-data"
300 // NoRTTI-NOT: "-fno-rtti"
301 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
302 // RTTI-NOT: "-fno-rtti-data"
303 // RTTI-NOT: "-fno-rtti"
304
305 // Accept "core" clang options.
306 // (/Zs is for syntax-only)
307 // RUN: %clang_cl \
308 // RUN: --driver-mode=cl \
309 // RUN: -ferror-limit=10 \
310 // RUN: -fmsc-version=1800 \
311 // RUN: -fno-strict-aliasing \
312 // RUN: -fstrict-aliasing \
313 // RUN: -mllvm -disable-llvm-optzns \
314 // RUN: -Wunused-variables \
315 // RUN: /Zs -- %s 2>&1
316
317
f()318 void f() { }
319