]> granicus.if.org Git - clang/blob - test/Driver/cl-options.c
clang-cl: Support the /fp options (PR23112)
[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 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
34 // fpexcept-NOT: -menable-unsafe-fp-math
35
36 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
37 // fpexcept_: -menable-unsafe-fp-math
38
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
42
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
46
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
50
51 // RTTI is on by default; just check that we don't error.
52 // RUN: %clang_cl /Zs /GR -- %s 2>&1
53
54 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
55 // GR_: -fno-rtti
56
57 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
58 // Gy: -ffunction-sections
59
60 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
61 // Gy_-NOT: -ffunction-sections
62
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"
69
70 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
71 // Gw: -fdata-sections
72
73 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
74 // Gw_-NOT: -fdata-sections
75
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"
79
80 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
81 // J: -fno-signed-char
82
83 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
84 // O: -Ofoo
85
86 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
87 // Ob0: -fno-inline
88
89 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
90 // Od: -O0
91
92 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
93 // Oi-NOT: -fno-builtin
94
95 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
96 // Oi_: -fno-builtin
97
98 // RUN: %clang_cl /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
99 // Os: -Os
100
101 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
102 // Ot: -O2
103
104 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
105 // Ox: -O3
106
107 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
108
109 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
110 // Oy_: -mdisable-fp-elim
111
112 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
113 // showIncludes: --show-includes
114
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'
118
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
121 // U: "-U" "mymacro"
122
123 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
124 // VD2: -vtordisp-mode=2
125
126 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
127 // VMG: "-fms-memptr-rep=virtual"
128
129 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
130 // VMS: "-fms-memptr-rep=single"
131
132 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
133 // VMM: "-fms-memptr-rep=multiple"
134
135 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
136 // VMV: "-fms-memptr-rep=virtual"
137
138 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
139 // VMB: '/vmg' not allowed with '/vmb'
140
141 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
142 // VMX: '/vms' not allowed with '/vmm'
143
144 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
145 // VOLATILE-ISO-NOT: "-fms-volatile"
146
147 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
148 // VOLATILE-MS: "-fms-volatile"
149
150 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
151 // W0: -w
152
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
158 // W1: -Wall
159
160 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
161 // WX: -Werror
162
163 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
164 // WX_: -Wno-error
165
166 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
167 // w: -w
168
169 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
170 // ZP: -fpack-struct=1
171
172 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
173 // ZP2: -fpack-struct=2
174
175 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
176 // Zs: -fsyntax-only
177
178 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
179 // FI: "-include" "asdf.h"
180
181 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
182 // FI_: "-include" "asdf.h"
183
184 // We forward any unrecognized -W diagnostic options to cc1.
185 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
186 // WJoined: "-cc1"
187 // WJoined: "-Wunused-pragmas"
188
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"
196
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
199 // Wno: "-cc1"
200 // Wno: "-Wno-macro-redefined"
201 // Wno: "-Wno-deprecated-declarations"
202
203 // Ignored options. Check that we don't get "unused during compilation" errors.
204 // RUN: %clang_cl /c \
205 // RUN:    /analyze- \
206 // RUN:    /cgthreads4 \
207 // RUN:    /cgthreads8 \
208 // RUN:    /d2Zi+ \
209 // RUN:    /errorReport:foo \
210 // RUN:    /Fdfoo \
211 // RUN:    /FS \
212 // RUN:    /Gd \
213 // RUN:    /GF \
214 // RUN:    /GS- \
215 // RUN:    /kernel- \
216 // RUN:    /nologo \
217 // RUN:    /Ob1 \
218 // RUN:    /Ob2 \
219 // RUN:    /openmp- \
220 // RUN:    /RTC1 \
221 // RUN:    /sdl \
222 // RUN:    /sdl- \
223 // RUN:    /vmg \
224 // RUN:    /volatile:iso \
225 // RUN:    /w12345 \
226 // RUN:    /wd1234 \
227 // RUN:    /Zo \
228 // RUN:    /Zo- \
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"
234
235 // Ignored options and compile-only options are ignored for link jobs.
236 // RUN: touch %t.obj
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
241
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
245
246 // Unsupported but parsed options. Check that we don't error on them.
247 // (/Zs is for syntax-only)
248 // RUN: %clang_cl /Zs \
249 // RUN:     /AIfoo \
250 // RUN:     /clr:pure \
251 // RUN:     /docname \
252 // RUN:     /EHsc \
253 // RUN:     /F \
254 // RUN:     /FA \
255 // RUN:     /FAc \
256 // RUN:     /Fafilename \
257 // RUN:     /FAs \
258 // RUN:     /FAu \
259 // RUN:     /favor:blend \
260 // RUN:     /FC \
261 // RUN:     /Fifoo \
262 // RUN:     /Fmfoo \
263 // RUN:     /FpDebug\main.pch \
264 // RUN:     /Frfoo \
265 // RUN:     /FRfoo \
266 // RUN:     /FU foo \
267 // RUN:     /Fx \
268 // RUN:     /G1 \
269 // RUN:     /G2 \
270 // RUN:     /GA \
271 // RUN:     /Gd \
272 // RUN:     /Ge \
273 // RUN:     /Gh \
274 // RUN:     /GH \
275 // RUN:     /GL \
276 // RUN:     /GL- \
277 // RUN:     /Gm \
278 // RUN:     /Gm- \
279 // RUN:     /Gr \
280 // RUN:     /GS \
281 // RUN:     /GT \
282 // RUN:     /GX \
283 // RUN:     /Gv \
284 // RUN:     /Gz \
285 // RUN:     /GZ \
286 // RUN:     /H \
287 // RUN:     /homeparams \
288 // RUN:     /hotpatch \
289 // RUN:     /kernel \
290 // RUN:     /LN \
291 // RUN:     /MP \
292 // RUN:     /o foo.obj \
293 // RUN:     /ofoo.obj \
294 // RUN:     /openmp \
295 // RUN:     /Qfast_transcendentals \
296 // RUN:     /QIfist \
297 // RUN:     /Qimprecise_fwaits \
298 // RUN:     /Qpar \
299 // RUN:     /Qvec-report:2 \
300 // RUN:     /u \
301 // RUN:     /V \
302 // RUN:     /volatile:ms \
303 // RUN:     /wfoo \
304 // RUN:     /WL \
305 // RUN:     /Wp64 \
306 // RUN:     /X \
307 // RUN:     /Y- \
308 // RUN:     /Yc \
309 // RUN:     /Ycstdafx.h \
310 // RUN:     /Yd \
311 // RUN:     /Yl- \
312 // RUN:     /Ylfoo \
313 // RUN:     /Yustdafx.h \
314 // RUN:     /Z7 \
315 // RUN:     /Za \
316 // RUN:     /Ze \
317 // RUN:     /Zg \
318 // RUN:     /Zi \
319 // RUN:     /ZI \
320 // RUN:     /Zl \
321 // RUN:     /ZW:nostdlib \
322 // RUN:     -- %s 2>&1
323
324 // We support -Xclang for forwarding options to cc1.
325 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
326 // Xclang: "-cc1"
327 // Xclang: "hellocc1"
328
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"
336
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"
341
342 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
343 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
344
345 // Accept "core" clang options.
346 // (/Zs is for syntax-only)
347 // RUN: %clang_cl \
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-variables \
355 // RUN:     /Zs -- %s 2>&1
356
357
358 void f() { }