|
1 | 1 | // Use of NAN macro will trigger a warning "infinity defined in macro" because
|
2 | 2 | // on Windows the NAN macro is defined using INFINITY. See below.
|
3 | 3 |
|
4 |
| -// RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan -triple powerpc64le-unknown-unknown %s \ |
5 |
| -// RUN: -menable-no-infs -menable-no-nans |
| 4 | +// RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan \ |
| 5 | +// RUN: -triple powerpc64le-unknown-unknown %s -menable-no-infs \ |
| 6 | +// RUN: -menable-no-nans -std=c++23 |
6 | 7 |
|
7 |
| -// RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown %s |
| 8 | +// RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan \ |
| 9 | +// RUN: -triple powerpc64le-unknown-unknown %s -menable-no-infs \ |
| 10 | +// RUN: -menable-no-nans -funsafe-math-optimizations -std=c++23 |
| 11 | + |
| 12 | +// RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \ |
| 13 | +// RUN: %s -std=c++23 |
| 14 | + |
| 15 | +// RUN: %clang_cc1 -x c++ -verify=no-inf -triple powerpc64le-unknown-unknown %s \ |
| 16 | +// RUN: -menable-no-infs -std=c++23 |
8 | 17 |
|
9 | 18 | // RUN: %clang_cc1 -x c++ -verify=no-inf -triple powerpc64le-unknown-unknown %s \
|
10 |
| -// RUN: -menable-no-infs |
| 19 | +// RUN: -menable-no-infs -funsafe-math-optimizations -std=c++23 |
| 20 | + |
| 21 | +// RUN: %clang_cc1 -x c++ -verify=no-nan -triple powerpc64le-unknown-unknown %s \ |
| 22 | +// RUN: -menable-no-nans -std=c++23 |
11 | 23 |
|
12 | 24 | // RUN: %clang_cc1 -x c++ -verify=no-nan -triple powerpc64le-unknown-unknown %s \
|
13 |
| -// RUN: -menable-no-nans |
| 25 | +// RUN: -funsafe-math-optimizations -menable-no-nans -std=c++23 |
| 26 | + |
| 27 | +// RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \ |
| 28 | +// RUN: %s -Wno-nan-infinity-disabled -menable-no-infs -std=c++23 |
| 29 | + |
| 30 | +// RUN: %clang_cc1 -x c++ -verify=no-fast -triple powerpc64le-unknown-unknown \ |
| 31 | +// RUN: %s -Wno-nan-infinity-disabled -menable-no-nans -std=c++23 |
14 | 32 |
|
15 | 33 | // no-fast-no-diagnostics
|
16 | 34 |
|
@@ -136,13 +154,41 @@ int compareit(float a, float b) {
|
136 | 154 | // no-inf-warning@+1 {{use of infinity is undefined behavior due to the currently enabled floating-point options}}
|
137 | 155 | p = __builtin_isfinite(a);
|
138 | 156 |
|
139 |
| - // These should NOT warn, since they are not using NaN or infinity. |
| 157 | +// These should NOT warn, since they are not using NaN or infinity. |
140 | 158 | j = a > 1.1;
|
141 | 159 | j = b < 1.1;
|
142 | 160 | j = a >= 1.1;
|
143 | 161 | j = b <= 1.1;
|
144 | 162 | j = isunorderedf(a, b);
|
145 | 163 |
|
| 164 | +#ifndef INFINITY |
| 165 | + j = a; |
| 166 | +#endif |
| 167 | +#ifndef NAN |
| 168 | + j = b; |
| 169 | +#endif |
| 170 | +#ifdef INFINITY |
| 171 | + j = a; |
| 172 | +#endif |
| 173 | +#ifdef NAN |
| 174 | + j = b; |
| 175 | +#endif |
| 176 | +#if defined(INFINITY) |
| 177 | + j = a; |
| 178 | +#elifndef(INFINITY) |
| 179 | + j = b; |
| 180 | +#endif |
| 181 | +#if defined(INFINITY) |
| 182 | + j = a; |
| 183 | +#elifndef(NAN) |
| 184 | + j = b; |
| 185 | +#endif |
| 186 | +#if defined(NAN) |
| 187 | + j = a; |
| 188 | +#elifndef(INFINITY) |
| 189 | + j = b; |
| 190 | +#endif |
| 191 | + |
146 | 192 | // no-inf-no-nan-warning@+4 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point option}}
|
147 | 193 | // no-inf-no-nan-warning@+3 {{use of NaN via a macro is undefined behavior due to the currently enabled floating-point options}}
|
148 | 194 | // no-inf-warning@+2 {{use of infinity via a macro is undefined behavior due to the currently enabled floating-point options}}
|
@@ -176,4 +222,4 @@ int compareit(float a, float b) {
|
176 | 222 | j = numeric_limits<float>::infinity();
|
177 | 223 | return 0;
|
178 | 224 |
|
179 |
| -} |
| 225 | +} |
0 commit comments