1 // RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan \
2 // RUN: -triple powerpc64le-unknown-unknown %s \
3 // RUN: -menable-no-infs -menable-no-nans -std=c++23
5 // RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan \
6 // RUN: -triple powerpc64le-unknown-unknown %s \
7 // RUN: -menable-no-infs -menable-no-nans -funsafe-math-optimizations \
10 // RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \
13 // RUN: %clang_cc1 -x c++ -verify=no-inf -triple powerpc64le-unknown-unknown %s \
14 // RUN: -menable-no-infs -std=c++23
16 // RUN: %clang_cc1 -x c++ -verify=no-inf -triple powerpc64le-unknown-unknown %s \
17 // RUN: -menable-no-infs -funsafe-math-optimizations -std=c++23
19 // RUN: %clang_cc1 -x c++ -verify=no-nan -triple powerpc64le-unknown-unknown %s \
20 // RUN: -menable-no-nans -std=c++23
22 // RUN: %clang_cc1 -x c++ -verify=no-nan -triple powerpc64le-unknown-unknown %s \
23 // RUN: -funsafe-math-optimizations -menable-no-nans -std=c++23
25 // RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \
26 // RUN: %s -Wno-nan-infinity-disabled -menable-no-infs -std=c++23
28 // RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \
29 // RUN: %s -Wno-nan-infinity-disabled -menable-no-nans -std=c++23
31 // no-fast-no-diagnostics
33 int isunorderedf (float x
, float y
);
35 namespace std
__attribute__((__visibility__("default"))) {
41 isinf(long double __x
);
47 isnan(long double __x
);
53 isfinte(long double __x
);
55 isunordered(float __x
, float __y
);
57 isunordered(double __x
, double __y
);
59 isunordered(long double __x
, long double __y
);
63 #define NAN (__builtin_nanf(""))
64 #define INFINITY (__builtin_inff())
67 class numeric_limits
{
69 [[nodiscard
]] static constexpr _Ty
infinity() noexcept
{
75 class numeric_limits
<float> {
77 [[nodiscard
]] static constexpr float infinity() noexcept
{
78 return __builtin_huge_val();
82 class numeric_limits
<double> {
84 [[nodiscard
]] static constexpr double infinity() noexcept
{
85 return __builtin_huge_val();
89 int compareit(float a
, float b
) {
90 volatile int i
, j
, k
, l
, m
, n
, o
, p
;
91 // no-inf-no-nan-warning@+4 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
92 // no-inf-no-nan-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
93 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
94 // no-inf-warning@+1 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
97 // no-inf-no-nan-warning@+4 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
98 // no-inf-no-nan-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
99 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
100 // no-inf-warning@+1 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
103 // no-inf-no-nan-warning@+4 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
104 // no-inf-no-nan-warning@+3 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
105 // no-nan-warning@+2 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
106 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
109 // no-inf-no-nan-warning@+4 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
110 // no-inf-no-nan-warning@+3 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
111 // no-nan-warning@+2 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
112 // no-nan-warning@+1 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
115 // no-inf-no-nan-warning@+4 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
116 // no-inf-no-nan-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
117 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
118 // no-inf-warning@+1 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
121 // no-inf-no-nan-warning@+4 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
122 // no-inf-no-nan-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
123 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
124 // no-inf-warning@+1 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
127 // no-inf-no-nan-warning@+4 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
128 // no-inf-no-nan-warning@+3 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
129 // no-nan-warning@+2 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
130 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
133 // no-inf-no-nan-warning@+4 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
134 // no-inf-no-nan-warning@+3 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
135 // no-nan-warning@+2 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
136 // no-nan-warning@+1 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
139 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
140 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
143 // no-inf-no-nan-warning@+2 {{use of NaN is undefined behavior due to the currently enabled floating-point option}}
144 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
147 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
148 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
149 o
= std::isfinite(a
);
151 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
152 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
153 m
= __builtin_isinf(a
);
155 // no-inf-no-nan-warning@+2 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
156 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
157 n
= __builtin_isnan(a
);
159 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
160 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
161 p
= __builtin_isfinite(a
);
163 // These should NOT warn, since they are not using NaN or infinity.
168 j
= isunorderedf(a
, b
);
182 #if defined(INFINITY)
187 #if defined(INFINITY)
198 // no-inf-no-nan-warning@+4 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
199 // no-inf-no-nan-warning@+3 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
200 // no-nan-warning@+2 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
201 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
202 j
= isunorderedf(a
, NAN
);
204 // no-inf-no-nan-warning@+4 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
205 // no-inf-no-nan-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
206 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
207 // no-inf-warning@+1 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
208 j
= isunorderedf(a
, INFINITY
);
210 // no-inf-no-nan-warning@+6 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
211 // no-inf-no-nan-warning@+5 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
212 // no-inf-no-nan-warning@+4 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
213 // no-nan-warning@+3 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
214 // no-nan-warning@+2 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
215 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
216 i
= std::isunordered(a
, NAN
);
218 // no-inf-no-nan-warning@+6 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
219 // no-inf-no-nan-warning@+5 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
220 // no-inf-no-nan-warning@+4 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
221 // no-inf-warning@+3 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
222 // no-inf-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
223 // no-nan-warning@+1 {{use of NaN is undefined behavior due to the currently enabled floating-point options}}
224 i
= std::isunordered(a
, INFINITY
);
226 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
227 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
228 double y
= i
* numeric_limits
<double>::infinity();
230 // no-inf-no-nan-warning@+2 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
231 // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
232 j
= numeric_limits
<float>::infinity();