| 1 | // Copyright (C) 2023-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-require-cmath "" } |
| 20 | |
| 21 | #include <stdfloat> |
| 22 | #include <cmath> |
| 23 | |
| 24 | template <typename T> |
| 25 | void |
| 26 | test_functions() |
| 27 | { |
| 28 | constexpr T zero = 0; |
| 29 | constexpr T one = 1; |
| 30 | constexpr auto a = std::acos(one); |
| 31 | constexpr auto b = std::asin(zero); |
| 32 | constexpr auto c = std::atan(zero); |
| 33 | constexpr auto d = std::cos(zero); |
| 34 | constexpr auto e = std::sin(zero); |
| 35 | constexpr auto f = std::tan(zero); |
| 36 | constexpr auto g = std::acosh(one); |
| 37 | constexpr auto h = std::asinh(zero); |
| 38 | constexpr auto i = std::atanh(zero); |
| 39 | constexpr auto j = std::cosh(zero); |
| 40 | constexpr auto k = std::sinh(zero); |
| 41 | constexpr auto l = std::tanh(zero); |
| 42 | constexpr auto m = std::exp(zero); |
| 43 | constexpr auto n = std::exp2(zero); |
| 44 | constexpr auto o = std::expm1(one); |
| 45 | constexpr auto p = std::log(one); |
| 46 | constexpr auto q = std::log10(one); |
| 47 | constexpr auto r = std::log1p(zero); |
| 48 | constexpr auto s = std::log2(one); |
| 49 | constexpr auto t = std::logb(one); |
| 50 | constexpr auto u = std::cbrt(zero); |
| 51 | constexpr auto v = std::fabs(zero); |
| 52 | constexpr auto w = std::sqrt(one); |
| 53 | constexpr auto x = std::erf(zero); |
| 54 | constexpr auto y = std::erfc(zero); |
| 55 | // constexpr auto z = std::lgamma(one); |
| 56 | constexpr auto A = std::tgamma(one); |
| 57 | constexpr auto B = std::ceil(zero); |
| 58 | constexpr auto C = std::floor(zero); |
| 59 | // constexpr auto D = std::nearbyint(zero); |
| 60 | // constexpr auto E = std::rint(zero); |
| 61 | constexpr auto F = std::round(zero); |
| 62 | constexpr auto G = std::trunc(zero); |
| 63 | constexpr auto H = std::atan2(zero, one); |
| 64 | constexpr auto I = std::hypot(one, zero); |
| 65 | constexpr auto J = std::pow(one, zero); |
| 66 | constexpr auto K = std::fmod(zero, one); |
| 67 | constexpr auto L = std::remainder(one, one); |
| 68 | constexpr auto M = std::copysign(zero, zero); |
| 69 | constexpr auto N = std::nextafter(zero, zero); |
| 70 | constexpr auto O = std::fdim(zero, zero); |
| 71 | constexpr auto P = std::fmax(zero, one); |
| 72 | constexpr auto Q = std::fmin(zero, one); |
| 73 | constexpr auto R = std::ilogb(one); |
| 74 | constexpr auto S = std::ldexp(one, 0); |
| 75 | constexpr auto U = std::scalbn(one, 1); |
| 76 | constexpr auto V = std::scalbln(one, 1); |
| 77 | // constexpr auto W = std::lrint(one); |
| 78 | // constexpr auto X = std::llrint(one); |
| 79 | constexpr auto Y = std::lround(one); |
| 80 | constexpr auto Z = std::llround(one); |
| 81 | constexpr auto a1 = std::fma(one, one, one); |
| 82 | constexpr auto b1 = std::atan2(zero, 1); |
| 83 | constexpr auto c1 = std::hypot(one, 0); |
| 84 | constexpr auto d1 = std::pow(one, 0); |
| 85 | constexpr auto e1 = std::fmod(zero, 1); |
| 86 | constexpr auto f1 = std::remainder(one, 1); |
| 87 | constexpr auto g1 = std::copysign(zero, 0); |
| 88 | constexpr auto h1 = std::nextafter(zero, 0); |
| 89 | constexpr auto i1 = std::fdim(zero, 0); |
| 90 | constexpr auto j1 = std::fmax(zero, 1); |
| 91 | constexpr auto k1 = std::fmin(zero, 1); |
| 92 | constexpr auto l1 = std::fma(one, one, 1); |
| 93 | constexpr auto n1 = std::atan2(0, one); |
| 94 | constexpr auto o1 = std::hypot(1, zero); |
| 95 | constexpr auto p1 = std::pow(1, zero); |
| 96 | constexpr auto q1 = std::fmod(0, one); |
| 97 | constexpr auto r1 = std::remainder(1, one); |
| 98 | constexpr auto s1 = std::copysign(0, zero); |
| 99 | constexpr auto t1 = std::nextafter(0, zero); |
| 100 | constexpr auto u1 = std::fdim(0, zero); |
| 101 | constexpr auto v1 = std::fmax(0, one); |
| 102 | constexpr auto w1 = std::fmin(0, one); |
| 103 | constexpr auto x1 = std::fma(one, 1, one); |
| 104 | constexpr auto y1 = std::fma(1, one, one); |
| 105 | constexpr auto z1 = std::fma(1, 1, one); |
| 106 | constexpr auto A1 = std::fma(1, one, 1); |
| 107 | } |
| 108 | |
| 109 | int |
| 110 | main() |
| 111 | { |
| 112 | #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 113 | test_functions<std::float16_t>(); |
| 114 | #endif |
| 115 | #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 116 | test_functions<std::float32_t>(); |
| 117 | #endif |
| 118 | #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 119 | test_functions<std::float64_t>(); |
| 120 | #endif |
| 121 | #if defined(__STDCPP_FLOAT128_T__) \ |
| 122 | && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ |
| 123 | || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) |
| 124 | test_functions<std::float128_t>(); |
| 125 | #endif |
| 126 | #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 127 | test_functions<std::bfloat16_t>(); |
| 128 | #endif |
| 129 | } |