1 // REQUIRES: clang-driver
3 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
4 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
6 // CHECK-OPTIONS1: -split-stacks
7 // CHECK-OPTIONS1: -fgnu-keywords
8 // CHECK-OPTIONS1: -fblocks
9 // CHECK-OPTIONS1: -fpascal-strings
11 // CHECK-OPTIONS2: -fmath-errno
12 // CHECK-OPTIONS2: -fno-gnu-keywords
13 // CHECK-OPTIONS2: -fno-builtin
14 // CHECK-OPTIONS2: -fshort-enums
15 // CHECK-OPTIONS2: -fshort-wchar
16 // CHECK-OPTIONS2: -fno-common
17 // CHECK-OPTIONS2: -fno-show-source-location
19 // RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s
20 // WRITE-STRINGS1: -fconst-strings
21 // RUN: %clang -### -S -Wwrite-strings -Wno-write-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS2 %s
22 // WRITE-STRINGS2-NOT: -fconst-strings
23 // RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s
24 // WRITE-STRINGS3-NOT: -fconst-strings
26 // RUN: %clang -### -x c++ -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
27 // RUN: %clang -### -x c++ -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
28 // RUN: %clang -### -x c++ -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
29 // RUN: %clang -### -x c++ -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
30 // RUN: %clang -### -x c++ -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
31 // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
32 // RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
33 // DEPRECATED-ON-CHECK: -fdeprecated-macro
34 // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro
36 // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s
37 // RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s
38 // RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s
39 // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast
40 // FP-CONTRACT-OFF-CHECK: -ffp-contract=off
42 // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s
43 // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s
44 // RUN: %clang -### -S -fno-unroll-loops -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s
45 // RUN: %clang -### -S -funroll-loops -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s
46 // CHECK-UNROLL-LOOPS: "-funroll-loops"
47 // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
49 // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s
50 // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s
51 // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s
52 // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s
53 // CHECK-REROLL-LOOPS: "-freroll-loops"
54 // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops"
56 // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
57 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
59 // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
60 // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
62 // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
63 // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
64 // RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
65 // RUN: %clang -### -S -fvectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
66 // RUN: %clang -### -S -ftree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
67 // RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
68 // RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
69 // RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
70 // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
71 // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
72 // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
73 // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
74 // RUN: %clang -### -S -fno-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
75 // RUN: %clang -### -S -O1 -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
76 // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
77 // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
78 // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
79 // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
80 // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
81 // CHECK-VECTORIZE: "-vectorize-loops"
82 // CHECK-NO-VECTORIZE-NOT: "-vectorize-loops"
84 // RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
85 // RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
86 // RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
87 // RUN: %clang -### -S -fslp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
88 // RUN: %clang -### -S -ftree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
89 // RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
90 // RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
91 // RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
92 // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
93 // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
94 // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
95 // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
96 // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
97 // RUN: %clang -### -S -fno-slp-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
98 // RUN: %clang -### -S -O1 -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
99 // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
100 // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
101 // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
102 // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
103 // CHECK-SLP-VECTORIZE: "-vectorize-slp"
104 // CHECK-NO-SLP-VECTORIZE-NOT: "-vectorize-slp"
106 // RUN: %clang -### -S -fslp-vectorize-aggressive %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE-AGG %s
107 // RUN: %clang -### -S -fno-slp-vectorize-aggressive -fslp-vectorize-aggressive %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE-AGG %s
108 // RUN: %clang -### -S -fno-slp-vectorize-aggressive %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE-AGG %s
109 // RUN: %clang -### -S -fslp-vectorize-aggressive -fno-slp-vectorize-aggressive %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE-AGG %s
110 // CHECK-SLP-VECTORIZE-AGG: "-vectorize-slp-aggressive"
111 // CHECK-NO-SLP-VECTORIZE-AGG-NOT: "-vectorize-slp-aggressive"
113 // RUN: %clang -### -S -fextended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-EXTENDED-IDENTIFIERS %s
114 // RUN: %clang -### -S -fno-extended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EXTENDED-IDENTIFIERS %s
115 // CHECK-EXTENDED-IDENTIFIERS: "-cc1"
116 // CHECK-EXTENDED-IDENTIFIERS-NOT: "-fextended-identifiers"
117 // CHECK-NO-EXTENDED-IDENTIFIERS: error: unsupported option '-fno-extended-identifiers'
119 // RUN: %clang -### -S -fno-pascal-strings -mpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-M-PASCAL-STRINGS %s
120 // CHECK-M-PASCAL-STRINGS: "-fpascal-strings"
122 // RUN: %clang -### -S -fpascal-strings -mno-pascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-NO-M-PASCAL-STRINGS %s
123 // CHECK-NO-M-PASCAL-STRINGS-NOT: "-fpascal-strings"
125 // RUN: %clang -### -S -O4 %s 2>&1 | FileCheck -check-prefix=CHECK-MAX-O %s
126 // CHECK-MAX-O: warning: -O4 is equivalent to -O3
129 // RUN: %clang -S -O20 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-O %s
130 // CHECK-INVALID-O: warning: optimization level '-O20' is unsupported; using '-O3' instead
132 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
133 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
135 // Test that we don't error on these.
136 // RUN: %clang -### -S -Werror \
137 // RUN: -falign-functions -falign-functions=2 -fno-align-functions \
138 // RUN: -fasynchronous-unwind-tables -fno-asynchronous-unwind-tables \
139 // RUN: -fbuiltin -fno-builtin \
140 // RUN: -fdiagnostics-show-location=once \
141 // RUN: -ffloat-store -fno-float-store \
142 // RUN: -feliminate-unused-debug-types -fno-eliminate-unused-debug-types \
143 // RUN: -fgcse -fno-gcse \
144 // RUN: -fident -fno-ident \
145 // RUN: -fimplicit-templates -fno-implicit-templates \
146 // RUN: -finput-charset=UTF-8 \
147 // RUN: -fivopts -fno-ivopts \
148 // RUN: -fnon-call-exceptions -fno-non-call-exceptions \
149 // RUN: -fpermissive -fno-permissive \
150 // RUN: -fdefer-pop -fno-defer-pop \
151 // RUN: -fprefetch-loop-arrays -fno-prefetch-loop-arrays \
152 // RUN: -fprofile-correction -fno-profile-correction \
153 // RUN: -fprofile-dir=bar \
154 // RUN: -fprofile-use -fprofile-use=zed -fno-profile-use \
155 // RUN: -fprofile-values -fno-profile-values \
156 // RUN: -frounding-math -fno-rounding-math \
157 // RUN: -fsee -fno-see \
158 // RUN: -ftracer -fno-tracer \
159 // RUN: -funroll-all-loops -fno-unroll-all-loops \
160 // RUN: -fuse-ld=gold \
161 // RUN: -fno-builtin-foobar \
162 // RUN: -fno-builtin-strcat -fno-builtin-strcpy \
163 // RUN: -fno-var-tracking \
164 // RUN: -fno-unsigned-char \
165 // RUN: -fno-signed-char \
166 // RUN: -fstrength-reduce -fno-strength-reduce \
167 // RUN: -finline-limit=1000 \
168 // RUN: -finline-limit \
169 // RUN: %s 2>&1 | FileCheck --check-prefix=IGNORE %s
170 // IGNORE-NOT: error: unknown argument
172 // Test that the warning is displayed on these.
173 // RUN: %clang -### -finline-limit=1000 %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING1 %s
174 // RUN: %clang -### -finline-limit %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING2 %s
175 // CHECK-WARNING1: ignoring unsupported optimization flag '-finline-limit=1000'
176 // CHECK-WARNING2: ignoring unsupported optimization flag '-finline-limit'
178 // RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 %s
179 // RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 %s
180 // CHECK-WCHAR1: -fno-short-wchar
181 // CHECK-WCHAR1-NOT: -fshort-wchar
182 // CHECK-WCHAR2: -fshort-wchar
183 // CHECK-WCHAR2-NOT: -fno-short-wchar