]> granicus.if.org Git - clang/blob - test/Driver/cl-options.c
clang-cl: use -fno-rtti by default
[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 /Dfoo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
14 // RUN: %clang_cl /D foo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D %s
15 // D: "-D" "foo=bar"
16
17 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
18 // E: "-E"
19 // E: "-o" "-"
20
21 // RTTI is on by default; just check that we don't error.
22 // RUN: %clang_cl /Zs /GR -- %s 2>&1
23
24 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
25 // GR_: -fno-rtti
26
27 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
28 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
29 // SLASH_I: "-I" "myincludedir"
30
31 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
32 // J: -fno-signed-char
33
34 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
35 // O: -Ofoo
36
37 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
38 // Ob0: -fno-inline
39
40 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
41 // Od: -O0
42
43 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
44 // Oi-NOT: -fno-builtin
45
46 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
47 // Oi_: -fno-builtin
48
49 // RUN: %clang_cl /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
50 // Os: -Os
51
52 // RUN: %clang_cl /Ot -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
53 // Ot: -O2
54
55 // RUN: %clang_cl /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
56 // Ox: -O3
57
58 // RUN: %clang_cl /Zs /Oy -- %s 2>&1
59
60 // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
61 // Oy_: -mdisable-fp-elim
62
63 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
64 // showIncludes: --show-includes
65
66 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
67 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
68 // U: "-U" "mymacro"
69
70 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
71 // VMG: "-fms-memptr-rep=virtual"
72
73 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
74 // VMS: "-fms-memptr-rep=single"
75
76 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
77 // VMM: "-fms-memptr-rep=multiple"
78
79 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
80 // VMV: "-fms-memptr-rep=virtual"
81
82 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
83 // VMB: '/vmg' not allowed with '/vmb'
84
85 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
86 // VMX: '/vms' not allowed with '/vmm'
87
88 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
89 // W0: -w
90
91 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
92 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
93 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
94 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
95 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
96 // W1: -Wall
97
98 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
99 // WX: -Werror
100
101 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
102 // WX_: -Wno-error
103
104 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
105 // w: -w
106
107 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
108 // Zs: -fsyntax-only
109
110 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
111 // FI: "-include" "asdf.h"
112
113 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
114 // FI_: "-include" "asdf.h"
115
116 // We forward any unrecognized -W diagnostic options to cc1.
117 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
118 // WJoined: "-cc1"
119 // WJoined: "-Wunused-pragmas"
120
121
122 // Ignored options. Check that we don't get "unused during compilation" errors.
123 // (/Zs is for syntax-only, /WX is for -Werror)
124 // RUN: %clang_cl /Zs /WX \
125 // RUN:    /analyze- \
126 // RUN:    /errorReport:foo \
127 // RUN:    /FS \
128 // RUN:    /GF \
129 // RUN:    /GS- \
130 // RUN:    /kernel- \
131 // RUN:    /nologo \
132 // RUN:    /Ob1 \
133 // RUN:    /Ob2 \
134 // RUN:    /RTC1 \
135 // RUN:    /sdl \
136 // RUN:    /sdl- \
137 // RUN:    /vmg \
138 // RUN:    /w12345 \
139 // RUN:    /wd1234 \
140 // RUN:    /Zc:forScope \
141 // RUN:    /Zc:wchar_t \
142 // RUN:    -- %s
143
144 // Ignored options and compile-only options are ignored for link jobs.
145 // RUN: touch %t.obj
146 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
147 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
148 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
149 // LINKUNUSED-NOT: argument unused during compilation
150
151 // Support ignoring warnings about unused arguments.
152 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
153 // UNUSED-NOT: warning
154
155 // Unsupported but parsed options. Check that we don't error on them.
156 // (/Zs is for syntax-only)
157 // RUN: %clang_cl /Zs \
158 // RUN:     /AIfoo \
159 // RUN:     /arch:sse2 \
160 // RUN:     /clr:pure \
161 // RUN:     /docname \
162 // RUN:     /d2Zi+ \
163 // RUN:     /EHsc \
164 // RUN:     /EP \
165 // RUN:     /F \
166 // RUN:     /FA \
167 // RUN:     /FAc \
168 // RUN:     /Fafilename \
169 // RUN:     /FAs \
170 // RUN:     /FAu \
171 // RUN:     /favor:blend \
172 // RUN:     /FC \
173 // RUN:     /Fdfoo \
174 // RUN:     /Fifoo \
175 // RUN:     /Fmfoo \
176 // RUN:     /FpDebug\main.pch \
177 // RUN:     /fp:precise \
178 // RUN:     /Frfoo \
179 // RUN:     /FRfoo \
180 // RUN:     /FU foo \
181 // RUN:     /Fx \
182 // RUN:     /G1 \
183 // RUN:     /G2 \
184 // RUN:     /GA \
185 // RUN:     /Gd \
186 // RUN:     /Ge \
187 // RUN:     /Gh \
188 // RUN:     /GH \
189 // RUN:     /GL \
190 // RUN:     /GL- \
191 // RUN:     /Gm \
192 // RUN:     /Gm- \
193 // RUN:     /Gr \
194 // RUN:     /GS \
195 // RUN:     /Gs1000 \
196 // RUN:     /GT \
197 // RUN:     /GX \
198 // RUN:     /Gy \
199 // RUN:     /Gy- \
200 // RUN:     /Gz \
201 // RUN:     /GZ \
202 // RUN:     /H \
203 // RUN:     /homeparams \
204 // RUN:     /hotpatch \
205 // RUN:     /kernel \
206 // RUN:     /LN \
207 // RUN:     /MP \
208 // RUN:     /o foo.obj \
209 // RUN:     /ofoo.obj \
210 // RUN:     /openmp \
211 // RUN:     /Qfast_transcendentals \
212 // RUN:     /QIfist \
213 // RUN:     /Qimprecise_fwaits \
214 // RUN:     /Qpar \
215 // RUN:     /Qvec-report:2 \
216 // RUN:     /u \
217 // RUN:     /V \
218 // RUN:     /vd2 \
219 // RUN:     /volatile \
220 // RUN:     /wfoo \
221 // RUN:     /WL \
222 // RUN:     /Wp64 \
223 // RUN:     /X \
224 // RUN:     /Y- \
225 // RUN:     /Yc \
226 // RUN:     /Ycstdafx.h \
227 // RUN:     /Yd \
228 // RUN:     /Yl- \
229 // RUN:     /Ylfoo \
230 // RUN:     /Yustdafx.h \
231 // RUN:     /Z7 \
232 // RUN:     /Za \
233 // RUN:     /Zc:auto \
234 // RUN:     /Zc:wchar_t- \
235 // RUN:     /Ze \
236 // RUN:     /Zg \
237 // RUN:     /Zi \
238 // RUN:     /ZI \
239 // RUN:     /Zl \
240 // RUN:     /Zp \
241 // RUN:     /Zp1 \
242 // RUN:     /ZW:nostdlib \
243 // RUN:     -- %s 2>&1
244
245 // We support -Xclang for forwarding options to cc1.
246 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
247 // Xclang: "-cc1"
248 // Xclang: "hellocc1"
249
250 // We support -m32 and -m64.
251 // RUN: %clang_cl /Zs /WX -m32 -m64 -- %s
252
253 // Use -fno-rtti by default.
254 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
255 // NoRTTI: "-fno-rtti"
256 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
257 // RTTI-NOT: "-fno-rtti"
258
259
260 void f() { }