[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Driver / fp-contract.c
blobcab63683ee813209f41196cae8ba741e9da185af
1 // Test that -ffp-contract is set to the right value when combined with
2 // the options -ffast-math, -fno-fast-math, funsafe-math-optimizations,
3 // fno-unsafe-math-optimizations.
5 // These warning checks are above the run lines because the warning is reported
6 // before the drive options that are checked below the run lines.
7 // WARN_FM_OFF: warning: overriding '-ffast-math' option with '-ffp-contract=off'
8 // WARN_FM_ON: warning: overriding '-ffast-math' option with '-ffp-contract=on'
9 // WARN_FM_FHP: warning: overriding '-ffast-math' option with '-ffp-contract=fast-honor-pragmas'
10 // WARN_UM_OFF: warning: overriding '-funsafe-math-optimizations' option with '-ffp-contract=off'
11 // WARN_UM_ON: warning: overriding '-funsafe-math-optimizations' option with '-ffp-contract=on'
13 // ffast-math, fno-fast-math
14 // RUN: %clang -### -ffast-math -c %s 2>&1 \
15 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
16 // CHECK-FPC-FAST: "-ffp-contract=fast"
18 // RUN: %clang -### -fno-fast-math -c %s 2>&1 \
19 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
21 // RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \
22 // RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
23 // CHECK-FPC-ON: "-ffp-contract=on"
25 // RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
26 // RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
27 // CHECK-FPC-OFF: "-ffp-contract=off"
29 // RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -c %s 2>&1 \
30 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
32 // RUN: %clang -### -ffast-math -ffp-contract=fast-honor-pragmas -c %s 2>&1 \
33 // RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST-HONOR,WARN_FM_FHP %s
34 // CHECK-FPC-FAST-HONOR: "-ffp-contract=fast-honor-pragmas"
36 // RUN: %clang -### -Werror -ffp-contract=fast -ffast-math -c %s 2>&1 \
37 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
38 // RUN: %clang -### -Werror -ffp-contract=on -ffast-math -c %s 2>&1 \
39 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
40 // RUN: %clang -### -Werror -ffp-contract=off -ffast-math -c %s 2>&1 \
41 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
43 // RUN: %clang -### -Werror -ffp-contract=fast -fno-fast-math -c %s 2>&1 \
44 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
45 // RUN: %clang -### -Werror -ffp-contract=on -fno-fast-math -c %s 2>&1 \
46 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
47 // RUN: %clang -### -Werror -ffp-contract=off -fno-fast-math -c %s 2>&1 \
48 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
51 // RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -ffp-contract=on -c %s 2>&1 \
52 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
54 // RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=off -c %s 2>&1 \
55 // RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_ON %s
57 // RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=fast -c %s 2>&1 \
58 // RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_FM_ON %s
60 // RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=on -c %s 2>&1 \
61 // RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_OFF %s
63 // RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=fast \
64 // RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_FM_OFF %s
66 // RUN: %clang -### -ffast-math -ffp-contract=on -fno-fast-math -c %s 2>&1 \
67 // RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
69 // RUN: %clang -### -ffast-math -ffp-contract=off -fno-fast-math -c %s 2>&1 \
70 // RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
72 // RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -fno-fast-math -c %s 2>&1 \
73 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
75 // RUN: %clang -### -Werror -ffast-math -fno-fast-math -c %s 2>&1 \
76 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
78 // RUN: %clang -### -Werror -fno-fast-math -ffast-math -c %s 2>&1 \
79 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
81 // RUN: %clang -### -Werror -fno-fast-math -ffp-contract=on -c %s 2>&1 \
82 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
84 // RUN: %clang -### -Werror -fno-fast-math -ffp-contract=off -c %s 2>&1 \
85 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
87 // RUN: %clang -### -Werror -fno-fast-math -ffp-contract=fast -c %s 2>&1 \
88 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
90 // RUN: %clang -### -Werror -ffp-contract=fast -fno-fast-math -ffp-contract=on \
91 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
93 // RUN: %clang -### -Werror -ffp-contract=fast -fno-fast-math -ffp-contract=off \
94 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
96 // RUN: %clang -### -Werror -ffp-contract=off -fno-fast-math -ffp-contract=fast \
97 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
99 // RUN: %clang -### -Werror -ffp-contract=off -fno-fast-math -ffp-contract=on \
100 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
102 // RUN: %clang -### -Werror -ffp-contract=on -ffast-math -c %s 2>&1 \
103 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
105 // RUN: %clang -### -Werror -ffp-contract=off -ffast-math -c %s 2>&1 \
106 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
108 // RUN: %clang -### -Werror -ffp-contract=fast -ffast-math -c %s 2>&1 \
109 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
111 // RUN: %clang -### -Werror -ffp-contract=on -ffast-math -fno-fast-math -c %s 2>&1 \
112 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
114 // RUN: %clang -### -Werror -ffp-contract=off -ffast-math -fno-fast-math -c %s 2>&1 \
115 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
117 // RUN: %clang -### -Werror -ffp-contract=fast -ffast-math -fno-fast-math -c %s 2>&1 \
118 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
120 // RUN: %clang -### -Werror -fno-fast-math -ffast-math -ffp-contract=fast \
121 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
123 // RUN: %clang -### -fno-fast-math -ffast-math -ffp-contract=on \
124 // RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
126 // RUN: %clang -### -fno-fast-math -ffast-math -ffp-contract=off \
127 // RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
129 // funsafe-math-optimizations, fno-unsafe-math-optimizations
130 // RUN: %clang -### -Werror -funsafe-math-optimizations -c %s 2>&1 \
131 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
133 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -c %s 2>&1 \
134 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
136 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on -c %s 2>&1 \
137 // RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
139 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
140 // RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
142 // RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast -c %s 2>&1 \
143 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
145 // RUN: %clang -### -Werror -ffp-contract=fast -funsafe-math-optimizations -c %s 2>&1 \
146 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
147 // RUN: %clang -### -Werror -ffp-contract=on -funsafe-math-optimizations -c %s 2>&1 \
148 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
149 // RUN: %clang -### -Werror -ffp-contract=off -funsafe-math-optimizations -c %s 2>&1 \
150 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
152 // RUN: %clang -### -Werror -ffp-contract=fast -fno-unsafe-math-optimizations -c \
153 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
154 // RUN: %clang -### -Werror -ffp-contract=on -fno-unsafe-math-optimizations -c %s 2>&1 \
155 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
156 // RUN: %clang -### -Werror -ffp-contract=off -fno-unsafe-math-optimizations -c %s 2>&1 \
157 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
159 // RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast \
160 // RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
162 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
163 // RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_ON %s
165 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
166 // RUN: -ffp-contract=fast -c %s 2>&1 \
167 // RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_UM_ON %s
169 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
170 // RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_OFF %s
172 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
173 // RUN: -ffp-contract=fast \
174 // RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_UM_OFF %s
176 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
177 // RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
178 // RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
180 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
181 // RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
182 // RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
184 // RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast \
185 // RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
186 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
188 // RUN: %clang -### -Werror -funsafe-math-optimizations -fno-unsafe-math-optimizations \
189 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
191 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -funsafe-math-optimizations \
192 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
194 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -ffp-contract=on -c %s 2>&1 \
195 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
197 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
198 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
200 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -ffp-contract=fast -c %s 2>&1 \
201 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
203 // RUN: %clang -### -Werror -ffp-contract=fast -fno-unsafe-math-optimizations \
204 // RUN: -ffp-contract=on \
205 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
207 // RUN: %clang -### -Werror -ffp-contract=fast -fno-unsafe-math-optimizations \
208 // RUN: -ffp-contract=off \
209 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
211 // RUN: %clang -### -Werror -ffp-contract=off -fno-unsafe-math-optimizations \
212 // RUN: -ffp-contract=fast \
213 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
215 // RUN: %clang -### -Werror -ffp-contract=off -fno-unsafe-math-optimizations \
216 // RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
218 // RUN: %clang -### -Werror -ffp-contract=on -funsafe-math-optimizations -c %s 2>&1 \
219 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
221 // RUN: %clang -### -Werror -ffp-contract=off -funsafe-math-optimizations -c %s 2>&1 \
222 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
224 // RUN: %clang -### -Werror -ffp-contract=fast -funsafe-math-optimizations -c %s 2>&1 \
225 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
227 // RUN: %clang -### -Werror -ffp-contract=on -funsafe-math-optimizations -fno-unsafe-math-optimizations -c %s 2>&1 \
228 // RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
230 // RUN: %clang -### -Werror -ffp-contract=off -funsafe-math-optimizations -fno-unsafe-math-optimizations -c %s 2>&1 \
231 // RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
233 // RUN: %clang -### -Werror -ffp-contract=fast -funsafe-math-optimizations -fno-unsafe-math-optimizations -c %s 2>&1 \
234 // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
236 // RUN: %clang -### -Werror -fno-unsafe-math-optimizations -funsafe-math-optimizations \
237 // RUN: -ffp-contract=fast \
238 // RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
240 // RUN: %clang -### -fno-unsafe-math-optimizations -funsafe-math-optimizations \
241 // RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
243 // RUN: %clang -### -fno-unsafe-math-optimizations -funsafe-math-optimizations \
244 // RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
246 // RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
247 // RUN: | FileCheck --check-prefix=WARN_UM_OFF %s
249 // This case should not warn
250 // RUN: %clang -### -Werror -funsafe-math-optimizations \
251 // RUN: -fno-unsafe-math-optimizations -ffp-contract=off -c %s
253 // RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
254 // RUN: | FileCheck --check-prefix=WARN_FM_OFF %s
256 // This case should not warn
257 // RUN: %clang -### -Werror -ffast-math -fno-fast-math -ffp-contract=off -c %s