]> granicus.if.org Git - clang/blob - test/Driver/cl-options.c
clang-cl: Correctly ignore /openmp- (PR22748)
[clang] / test / Driver / cl-options.c
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 /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"
51
52 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
53 // Gw: -fdata-sections
54
55 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
56 // Gw_-NOT: -fdata-sections
57
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"
61
62 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
63 // J: -fno-signed-char
64
65 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
66 // O: -Ofoo
67
68 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
69 // Ob0: -fno-inline
70
71 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
72 // Od: -O0
73
74 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
75 // Oi-NOT: -fno-builtin
76
77 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
78 // Oi_: -fno-builtin
79
80 // RUN: %clang_cl /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
81 // Os: -Os
82
83 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
84 // Ot: -O2
85
86 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
87 // Ox: -O3
88
89 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
90
91 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
92 // Oy_: -mdisable-fp-elim
93
94 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
95 // showIncludes: --show-includes
96
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'
100
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
103 // U: "-U" "mymacro"
104
105 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
106 // VD2: -vtordisp-mode=2
107
108 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
109 // VMG: "-fms-memptr-rep=virtual"
110
111 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
112 // VMS: "-fms-memptr-rep=single"
113
114 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
115 // VMM: "-fms-memptr-rep=multiple"
116
117 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
118 // VMV: "-fms-memptr-rep=virtual"
119
120 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
121 // VMB: '/vmg' not allowed with '/vmb'
122
123 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
124 // VMX: '/vms' not allowed with '/vmm'
125
126 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
127 // VOLATILE-ISO-NOT: "-fms-volatile"
128
129 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
130 // VOLATILE-MS: "-fms-volatile"
131
132 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
133 // W0: -w
134
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
140 // W1: -Wall
141
142 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
143 // WX: -Werror
144
145 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
146 // WX_: -Wno-error
147
148 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
149 // w: -w
150
151 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
152 // ZP: -fpack-struct=1
153
154 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
155 // ZP2: -fpack-struct=2
156
157 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
158 // Zs: -fsyntax-only
159
160 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
161 // FI: "-include" "asdf.h"
162
163 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
164 // FI_: "-include" "asdf.h"
165
166 // We forward any unrecognized -W diagnostic options to cc1.
167 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
168 // WJoined: "-cc1"
169 // WJoined: "-Wunused-pragmas"
170
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"
178
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
181 // Wno: "-cc1"
182 // Wno: "-Wno-macro-redefined"
183 // Wno: "-Wno-deprecated-declarations"
184
185 // Ignored options. Check that we don't get "unused during compilation" errors.
186 // RUN: %clang_cl /c \
187 // RUN:    /analyze- \
188 // RUN:    /cgthreads4 \
189 // RUN:    /cgthreads8 \
190 // RUN:    /d2Zi+ \
191 // RUN:    /errorReport:foo \
192 // RUN:    /Fdfoo \
193 // RUN:    /FS \
194 // RUN:    /Gd \
195 // RUN:    /GF \
196 // RUN:    /GS- \
197 // RUN:    /kernel- \
198 // RUN:    /nologo \
199 // RUN:    /Ob1 \
200 // RUN:    /Ob2 \
201 // RUN:    /openmp- \
202 // RUN:    /RTC1 \
203 // RUN:    /sdl \
204 // RUN:    /sdl- \
205 // RUN:    /vmg \
206 // RUN:    /volatile:iso \
207 // RUN:    /w12345 \
208 // RUN:    /wd1234 \
209 // RUN:    /Zo \
210 // RUN:    /Zo- \
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"
216
217 // Ignored options and compile-only options are ignored for link jobs.
218 // RUN: touch %t.obj
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
223
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
227
228 // Unsupported but parsed options. Check that we don't error on them.
229 // (/Zs is for syntax-only)
230 // RUN: %clang_cl /Zs \
231 // RUN:     /AIfoo \
232 // RUN:     /clr:pure \
233 // RUN:     /docname \
234 // RUN:     /EHsc \
235 // RUN:     /F \
236 // RUN:     /FA \
237 // RUN:     /FAc \
238 // RUN:     /Fafilename \
239 // RUN:     /FAs \
240 // RUN:     /FAu \
241 // RUN:     /favor:blend \
242 // RUN:     /FC \
243 // RUN:     /Fifoo \
244 // RUN:     /Fmfoo \
245 // RUN:     /FpDebug\main.pch \
246 // RUN:     /fp:precise \
247 // RUN:     /Frfoo \
248 // RUN:     /FRfoo \
249 // RUN:     /FU foo \
250 // RUN:     /Fx \
251 // RUN:     /G1 \
252 // RUN:     /G2 \
253 // RUN:     /GA \
254 // RUN:     /Gd \
255 // RUN:     /Ge \
256 // RUN:     /Gh \
257 // RUN:     /GH \
258 // RUN:     /GL \
259 // RUN:     /GL- \
260 // RUN:     /Gm \
261 // RUN:     /Gm- \
262 // RUN:     /Gr \
263 // RUN:     /GS \
264 // RUN:     /GT \
265 // RUN:     /GX \
266 // RUN:     /Gv \
267 // RUN:     /Gz \
268 // RUN:     /GZ \
269 // RUN:     /H \
270 // RUN:     /homeparams \
271 // RUN:     /hotpatch \
272 // RUN:     /kernel \
273 // RUN:     /LN \
274 // RUN:     /MP \
275 // RUN:     /o foo.obj \
276 // RUN:     /ofoo.obj \
277 // RUN:     /openmp \
278 // RUN:     /Qfast_transcendentals \
279 // RUN:     /QIfist \
280 // RUN:     /Qimprecise_fwaits \
281 // RUN:     /Qpar \
282 // RUN:     /Qvec-report:2 \
283 // RUN:     /u \
284 // RUN:     /V \
285 // RUN:     /volatile:ms \
286 // RUN:     /wfoo \
287 // RUN:     /WL \
288 // RUN:     /Wp64 \
289 // RUN:     /X \
290 // RUN:     /Y- \
291 // RUN:     /Yc \
292 // RUN:     /Ycstdafx.h \
293 // RUN:     /Yd \
294 // RUN:     /Yl- \
295 // RUN:     /Ylfoo \
296 // RUN:     /Yustdafx.h \
297 // RUN:     /Z7 \
298 // RUN:     /Za \
299 // RUN:     /Ze \
300 // RUN:     /Zg \
301 // RUN:     /Zi \
302 // RUN:     /ZI \
303 // RUN:     /Zl \
304 // RUN:     /ZW:nostdlib \
305 // RUN:     -- %s 2>&1
306
307 // We support -Xclang for forwarding options to cc1.
308 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
309 // Xclang: "-cc1"
310 // Xclang: "hellocc1"
311
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"
319
320 // Accept "core" clang options.
321 // (/Zs is for syntax-only)
322 // RUN: %clang_cl \
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
331
332
333 void f() { }