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 /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
91 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
92 // U: "-U" "mymacro"
93
94 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
95 // VD2: -vtordisp-mode=2
96
97 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
98 // VMG: "-fms-memptr-rep=virtual"
99
100 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
101 // VMS: "-fms-memptr-rep=single"
102
103 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
104 // VMM: "-fms-memptr-rep=multiple"
105
106 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
107 // VMV: "-fms-memptr-rep=virtual"
108
109 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
110 // VMB: '/vmg' not allowed with '/vmb'
111
112 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
113 // VMX: '/vms' not allowed with '/vmm'
114
115 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
116 // W0: -w
117
118 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
119 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
120 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
121 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
122 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
123 // W1: -Wall
124
125 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
126 // WX: -Werror
127
128 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
129 // WX_: -Wno-error
130
131 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
132 // w: -w
133
134 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
135 // Zs: -fsyntax-only
136
137 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
138 // FI: "-include" "asdf.h"
139
140 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
141 // FI_: "-include" "asdf.h"
142
143 // We forward any unrecognized -W diagnostic options to cc1.
144 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
145 // WJoined: "-cc1"
146 // WJoined: "-Wunused-pragmas"
147
148 // We recognize -f[no-]strict-aliasing.
149 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
150 // DEFAULTSTRICT: "-relaxed-aliasing"
151 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
152 // STRICT-NOT: "-relaxed-aliasing"
153 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
154 // NOSTRICT: "-relaxed-aliasing"
155
156 // For some warning ids, we can map from MSVC warning to Clang warning.
157 // RUN: %clang_cl -wd4005 -### -- %s 2>&1 | FileCheck -check-prefix=wd4005 %s
158 // wd4005: "-cc1"
159 // wd4005: "-Wno-macro-redefined"
160
161 // Ignored options. Check that we don't get "unused during compilation" errors.
162 // (/Zs is for syntax-only)
163 // RUN: %clang_cl /Zs \
164 // RUN: /analyze- \
165 // RUN: /errorReport:foo \
166 // RUN: /FS \
167 // RUN: /GF \
168 // RUN: /GS- \
169 // RUN: /kernel- \
170 // RUN: /nologo \
171 // RUN: /Ob1 \
172 // RUN: /Ob2 \
173 // RUN: /RTC1 \
174 // RUN: /sdl \
175 // RUN: /sdl- \
176 // RUN: /vmg \
177 // RUN: /w12345 \
178 // RUN: /wd1234 \
179 // RUN: /Zc:forScope \
180 // RUN: /Zc:wchar_t \
181 // RUN: /Zc:inline \
182 // RUN: /Zc:rvalueCast \
183 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
184 // IGNORED-NOT: argument unused during compilation
185
186 // Ignored options and compile-only options are ignored for link jobs.
187 // RUN: touch %t.obj
188 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
189 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
190 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
191 // LINKUNUSED-NOT: argument unused during compilation
192
193 // Support ignoring warnings about unused arguments.
194 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
195 // UNUSED-NOT: argument unused during compilation
196
197 // Unsupported but parsed options. Check that we don't error on them.
198 // (/Zs is for syntax-only)
199 // RUN: %clang_cl /Zs \
200 // RUN: /AIfoo \
201 // RUN: /arch:sse2 \
202 // RUN: /clr:pure \
203 // RUN: /docname \
204 // RUN: /d2Zi+ \
205 // RUN: /EHsc \
206 // RUN: /F \
207 // RUN: /FA \
208 // RUN: /FAc \
209 // RUN: /Fafilename \
210 // RUN: /FAs \
211 // RUN: /FAu \
212 // RUN: /favor:blend \
213 // RUN: /FC \
214 // RUN: /Fdfoo \
215 // RUN: /Fifoo \
216 // RUN: /Fmfoo \
217 // RUN: /FpDebug\main.pch \
218 // RUN: /fp:precise \
219 // RUN: /Frfoo \
220 // RUN: /FRfoo \
221 // RUN: /FU foo \
222 // RUN: /Fx \
223 // RUN: /G1 \
224 // RUN: /G2 \
225 // RUN: /GA \
226 // RUN: /Gd \
227 // RUN: /Ge \
228 // RUN: /Gh \
229 // RUN: /GH \
230 // RUN: /GL \
231 // RUN: /GL- \
232 // RUN: /Gm \
233 // RUN: /Gm- \
234 // RUN: /Gr \
235 // RUN: /GS \
236 // RUN: /Gs1000 \
237 // RUN: /GT \
238 // RUN: /GX \
239 // RUN: /Gz \
240 // RUN: /GZ \
241 // RUN: /H \
242 // RUN: /homeparams \
243 // RUN: /hotpatch \
244 // RUN: /kernel \
245 // RUN: /LN \
246 // RUN: /MP \
247 // RUN: /o foo.obj \
248 // RUN: /ofoo.obj \
249 // RUN: /openmp \
250 // RUN: /Qfast_transcendentals \
251 // RUN: /QIfist \
252 // RUN: /Qimprecise_fwaits \
253 // RUN: /Qpar \
254 // RUN: /Qvec-report:2 \
255 // RUN: /u \
256 // RUN: /V \
257 // RUN: /volatile \
258 // RUN: /wfoo \
259 // RUN: /WL \
260 // RUN: /Wp64 \
261 // RUN: /X \
262 // RUN: /Y- \
263 // RUN: /Yc \
264 // RUN: /Ycstdafx.h \
265 // RUN: /Yd \
266 // RUN: /Yl- \
267 // RUN: /Ylfoo \
268 // RUN: /Yustdafx.h \
269 // RUN: /Z7 \
270 // RUN: /Za \
271 // RUN: /Zc:auto \
272 // RUN: /Zc:wchar_t- \
273 // RUN: /Ze \
274 // RUN: /Zg \
275 // RUN: /Zi \
276 // RUN: /ZI \
277 // RUN: /Zl \
278 // RUN: /Zp \
279 // RUN: /Zp1 \
280 // RUN: /ZW:nostdlib \
281 // RUN: -- %s 2>&1
282
283 // We support -Xclang for forwarding options to cc1.
284 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
285 // Xclang: "-cc1"
286 // Xclang: "hellocc1"
287
288 // We support -m32 and -m64.
289 // RUN: %clang_cl /Zs /WX -m32 -m64 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s
290 // MFLAGS-NOT: argument unused during compilation
291
292 // RTTI is on by default. /GR- controls -fno-rtti-data.
293 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
294 // NoRTTI: "-fno-rtti-data"
295 // NoRTTI-NOT: "-fno-rtti"
296 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
297 // RTTI-NOT: "-fno-rtti-data"
298 // RTTI-NOT: "-fno-rtti"
299
300
f()301 void f() { }
302