blob: 52b40c716daed1eafb5f8ae1ee190f4ae3affe60 [file] [log] [blame]
Hans Wennborg96d54842013-08-02 22:24:50 +00001// Note: %s must be preceded by --, otherwise it may be interpreted as a
2// command-line option, e.g. on Mac where %s is commonly under /Users.
Hans Wennborg19076102013-07-31 20:51:53 +00003
Hans Wennborg96d54842013-08-02 22:24:50 +00004
5// Alias options:
6
Hans Wennborg8f008372014-06-11 19:44:53 +00007// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
8// c: -c
9
10// RUN: %clang_cl /C -### -- %s 2>&1 | FileCheck -check-prefix=C %s
11// C: error: invalid argument '-C' only allowed with '/E, /P or /EP'
12
13// RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
14// C_P: "-E"
15// C_P: "-C"
Hans Wennborg96d54842013-08-02 22:24:50 +000016
Hans Wennborg94d6a712016-01-12 23:31:58 +000017// RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \
Hans Wennborg21d73d22016-01-12 23:17:03 +000018// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=D %s
Hans Wennborg96d54842013-08-02 22:24:50 +000019// D: "-D" "foo=bar"
Hans Wennborg21d73d22016-01-12 23:17:03 +000020// D: "-D" "bar=baz"
21// D: "-D" "MYDEF=value"
22// D: "-D" "MYDEF2=foo#bar"
23// D: "-D" "MYDEF3=a=b"
Hans Wennborg94d6a712016-01-12 23:31:58 +000024// D: "-D" "MYDEF4="
Hans Wennborg96d54842013-08-02 22:24:50 +000025
Hans Wennborge0053472013-12-20 18:40:46 +000026// RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
27// E: "-E"
28// E: "-o" "-"
29
Hans Wennborge50cec32014-06-13 20:59:54 +000030// RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
31// EP: "-E"
32// EP: "-P"
33// EP: "-o" "-"
34
Hans Wennborg7a2e5c22015-04-08 22:55:09 +000035// RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
36// fpexcept-NOT: -menable-unsafe-fp-math
37
38// RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
39// fpexcept_: -menable-unsafe-fp-math
40
41// RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
42// fpfast: -menable-unsafe-fp-math
43// fpfast: -ffast-math
44
45// RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
46// fpprecise-NOT: -menable-unsafe-fp-math
47// fpprecise-NOT: -ffast-math
48
49// RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
50// fpstrict-NOT: -menable-unsafe-fp-math
51// fpstrict-NOT: -ffast-math
52
Adrian McCarthy084148f2016-08-25 18:24:35 +000053// RUN: %clang_cl /Z7 -gcolumn-info -### -- %s 2>&1 | FileCheck -check-prefix=gcolumn %s
54// gcolumn: -dwarf-column-info
55
56// RUN: %clang_cl /Z7 -gno-column-info -### -- %s 2>&1 | FileCheck -check-prefix=gnocolumn %s
57// gnocolumn-NOT: -dwarf-column-info
58
59// RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
60// gdefcolumn-NOT: -dwarf-column-info
61
David Majnemere95f3bd2015-05-20 04:39:56 +000062// RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
63// GA: -ftls-model=local-exec
64
Hans Wennborg96d54842013-08-02 22:24:50 +000065// RTTI is on by default; just check that we don't error.
66// RUN: %clang_cl /Zs /GR -- %s 2>&1
67
68// RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
69// GR_: -fno-rtti
70
Etienne Bergerone28e7f22016-06-15 20:34:33 +000071// Security Buffer Check is on by default.
72// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
73// GS-default: "-stack-protector" "2"
74
75// RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
76// GS: "-stack-protector" "2"
77
78// RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
79// GS_-NOT: -stack-protector
80
David Majnemerda39ab22014-03-23 17:47:22 +000081// RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
82// Gy: -ffunction-sections
83
84// RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
85// Gy_-NOT: -ffunction-sections
86
Hans Wennborg77dc2362015-01-20 19:45:50 +000087// RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
88// Gs: "-mstack-probe-size=0"
89// RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
90// Gs0: "-mstack-probe-size=0"
91// RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
92// Gs4096: "-mstack-probe-size=4096"
93
David Majnemerdc7a47c2014-04-07 16:14:38 +000094// RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
95// Gw: -fdata-sections
96
97// RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
98// Gw_-NOT: -fdata-sections
99
Reid Kleckneraf1acd92013-09-26 17:41:14 +0000100// RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
101// RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
102// SLASH_I: "-I" "myincludedir"
Hans Wennborg96d54842013-08-02 22:24:50 +0000103
Nico Weberfd3e1ad2016-04-12 19:04:37 +0000104// RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
105// RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
106// Clang's resource header directory should be first:
Ismail Donmezf677cd52016-04-14 15:32:24 +0000107// SLASH_imsvc: "-internal-isystem" "{{[^"]*}}lib{{(64)?/|\\\\}}clang{{[^"]*}}include"
Nico Weberfd3e1ad2016-04-12 19:04:37 +0000108// SLASH_imsvc: "-internal-isystem" "myincludedir"
109
Hans Wennborg96d54842013-08-02 22:24:50 +0000110// RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
111// J: -fno-signed-char
112
113// RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
David Majnemer015ce0f2015-07-27 07:32:11 +0000114// O: /Ofoo
Hans Wennborg96d54842013-08-02 22:24:50 +0000115
116// RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
117// Ob0: -fno-inline
118
Hans Wennborg7a008882016-05-24 20:40:51 +0000119// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
Hans Wennborg3270bdb2016-05-24 21:23:29 +0000120// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
Hans Wennborgdebfed92016-05-25 00:43:45 +0000121// RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
122// Ob2-NOT: warning: argument unused during compilation: '/O2'
Hans Wennborg7a008882016-05-24 20:40:51 +0000123// Ob2: -finline-functions
124
Hans Wennborg44d061a2016-06-22 16:56:16 +0000125// RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
126// RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
127// Ob1: -finline-hint-functions
128
Hans Wennborg96d54842013-08-02 22:24:50 +0000129// RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
130// Od: -O0
131
Hans Wennborg56eb4b62013-08-08 23:44:01 +0000132// RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
133// Oi-NOT: -fno-builtin
134
135// RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
136// Oi_: -fno-builtin
137
Saleem Abdulrasool5860fe12015-10-03 07:15:28 +0000138// RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
139// RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
David Majnemer015ce0f2015-07-27 07:32:11 +0000140// Os-NOT: -mdisable-fp-elim
141// Os: -momit-leaf-frame-pointer
Hans Wennborg96d54842013-08-02 22:24:50 +0000142// Os: -Os
143
Saleem Abdulrasool5860fe12015-10-03 07:15:28 +0000144// RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
145// RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
David Majnemer015ce0f2015-07-27 07:32:11 +0000146// Ot-NOT: -mdisable-fp-elim
147// Ot: -momit-leaf-frame-pointer
Hans Wennborg96d54842013-08-02 22:24:50 +0000148// Ot: -O2
149
Saleem Abdulrasool5860fe12015-10-03 07:15:28 +0000150// RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
151// RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
David Majnemer015ce0f2015-07-27 07:32:11 +0000152// Ox-NOT: -mdisable-fp-elim
153// Ox: -momit-leaf-frame-pointer
154// Ox: -O2
155
David Majnemer7ab76f22015-08-25 00:46:45 +0000156// RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
David Majnemer015ce0f2015-07-27 07:32:11 +0000157// PR24003: -mdisable-fp-elim
158// PR24003: -momit-leaf-frame-pointer
159// PR24003: -Os
Hans Wennborg96d54842013-08-02 22:24:50 +0000160
Nico Weber9c3fca32016-03-23 15:37:41 +0000161// RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
David Majnemer259d71a2016-01-21 23:01:11 +0000162// Oy_2: -momit-leaf-frame-pointer
163// Oy_2: -O2
164
Nico Weber9c3fca32016-03-23 15:37:41 +0000165// RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1
Hans Wennborg96d54842013-08-02 22:24:50 +0000166
Nico Weber9c3fca32016-03-23 15:37:41 +0000167// RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
Hans Wennborg96d54842013-08-02 22:24:50 +0000168// Oy_: -mdisable-fp-elim
169
David Majnemer87b853c2015-05-14 05:19:17 +0000170// RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
171// Qvec: -vectorize-loops
172
173// RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
174// Qvec_-NOT: -vectorize-loops
175
Hans Wennborg0fd62072013-08-09 00:32:23 +0000176// RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
177// showIncludes: --show-includes
178
Hans Wennborg8858a032014-07-21 23:42:07 +0000179// RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
180// RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
181// showIncludes_E: warning: argument unused during compilation: '--show-includes'
182
Nico Weber97f446c2016-08-23 16:47:09 +0000183// /source-charset: should warn on everything except UTF-8.
184// RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
185// source-charset-utf-16: invalid value 'utf-16'
186
Nico Weberebe8d622016-08-26 21:11:43 +0000187// /execution-charset: should warn on everything except UTF-8.
188// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
189// execution-charset-utf-16: invalid value 'utf-16'
190//
Hans Wennborg96d54842013-08-02 22:24:50 +0000191// RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
192// RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
193// U: "-U" "mymacro"
194
David Majnemerca116412014-03-23 17:47:18 +0000195// RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
196// VD2: -vtordisp-mode=2
197
David Majnemer86c318f2014-02-11 21:05:00 +0000198// RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
199// VMG: "-fms-memptr-rep=virtual"
200
201// RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
202// VMS: "-fms-memptr-rep=single"
203
204// RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
205// VMM: "-fms-memptr-rep=multiple"
206
207// RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
208// VMV: "-fms-memptr-rep=virtual"
209
210// RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
211// VMB: '/vmg' not allowed with '/vmb'
212
213// RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
214// VMX: '/vms' not allowed with '/vmm'
215
David Majnemera5b195a2015-02-14 01:35:12 +0000216// RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
217// VOLATILE-ISO-NOT: "-fms-volatile"
218
219// RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
220// VOLATILE-MS: "-fms-volatile"
221
Hans Wennborg96d54842013-08-02 22:24:50 +0000222// RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
223// W0: -w
224
225// RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
226// RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
227// RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
Nico Weberc8036742015-12-11 22:31:16 +0000228// RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
Hans Wennborg4ae76c22015-12-14 18:46:11 +0000229// RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
Hans Wennborg96d54842013-08-02 22:24:50 +0000230// W1: -Wall
Nico Weberc8036742015-12-11 22:31:16 +0000231// W4: -WCL4
Hans Wennborg96d54842013-08-02 22:24:50 +0000232
233// RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
234// WX: -Werror
235
236// RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
237// WX_: -Wno-error
238
239// RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
240// w: -w
241
David Majnemer104fb542014-07-25 17:30:10 +0000242// RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
243// ZP: -fpack-struct=1
244
245// RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
246// ZP2: -fpack-struct=2
247
Hans Wennborg96d54842013-08-02 22:24:50 +0000248// RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
249// Zs: -fsyntax-only
250
Reid Kleckneraf1acd92013-09-26 17:41:14 +0000251// RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
252// FI: "-include" "asdf.h"
253
Rafael Espindola8c871122013-10-29 19:42:01 +0000254// RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
255// FI_: "-include" "asdf.h"
256
David Majnemercd5855e2016-02-29 01:40:36 +0000257// RUN: %clang_cl /TP /c -### -- %s 2>&1 | FileCheck -check-prefix=NO-GX %s
David Majnemera7bdc5a2016-02-22 17:44:51 +0000258// NO-GX-NOT: "-fcxx-exceptions" "-fexceptions"
259
David Majnemercd5855e2016-02-29 01:40:36 +0000260// RUN: %clang_cl /TP /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
David Majnemerb8809092016-02-20 09:23:44 +0000261// GX: "-fcxx-exceptions" "-fexceptions"
262
David Majnemercd5855e2016-02-29 01:40:36 +0000263// RUN: %clang_cl /TP /c /GX /GX- -### -- %s 2>&1 | FileCheck -check-prefix=GX_ %s
David Majnemerb8809092016-02-20 09:23:44 +0000264// GX_-NOT: "-fcxx-exceptions" "-fexceptions"
265
Reid Klecknerf3ad7202013-09-03 23:18:43 +0000266// We forward any unrecognized -W diagnostic options to cc1.
267// RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
268// WJoined: "-cc1"
269// WJoined: "-Wunused-pragmas"
Hans Wennborg96d54842013-08-02 22:24:50 +0000270
Reid Kleckner2a24e3a2014-04-09 20:07:39 +0000271// We recognize -f[no-]strict-aliasing.
272// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
273// DEFAULTSTRICT: "-relaxed-aliasing"
274// RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
275// STRICT-NOT: "-relaxed-aliasing"
276// RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
277// NOSTRICT: "-relaxed-aliasing"
278
Reid Kleckner9307fba2014-04-04 01:36:55 +0000279// For some warning ids, we can map from MSVC warning to Clang warning.
Nico Weber0d10b2c2015-12-15 17:07:16 +0000280// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
Reid Kleckner469b6bc2015-02-17 23:28:19 +0000281// Wno: "-cc1"
282// Wno: "-Wno-macro-redefined"
Nico Weber0d10b2c2015-12-15 17:07:16 +0000283// Wno: "-Wno-unused-parameter"
Hans Wennborg89e39a72015-06-11 18:14:11 +0000284// Wno: "-Wno-dllexport-explicit-instantiation-decl"
Nico Weber0d10b2c2015-12-15 17:07:16 +0000285// Wno: "-Wno-deprecated-declarations"
Hans Wennborga8ef14f2013-09-17 00:03:41 +0000286
Hans Wennborg96d54842013-08-02 22:24:50 +0000287// Ignored options. Check that we don't get "unused during compilation" errors.
Hans Wennborge2155942015-03-02 22:09:05 +0000288// RUN: %clang_cl /c \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000289// RUN: /analyze- \
Nico Weber4cc796a2015-09-18 20:49:33 +0000290// RUN: /bigobj \
Hans Wennborga41faed2014-12-13 22:24:16 +0000291// RUN: /cgthreads4 \
292// RUN: /cgthreads8 \
Nico Weber4884dcf2016-03-29 19:41:02 +0000293// RUN: /d2FastFail \
Hans Wennborg05d50a92014-11-14 18:24:08 +0000294// RUN: /d2Zi+ \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000295// RUN: /errorReport:foo \
Nico Weberebe8d622016-08-26 21:11:43 +0000296// RUN: /execution-charset:utf-8 \
Nico Weber32b70e02016-03-21 17:19:31 +0000297// RUN: /FC \
Reid Klecknerc00927c2015-02-25 19:17:50 +0000298// RUN: /Fdfoo \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000299// RUN: /FS \
Hans Wennborg951f1cc2014-12-13 22:13:23 +0000300// RUN: /Gd \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000301// RUN: /GF \
302// RUN: /GS- \
303// RUN: /kernel- \
304// RUN: /nologo \
Hans Wennborge2155942015-03-02 22:09:05 +0000305// RUN: /openmp- \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000306// RUN: /RTC1 \
307// RUN: /sdl \
308// RUN: /sdl- \
Nico Weber97f446c2016-08-23 16:47:09 +0000309// RUN: /source-charset:utf-8 \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000310// RUN: /vmg \
Hans Wennborg1fda2162014-12-13 22:44:46 +0000311// RUN: /volatile:iso \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000312// RUN: /w12345 \
313// RUN: /wd1234 \
Hans Wennborg05d50a92014-11-14 18:24:08 +0000314// RUN: /Zo \
315// RUN: /Zo- \
Hans Wennborg5e91ef62014-03-28 20:45:05 +0000316// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
317// IGNORED-NOT: argument unused during compilation
Hans Wennborg05d50a92014-11-14 18:24:08 +0000318// IGNORED-NOT: no such file or directory
Hans Wennborge2155942015-03-02 22:09:05 +0000319// Don't confuse /openmp- with the /o flag:
320// IGNORED-NOT: "-o" "penmp-.obj"
Hans Wennborg96d54842013-08-02 22:24:50 +0000321
Hans Wennborga8ef14f2013-09-17 00:03:41 +0000322// Ignored options and compile-only options are ignored for link jobs.
Hans Wennborg1f849802013-09-17 00:50:43 +0000323// RUN: touch %t.obj
Hans Wennborga8ef14f2013-09-17 00:03:41 +0000324// RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
325// RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
326// RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
327// LINKUNUSED-NOT: argument unused during compilation
328
Chandler Carruth576a3692013-09-05 10:09:03 +0000329// Support ignoring warnings about unused arguments.
330// RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
Hans Wennborg5e91ef62014-03-28 20:45:05 +0000331// UNUSED-NOT: argument unused during compilation
Chandler Carruth576a3692013-09-05 10:09:03 +0000332
Hans Wennborg96d54842013-08-02 22:24:50 +0000333// Unsupported but parsed options. Check that we don't error on them.
334// (/Zs is for syntax-only)
Hans Wennborg444c37d2013-11-15 18:29:58 +0000335// RUN: %clang_cl /Zs \
336// RUN: /AIfoo \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000337// RUN: /clr:pure \
338// RUN: /docname \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000339// RUN: /EHsc \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000340// RUN: /F \
341// RUN: /FA \
342// RUN: /FAc \
343// RUN: /Fafilename \
344// RUN: /FAs \
345// RUN: /FAu \
346// RUN: /favor:blend \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000347// RUN: /Fifoo \
348// RUN: /Fmfoo \
349// RUN: /FpDebug\main.pch \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000350// RUN: /Frfoo \
351// RUN: /FRfoo \
352// RUN: /FU foo \
353// RUN: /Fx \
354// RUN: /G1 \
355// RUN: /G2 \
356// RUN: /GA \
357// RUN: /Gd \
358// RUN: /Ge \
359// RUN: /Gh \
360// RUN: /GH \
361// RUN: /GL \
362// RUN: /GL- \
363// RUN: /Gm \
364// RUN: /Gm- \
365// RUN: /Gr \
366// RUN: /GS \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000367// RUN: /GT \
Hans Wennborgd6e069f2015-11-04 16:11:56 +0000368// RUN: /guard:cf \
369// RUN: /guard:cf- \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000370// RUN: /GX \
Hans Wennborg92391ce2014-12-13 22:06:23 +0000371// RUN: /Gv \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000372// RUN: /Gz \
373// RUN: /GZ \
374// RUN: /H \
375// RUN: /homeparams \
376// RUN: /hotpatch \
377// RUN: /kernel \
378// RUN: /LN \
379// RUN: /MP \
380// RUN: /o foo.obj \
381// RUN: /ofoo.obj \
382// RUN: /openmp \
383// RUN: /Qfast_transcendentals \
384// RUN: /QIfist \
385// RUN: /Qimprecise_fwaits \
386// RUN: /Qpar \
387// RUN: /Qvec-report:2 \
388// RUN: /u \
389// RUN: /V \
Hans Wennborg1fda2162014-12-13 22:44:46 +0000390// RUN: /volatile:ms \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000391// RUN: /wfoo \
392// RUN: /WL \
393// RUN: /Wp64 \
394// RUN: /X \
395// RUN: /Y- \
396// RUN: /Yc \
397// RUN: /Ycstdafx.h \
398// RUN: /Yd \
399// RUN: /Yl- \
400// RUN: /Ylfoo \
401// RUN: /Yustdafx.h \
402// RUN: /Z7 \
403// RUN: /Za \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000404// RUN: /Ze \
405// RUN: /Zg \
406// RUN: /Zi \
407// RUN: /ZI \
408// RUN: /Zl \
Hans Wennborg444c37d2013-11-15 18:29:58 +0000409// RUN: /ZW:nostdlib \
410// RUN: -- %s 2>&1
Hans Wennborgc0fbccc2013-08-19 18:32:59 +0000411
412// We support -Xclang for forwarding options to cc1.
413// RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
414// Xclang: "-cc1"
415// Xclang: "hellocc1"
Hans Wennborga8ef14f2013-09-17 00:03:41 +0000416
David Majnemerf6072342014-07-01 22:24:56 +0000417// RTTI is on by default. /GR- controls -fno-rtti-data.
418// RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
419// NoRTTI: "-fno-rtti-data"
420// NoRTTI-NOT: "-fno-rtti"
Hans Wennborg7b0dcef2014-02-25 18:36:22 +0000421// RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
David Majnemerf6072342014-07-01 22:24:56 +0000422// RTTI-NOT: "-fno-rtti-data"
Hans Wennborg7b0dcef2014-02-25 18:36:22 +0000423// RTTI-NOT: "-fno-rtti"
424
David Majnemerc371ff02015-03-22 08:39:22 +0000425// thread safe statics are off for versions < 19.
Adrian McCarthye4b26fc2016-05-13 23:20:11 +0000426// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
David Majnemerc371ff02015-03-22 08:39:22 +0000427// RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
428// NoThreadSafeStatics: "-fno-threadsafe-statics"
429
430// RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
431// ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
432
Reid Kleckner124955a2015-08-05 18:51:13 +0000433// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
Reid Kleckner124955a2015-08-05 18:51:13 +0000434// Zi: "-gcodeview"
Reid Kleckner9ce06a4a2016-02-10 21:28:38 +0000435// Zi: "-debug-info-kind=limited"
Reid Kleckner124955a2015-08-05 18:51:13 +0000436
437// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
Reid Kleckner124955a2015-08-05 18:51:13 +0000438// Z7: "-gcodeview"
Reid Kleckner9ce06a4a2016-02-10 21:28:38 +0000439// Z7: "-debug-info-kind=limited"
Reid Kleckner124955a2015-08-05 18:51:13 +0000440
David Majnemer58fab352016-07-09 21:49:16 +0000441// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
Reid Kleckner72a9d152016-03-18 18:42:56 +0000442// Z7GMLT: "-gcodeview"
443// Z7GMLT: "-debug-info-kind=line-tables-only"
444
Reid Klecknerbab5a5d2016-08-09 17:23:56 +0000445// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
446// ZGMLT: "-gcodeview"
447// ZGMLT: "-debug-info-kind=line-tables-only"
448
David Majnemer2b9349d2015-12-21 22:09:34 +0000449// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
450// BreproDefault: "-mincremental-linker-compatible"
451
452// RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
Nico Weber8531e492016-08-23 19:32:02 +0000453// Brepro-NOT: "-mincremental-linker-compatible"
David Majnemer2b9349d2015-12-21 22:09:34 +0000454
455// RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
Nico Weber8531e492016-08-23 19:32:02 +0000456// Brepro_: "-mincremental-linker-compatible"
David Majnemer2b9349d2015-12-21 22:09:34 +0000457
Douglas Katzman3459ce22015-10-08 04:24:12 +0000458// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
459// later on the command line, so it should win. Interestingly the cc1 arguments
460// came out right, but had wrong semantics, because an invariant assumed by
461// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
462// line-tables-only} appear. If you assume that, then you can safely use
463// Args.hasArg to test whether a boolean flag is present without caring
464// where it appeared. And for this test, it appeared to the left of -gdwarf
465// which made it "win". This test could not detect that bug.
Reid Kleckner124955a2015-08-05 18:51:13 +0000466// RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
Reid Kleckner124955a2015-08-05 18:51:13 +0000467// Z7_gdwarf: "-gcodeview"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000468// Z7_gdwarf: "-debug-info-kind=limited"
469// Z7_gdwarf: "-dwarf-version=4"
Reid Kleckner124955a2015-08-05 18:51:13 +0000470
David Majnemer8db91762015-05-18 04:49:30 +0000471// RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
472// CXX11: -std=c++11
473
474// RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
475// CXX14: -std=c++14
476
David Majnemer093012b2016-06-27 02:32:12 +0000477// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
478// STDCXX14: -std=c++14
479
480// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
481// STDCXXLATEST: -std=c++1z
482
David Majnemer3a4f9582015-08-10 18:16:32 +0000483// RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
484// ENV-CL: "-ffunction-sections"
485
486// RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
487// ENV-_CL_-NOT: "-ffunction-sections"
488
Hans Wennborg8a7c47f2014-07-16 16:03:56 +0000489// Accept "core" clang options.
Hans Wennborgc296b042015-04-11 11:44:44 +0000490// (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
Hans Wennborgdb829de2014-07-16 16:29:00 +0000491// RUN: %clang_cl \
492// RUN: --driver-mode=cl \
Hans Wennborgbec52352015-04-11 12:27:56 +0000493// RUN: -fcolor-diagnostics \
494// RUN: -fno-color-diagnostics \
Hans Wennborg7aeeb922015-04-12 07:12:19 +0000495// RUN: -fdiagnostics-color \
496// RUN: -fno-diagnostics-color \
Hans Wennborg0260ee12015-04-21 23:12:03 +0000497// RUN: -fdiagnostics-parseable-fixits \
Hans Wennborgb30f4372016-08-26 15:45:36 +0000498// RUN: -fdiagnostics-absolute-paths \
Hans Wennborgdb829de2014-07-16 16:29:00 +0000499// RUN: -ferror-limit=10 \
Hans Wennborg8a7c47f2014-07-16 16:03:56 +0000500// RUN: -fmsc-version=1800 \
Hans Wennborgdb829de2014-07-16 16:29:00 +0000501// RUN: -fno-strict-aliasing \
502// RUN: -fstrict-aliasing \
Hans Wennborg5615f6b2015-04-15 10:02:21 +0000503// RUN: -fsyntax-only \
Hans Wennborg1f53eb62015-10-08 23:13:28 +0000504// RUN: -fms-compatibility \
505// RUN: -fno-ms-compatibility \
506// RUN: -fms-extensions \
507// RUN: -fno-ms-extensions \
Hans Wennborgdb829de2014-07-16 16:29:00 +0000508// RUN: -mllvm -disable-llvm-optzns \
Hans Wennborg92375f52016-06-13 20:31:30 +0000509// RUN: -resource-dir \
Hans Wennborgc296b042015-04-11 11:44:44 +0000510// RUN: -Wunused-variable \
511// RUN: -fmacro-backtrace-limit=0 \
512// RUN: -Werror /Zs -- %s 2>&1
Hans Wennborg8a7c47f2014-07-16 16:03:56 +0000513
Hans Wennborg65a008682013-10-10 22:36:20 +0000514
Hans Wennborga8ef14f2013-09-17 00:03:41 +0000515void f() { }