1 // Test that incompatible combinations of -ffp-model= options
2 // and other floating point options get a warning diagnostic.
3 //
4 // REQUIRES: clang-driver
5 
6 // RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
7 // RUN:   | FileCheck --check-prefix=WARN %s
8 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
9 
10 // RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
11 // RUN:   | FileCheck --check-prefix=WARN1 %s
12 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
13 
14 // RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
15 // RUN:   | FileCheck --check-prefix=WARN2 %s
16 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
17 
18 // RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
19 // RUN:   | FileCheck --check-prefix=WARN3 %s
20 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
21 
22 // RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
23 // RUN:   | FileCheck --check-prefix=WARN4 %s
24 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
25 
26 // RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
27 // RUN:   | FileCheck --check-prefix=WARN5 %s
28 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
29 
30 // RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
31 // RUN:   | FileCheck --check-prefix=WARN7 %s
32 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
33 
34 // RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
35 // RUN:   | FileCheck --check-prefix=WARN8 %s
36 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
37 
38 // RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
39 // RUN:   | FileCheck --check-prefix=WARN9 %s
40 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
41 
42 // RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
43 // RUN:   | FileCheck --check-prefix=WARNa %s
44 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
45 
46 // RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
47 // RUN:   | FileCheck --check-prefix=WARNb %s
48 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
49 
50 // RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
51 // RUN:   | FileCheck --check-prefix=WARNc %s
52 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
53 
54 // RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
55 // RUN:   | FileCheck --check-prefix=WARNd %s
56 // WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-t-option]
57 
58 // RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
59 // RUN:   | FileCheck --check-prefix=WARNe %s
60 // WARNe: warning: overriding '-ffp-model=strict' option with '-funsafe-math-optimizations' [-Woverriding-t-option]
61 
62 // RUN: %clang -### -ffp-model=strict -Ofast -c %s 2>&1 \
63 // RUN:   | FileCheck --check-prefix=WARNf %s
64 // WARNf: warning: overriding '-ffp-model=strict' option with '-Ofast' [-Woverriding-t-option]
65 
66 // RUN: %clang -### -ffp-model=strict -fdenormal-fp-math=preserve-sign,preserve-sign -c %s 2>&1 \
67 // RUN:   | FileCheck --check-prefix=WARN10 %s
68 // WARN10: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-t-option]
69 
70 // RUN: %clang -### -c %s 2>&1 \
71 // RUN:   | FileCheck --check-prefix=CHECK-NOROUND %s
72 // CHECK-NOROUND: "-cc1"
73 // CHECK-NOROUND: "-fno-rounding-math"
74 
75 // RUN: %clang -### -frounding-math -c %s 2>&1 \
76 // RUN:   | FileCheck --check-prefix=CHECK-ROUND --implicit-check-not ffp-exception-behavior=strict %s
77 // CHECK-ROUND: "-cc1"
78 // CHECK-ROUND: "-frounding-math"
79 
80 // RUN: %clang -### -ftrapping-math -c %s 2>&1 \
81 // RUN:   | FileCheck --check-prefix=CHECK-TRAP %s
82 // CHECK-TRAP: "-cc1"
83 // CHECK-TRAP: "-ftrapping-math"
84 // CHECK-TRAP: "-ffp-exception-behavior=strict"
85 
86 // RUN: %clang -### -nostdinc -ffp-model=fast -c %s 2>&1 \
87 // RUN:   | FileCheck --check-prefix=CHECK-FPM-FAST %s
88 // CHECK-FPM-FAST: "-cc1"
89 // CHECK-FPM-FAST: "-menable-no-infs"
90 // CHECK-FPM-FAST: "-menable-no-nans"
91 // CHECK-FPM-FAST: "-menable-unsafe-fp-math"
92 // CHECK-FPM-FAST: "-fno-signed-zeros"
93 // CHECK-FPM-FAST: "-mreassociate"
94 // CHECK-FPM-FAST: "-freciprocal-math"
95 // CHECK-FPM-FAST: "-ffp-contract=fast"
96 // CHECK-FPM-FAST: "-fno-rounding-math"
97 // CHECK-FPM-FAST: "-ffast-math"
98 // CHECK-FPM-FAST: "-ffinite-math-only"
99 
100 // RUN: %clang -### -nostdinc -ffp-model=precise -c %s 2>&1 \
101 // RUN:   | FileCheck --check-prefix=CHECK-FPM-PRECISE %s
102 // CHECK-FPM-PRECISE: "-cc1"
103 // CHECK-FPM-PRECISE: "-ffp-contract=fast"
104 // CHECK-FPM-PRECISE: "-fno-rounding-math"
105 
106 // RUN: %clang -### -nostdinc -ffp-model=strict -c %s 2>&1 \
107 // RUN:   | FileCheck --check-prefix=CHECK-FPM-STRICT %s
108 // CHECK-FPM-STRICT: "-cc1"
109 // CHECK-FPM-STRICT: "-ftrapping-math"
110 // CHECK-FPM-STRICT: "-frounding-math"
111 // CHECK-FPM-STRICT: "-ffp-exception-behavior=strict"
112 
113 // RUN: %clang -### -nostdinc -ftrapping-math -ffp-exception-behavior=ignore -c %s 2>&1 \
114 // RUN:   | FileCheck --check-prefix=CHECK-TRAP-IGNORE %s
115 // CHECK-TRAP-IGNORE: "-cc1"
116 // CHECK-TRAP-IGNORE: "-fno-rounding-math"
117 // CHECK-TRAP-IGNORE: "-ffp-exception-behavior=ignore"
118 
119 
120 // RUN: %clang -### -nostdinc -ffp-exception-behavior=strict -c %s 2>&1 \
121 // RUN:   | FileCheck --check-prefix=CHECK-FEB-STRICT %s
122 // CHECK-FEB-STRICT: "-cc1"
123 // CHECK-FEB-STRICT: "-fno-rounding-math"
124 // CHECK-FEB-STRICT: "-ffp-exception-behavior=strict"
125 
126 // RUN: %clang -### -nostdinc -ffp-exception-behavior=maytrap -c %s 2>&1 \
127 // RUN:   | FileCheck --check-prefix=CHECK-FEB-MAYTRAP %s
128 // CHECK-FEB-MAYTRAP: "-cc1"
129 // CHECK-FEB-MAYTRAP: "-fno-rounding-math"
130 // CHECK-FEB-MAYTRAP: "-ffp-exception-behavior=maytrap"
131 
132 // RUN: %clang -### -nostdinc -ffp-exception-behavior=ignore -c %s 2>&1 \
133 // RUN:   | FileCheck --check-prefix=CHECK-FEB-IGNORE %s
134 // CHECK-FEB-IGNORE: "-cc1"
135 // CHECK-FEB-IGNORE: "-fno-rounding-math"
136 // CHECK-FEB-IGNORE: "-ffp-exception-behavior=ignore"
137 
138