[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Driver / fp-model.c
blob6f17d4aeb1ef577259563654215f40c55bdbab35
1 // Test that incompatible combinations of -ffp-model= options
2 // and other floating point options get a warning diagnostic.
3 //
5 // RUN: %clang -### -ffp-model=aggressive -ffp-contract=off -c %s 2>&1 \
6 // RUN: | FileCheck --check-prefix=WARN %s
7 // WARN: warning: overriding '-ffp-model=aggressive' option with '-ffp-contract=off' [-Woverriding-option]
9 // RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
10 // RUN: | FileCheck --check-prefix=WARN0 %s
11 // WARN0: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-option]
13 // RUN: %clang -### -ffp-model=aggressive -ffp-contract=on -c %s 2>&1 \
14 // RUN: | FileCheck --check-prefix=WARN1 %s
15 // WARN1: warning: overriding '-ffp-model=aggressive' option with '-ffp-contract=on' [-Woverriding-option]
17 // RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
18 // RUN: | FileCheck --check-prefix=WARN2 %s
19 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-option]
21 // RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
22 // RUN: | FileCheck --check-prefix=WARN3 %s
23 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-option]
25 // RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
26 // RUN: | FileCheck --check-prefix=WARN4 %s
27 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-option]
29 // RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
30 // RUN: | FileCheck --check-prefix=WARN5 %s
31 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-option]
33 // RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
34 // RUN: | FileCheck --check-prefix=WARN7 %s
35 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-option]
37 // RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
38 // RUN: | FileCheck --check-prefix=WARN8 %s
39 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-option]
41 // RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
42 // RUN: | FileCheck --check-prefix=WARN9 %s
43 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-option]
45 // RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
46 // RUN: | FileCheck --check-prefix=WARNa %s
47 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-option]
49 // RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
50 // RUN: | FileCheck --check-prefix=WARNb %s
51 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-option]
53 // RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
54 // RUN: | FileCheck --check-prefix=WARNc %s
55 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-option]
57 // RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
58 // RUN: | FileCheck --check-prefix=WARNd %s
59 // WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-option]
61 // RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
62 // RUN: | FileCheck --check-prefix=WARNe %s
63 // WARNe: warning: overriding '-ffp-model=strict' option with '-funsafe-math-optimizations' [-Woverriding-option]
65 // RUN: %clang -### -ffp-model=strict -Ofast -c %s 2>&1 \
66 // RUN: | FileCheck --check-prefix=WARNf %s
67 // WARNf: warning: overriding '-ffp-model=strict' option with '-Ofast' [-Woverriding-option]
69 // RUN: %clang -### -ffp-model=strict -fdenormal-fp-math=preserve-sign,preserve-sign -c %s 2>&1 \
70 // RUN: | FileCheck --check-prefix=WARN10 %s
71 // WARN10: "-cc1"
72 // WARN10-NOT: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-option]
74 // RUN: %clang -### -ffp-model=fast -ffp-model=strict -c %s 2>&1 | FileCheck \
75 // RUN: --check-prefix=WARN11 %s
76 // WARN11: warning: overriding '-ffp-model=fast' option with '-ffp-model=strict' [-Woverriding-option]
77 // WARN11-NOT: warning: overriding '-ffp-model=strict' option with '-ffp-model=strict' [-Woverriding-option]
79 // RUN: %clang -### -Ofast -ffp-model=strict -c %s 2>&1 | FileCheck \
80 // RUN: --check-prefix=WARN12 %s
81 // WARN12: warning: overriding '-ffp-model=strict' option with '-Ofast'
83 // RUN: %clang -### -ffast-math -ffp-model=strict -c %s 2>&1 | FileCheck \
84 // RUN: --check-prefix=WARN-CX-BASIC-TO-FULL %s
85 // WARN-CX-BASIC-TO-FULL: warning: overriding '-fcomplex-arithmetic=basic' option with '-fcomplex-arithmetic=full'
87 // RUN: %clang -### -ffp-model=strict -fapprox-func -c %s 2>&1 \
88 // RUN: | FileCheck --check-prefix=WARN13 %s
89 // WARN13: warning: overriding '-ffp-model=strict' option with '-fapprox-func' [-Woverriding-option]
91 // RUN: %clang -### -ffp-model=precise -ffp-contract=off -c %s 2>&1 \
92 // RUN: | FileCheck --check-prefix=WARN14 %s
93 // WARN14: warning: overriding '-ffp-model=precise' option with '-ffp-contract=off' [-Woverriding-option]
95 // RUN: %clang -### -ffp-model=precise -ffp-contract=fast -c %s 2>&1 \
96 // RUN: | FileCheck --check-prefix=WARN15 %s
97 // WARN15: warning: overriding '-ffp-model=precise' option with '-ffp-contract=fast' [-Woverriding-option]
99 // RUN: %clang -### -ffp-model=strict -fassociative-math -ffp-contract=on \
100 // RUN: -c %s 2>&1 | FileCheck --check-prefix=WARN16 %s
101 // WARN16: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-option]
102 // WARN16: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-option]
104 // RUN: %clang -### -c %s 2>&1 \
105 // RUN: | FileCheck --check-prefix=CHECK-NOROUND %s
106 // CHECK-NOROUND: "-cc1"
107 // CHECK-NOROUND-SAME: "-fno-rounding-math"
109 // RUN: %clang -### -frounding-math -c %s 2>&1 \
110 // RUN: | FileCheck --check-prefix=CHECK-ROUND --implicit-check-not ffp-exception-behavior=strict %s
111 // CHECK-ROUND: "-cc1"
112 // CHECK-ROUND-SAME: "-frounding-math"
114 // RUN: %clang -### -ftrapping-math -c %s 2>&1 \
115 // RUN: | FileCheck --check-prefix=CHECK-TRAP %s
116 // CHECK-TRAP: "-cc1"
117 // CHECK-TRAP-SAME: "-ffp-exception-behavior=strict"
119 // RUN: %clang -### -nostdinc -ffp-model=aggressive -c %s 2>&1 \
120 // RUN: | FileCheck --check-prefix=CHECK-FPM-AGGR %s
121 // CHECK-FPM-AGGR: "-cc1"
122 // CHECK-FPM-AGGR-SAME: "-menable-no-infs"
123 // CHECK-FPM-AGGR-SAME: "-menable-no-nans"
124 // CHECK-FPM-AGGR-SAME: "-fapprox-func"
125 // CHECK-FPM-AGGR-SAME: "-funsafe-math-optimizations"
126 // CHECK-FPM-AGGR-SAME: "-fno-signed-zeros"
127 // CHECK-FPM-AGGR-SAME: "-mreassociate"
128 // CHECK-FPM-AGGR-SAME: "-freciprocal-math"
129 // CHECK-FPM-AGGR-SAME: "-ffp-contract=fast"
130 // CHECK-FPM-AGGR-SAME: "-fno-rounding-math"
131 // CHECK-FPM-AGGR-SAME: "-ffast-math"
132 // CHECK-FPM-AGGR-SAME: "-ffinite-math-only"
133 // CHECK-FPM-AGGR-SAME: "-complex-range=basic"
135 // RUN: %clang -### -nostdinc -ffp-model=fast -c %s 2>&1 \
136 // RUN: | FileCheck --check-prefix=CHECK-FPM-FAST %s
137 // CHECK-FPM-FAST: "-cc1"
138 // CHECK-FPM-FAST-NOT: "-menable-no-infs"
139 // CHECK-FPM-FAST-NOT: "-menable-no-nans"
140 // CHECK-FPM-FAST-SAME: "-fapprox-func"
141 // CHECK-FPM-FAST-SAME: "-funsafe-math-optimizations"
142 // CHECK-FPM-FAST-SAME: "-fno-signed-zeros"
143 // CHECK-FPM-FAST-SAME: "-mreassociate"
144 // CHECK-FPM-FAST-SAME: "-freciprocal-math"
145 // CHECK-FPM-FAST-SAME: "-ffp-contract=fast"
146 // CHECK-FPM-FAST-SAME: "-fno-rounding-math"
147 // CHECK-FPM-FAST-NOT: "-ffast-math"
148 // CHECK-FPM-FAST-NOT: "-ffinite-math-only"
149 // CHECK-FPM-FAST-SAME: "-complex-range=promoted"
151 // RUN: %clang -### -nostdinc -ffp-model=precise -c %s 2>&1 \
152 // RUN: | FileCheck --check-prefix=CHECK-FPM-PRECISE %s
153 // CHECK-FPM-PRECISE: "-cc1"
154 // CHECK-FPM-PRECISE-SAME: "-ffp-contract=on"
155 // CHECK-FPM-PRECISE-SAME: "-fno-rounding-math"
157 // RUN: %clang -### -nostdinc -ffp-model=strict -c %s 2>&1 \
158 // RUN: | FileCheck --check-prefix=CHECK-FPM-STRICT %s
159 // CHECK-FPM-STRICT: "-cc1"
160 // CHECK-FPM-STRICT-SAME: "-frounding-math"
161 // CHECK-FPM-STRICT-SAME: "-ffp-exception-behavior=strict"
163 // RUN: %clang -### -nostdinc -ffp-model=strict -ffp-model=fast -c %s 2>&1 \
164 // RUN: | FileCheck --check-prefix=CHECK-NO-EXCEPT %s
165 // RUN: %clang -### -nostdinc -ffp-model=strict -ffast-math -c %s 2>&1 \
166 // RUN: | FileCheck --check-prefix=CHECK-NO-EXCEPT %s
167 // RUN: %clang -### -nostdinc -ffp-model=strict -Ofast -c %s 2>&1 \
168 // RUN: | FileCheck --check-prefix=CHECK-NO-EXCEPT %s
169 // CHECK-NO-EXCEPT: "-cc1"
170 // CHECK-NO-EXCEPT-NOT: "-ffp-exception-behavior=strict"
172 // RUN: %clang -### -nostdinc -ffp-exception-behavior=strict -c %s 2>&1 \
173 // RUN: | FileCheck --check-prefix=CHECK-FEB-STRICT %s
174 // CHECK-FEB-STRICT: "-cc1"
175 // CHECK-FEB-STRICT-SAME: "-fno-rounding-math"
176 // CHECK-FEB-STRICT-SAME: "-ffp-exception-behavior=strict"
178 // RUN: %clang -### -nostdinc -ffp-exception-behavior=maytrap -c %s 2>&1 \
179 // RUN: | FileCheck --check-prefix=CHECK-FEB-MAYTRAP %s
180 // CHECK-FEB-MAYTRAP: "-cc1"
181 // CHECK-FEB-MAYTRAP-SAME: "-fno-rounding-math"
182 // CHECK-FEB-MAYTRAP-SAME: "-ffp-exception-behavior=maytrap"
184 // RUN: %clang -### -nostdinc -ffp-exception-behavior=ignore -c %s 2>&1 \
185 // RUN: | FileCheck --check-prefix=CHECK-FEB-IGNORE %s
186 // CHECK-FEB-IGNORE: "-cc1"
187 // CHECK-FEB-IGNORE: "-fno-rounding-math"
188 // CHECK-FEB-IGNORE: "-ffp-exception-behavior=ignore"
190 // RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=aggressive -c %s 2>&1 \
191 // RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-AGGR %s
192 // CHECK-FASTMATH-FPM-AGGR: "-cc1"
193 // CHECK-FASTMATH-FPM-AGGR-SAME: "-menable-no-infs"
194 // CHECK-FASTMATH-FPM-AGGR-SAME: "-menable-no-nans"
195 // CHECK-FASTMATH-FPM-AGGR-SAME: "-fapprox-func"
196 // CHECK-FASTMATH-FPM-AGGR-SAME: "-funsafe-math-optimizations"
197 // CHECK-FASTMATH-FPM-AGGR-SAME: "-fno-signed-zeros"
198 // CHECK-FASTMATH-FPM-AGGR-SAME: "-mreassociate"
199 // CHECK-FASTMATH-FPM-AGGR-SAME: "-freciprocal-math"
200 // CHECK-FASTMATH-FPM-AGGR-SAME: "-ffp-contract=fast"
201 // CHECK-FASTMATH-FPM-AGGR-SAME: "-fno-rounding-math"
202 // CHECK-FASTMATH-FPM-AGGR-SAME: "-ffast-math"
203 // CHECK-FASTMATH-FPM-AGGR-SAME: "-ffinite-math-only"
204 // CHECK-FASTMATH-FPM-AGGR-SAME: "-complex-range=basic"
206 // RUN: %clang -### -nostdinc -ffast-math -ffp-model=fast -c %s 2>&1 \
207 // RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-FAST %s
208 // CHECK-FASTMATH-FPM-FAST: warning: overriding '-fcomplex-arithmetic=basic' option with '-fcomplex-arithmetic=promoted'
209 // CHECK-FASTMATH-FPM-FAST: "-cc1"
210 // CHECK-FASTMATH-FPM-FAST-NOT: "-menable-no-infs"
211 // CHECK-FASTMATH-FPM-FAST-NOT: "-menable-no-nans"
212 // CHECK-FASTMATH-FPM-FAST-SAME: "-fapprox-func"
213 // CHECK-FASTMATH-FPM-FAST-SAME: "-funsafe-math-optimizations"
214 // CHECK-FASTMATH-FPM-FAST-SAME: "-fno-signed-zeros"
215 // CHECK-FASTMATH-FPM-FAST-SAME: "-mreassociate"
216 // CHECK-FASTMATH-FPM-FAST-SAME: "-freciprocal-math"
217 // CHECK-FASTMATH-FPM-FAST-SAME: "-ffp-contract=fast"
218 // CHECK-FASTMATH-FPM-FAST-SAME: "-fno-rounding-math"
219 // CHECK-FASTMATH-FPM-FAST-NOT: "-ffast-math"
220 // CHECK-FASTMATH-FPM-FAST-NOT: "-ffinite-math-only"
221 // CHECK-FASTMATH-FPM-FAST-SAME: "-complex-range=promoted"
223 // RUN: %clang -### -nostdinc -ffast-math -ffp-model=precise -c %s 2>&1 \
224 // RUN: | FileCheck --check-prefixes=CHECK-FASTMATH-FPM-PRECISE,WARN-CX-BASIC-TO-FULL %s
225 // CHECK-FASTMATH-FPM-PRECISE: "-cc1"
226 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-infs"
227 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-nans"
228 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-fapprox-func"
229 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-funsafe-math-optimizations"
230 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-fno-signed-zeros"
231 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-mreassociate"
232 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-freciprocal-math"
233 // CHECK-FASTMATH-FPM-PRECISE-SAME: "-ffp-contract=on"
234 // CHECK-FASTMATH-FPM-PRECISE-SAME: "-fno-rounding-math"
235 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffast-math"
236 // CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffinite-math-only"
237 // CHECK-FASTMATH-FPM-PRECISE-SAME: "-complex-range=full"
239 // RUN: %clang -### -nostdinc -ffast-math -ffp-model=strict -c %s 2>&1 \
240 // RUN: | FileCheck --check-prefixes=CHECK-FASTMATH-FPM-STRICT,WARN-CX-BASIC-TO-FULL %s
241 // CHECK-FASTMATH-FPM-STRICT: "-cc1"
242 // CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-infs"
243 // CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-nans"
244 // CHECK-FASTMATH-FPM-STRICT-NOT: "-fapprox-func"
245 // CHECK-FASTMATH-FPM-STRICT-NOT: "-funsafe-math-optimizations"
246 // CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-signed-zeros"
247 // CHECK-FASTMATH-FPM-STRICT-NOT: "-mreassociate"
248 // CHECK-FASTMATH-FPM-STRICT-NOT: "-freciprocal-math"
249 // CHECK-FASTMATH-FPM-STRICT-SAME: "-ffp-contract=off"
250 // CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-rounding-math"
251 // CHECK-FASTMATH-FPM-STRICT-NOT: "-ffast-math"
252 // CHECK-FASTMATH-FPM-STRICT-NOT: "-ffinite-math-only"
253 // CHECK-FASTMATH-FPM-STRICT-SAME: "-complex-range=full"