| 1 |
// Copyright (C) 2022-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do link { target c++23 } } |
| 19 |
// { dg-excess-errors "" { target uclibc } } |
| 20 |
|
| 21 |
#include <cmath> |
| 22 |
#include <stdfloat> |
| 23 |
|
| 24 |
void fpclassify() { } |
| 25 |
|
| 26 |
void isfinite() { } |
| 27 |
|
| 28 |
void isinf() { } |
| 29 |
|
| 30 |
void isnan() { } |
| 31 |
|
| 32 |
void isnormal() { } |
| 33 |
|
| 34 |
void signbit() { } |
| 35 |
|
| 36 |
void isgreater() { } |
| 37 |
|
| 38 |
void isgreaterequal() { } |
| 39 |
|
| 40 |
void isless() { } |
| 41 |
|
| 42 |
void islessequal() { } |
| 43 |
|
| 44 |
void islessgreater() { } |
| 45 |
|
| 46 |
void isunordered() { } |
| 47 |
|
| 48 |
#if _GLIBCXX_USE_C99_MATH |
| 49 |
template <typename _Tp, typename _Up = _Tp> |
| 50 |
void test_c99_classify() |
| 51 |
{ |
| 52 |
typedef _Tp fp_type_one; |
| 53 |
typedef _Up fp_type_two; |
| 54 |
fp_type_one f1 = _Tp(1.0); |
| 55 |
fp_type_two f2 = _Up(3.0); |
| 56 |
int resi; |
| 57 |
volatile bool res; |
| 58 |
|
| 59 |
resi = std::fpclassify(f1); |
| 60 |
res = std::isfinite(f2); |
| 61 |
res = std::isinf(f1); |
| 62 |
res = std::isnan(f2); |
| 63 |
res = std::isnormal(f1); |
| 64 |
res = std::signbit(f2); |
| 65 |
res = std::isgreater(f1, f2); |
| 66 |
res = std::isgreaterequal(f1, f2); |
| 67 |
res = std::isless(f1, f2); |
| 68 |
res = std::islessequal(f1,f2); |
| 69 |
res = std::islessgreater(f1, f2); |
| 70 |
res = std::isunordered(f1, f2); |
| 71 |
resi = resi; // Suppress unused warning. |
| 72 |
res = res; |
| 73 |
} |
| 74 |
#endif |
| 75 |
|
| 76 |
int main() |
| 77 |
{ |
| 78 |
#if _GLIBCXX_USE_C99_MATH |
| 79 |
#ifdef __STDCPP_FLOAT16_T__ |
| 80 |
test_c99_classify<std::float16_t>(); |
| 81 |
#endif |
| 82 |
#ifdef __STDCPP_FLOAT32_T__ |
| 83 |
test_c99_classify<std::float32_t>(); |
| 84 |
#endif |
| 85 |
#ifdef __STDCPP_FLOAT64_T__ |
| 86 |
test_c99_classify<std::float64_t>(); |
| 87 |
#endif |
| 88 |
#ifdef __STDCPP_FLOAT128_T__ |
| 89 |
test_c99_classify<std::float128_t>(); |
| 90 |
#endif |
| 91 |
#ifdef __STDCPP_BFLOAT16_T__ |
| 92 |
test_c99_classify<std::bfloat16_t>(); |
| 93 |
#endif |
| 94 |
#endif |
| 95 |
return 0; |
| 96 |
} |