| 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 | |
| 20 | #include <stdfloat> |
| 21 | #include <complex> |
| 22 | |
| 23 | template <typename T> |
| 24 | __attribute__((__noipa__)) void |
| 25 | test_functions(T *p, std::complex<T> *q) |
| 26 | { |
| 27 | p[0] = std::abs(q[0]); |
| 28 | p[1] = std::arg(q[1]); |
| 29 | q[2] = std::cos(q[2]); |
| 30 | q[3] = std::cosh(q[3]); |
| 31 | q[4] = std::exp(q[4]); |
| 32 | q[5] = std::log(q[5]); |
| 33 | q[6] = std::sin(q[6]); |
| 34 | q[7] = std::sinh(q[7]); |
| 35 | q[8] = std::sqrt(q[8]); |
| 36 | q[9] = std::tan(q[9]); |
| 37 | q[10] = std::tanh(q[10]); |
| 38 | q[11] = std::pow(q[11], q[19]); |
| 39 | q[12] = std::acos(q[12]); |
| 40 | q[13] = std::asin(q[13]); |
| 41 | q[14] = std::atan(q[14]); |
| 42 | q[15] = std::acosh(q[15]); |
| 43 | q[16] = std::asinh(q[16]); |
| 44 | q[17] = std::atanh(q[17]); |
| 45 | q[18] = std::proj(q[18]); |
| 46 | } |
| 47 | |
| 48 | int |
| 49 | main() |
| 50 | { |
| 51 | #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 52 | { |
| 53 | std::float16_t p[2] = {}; |
| 54 | std::complex<std::float16_t> q[20] = {}; |
| 55 | test_functions(p, q); |
| 56 | } |
| 57 | #endif |
| 58 | #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 59 | { |
| 60 | std::float32_t p[2] = {}; |
| 61 | std::complex<std::float32_t> q[20] = {}; |
| 62 | test_functions(p, q); |
| 63 | } |
| 64 | #endif |
| 65 | #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) |
| 66 | { |
| 67 | std::float64_t p[2] = {}; |
| 68 | std::complex<std::float64_t> q[20] = {}; |
| 69 | test_functions(p, q); |
| 70 | } |
| 71 | #endif |
| 72 | #if defined(__STDCPP_FLOAT128_T__) \ |
| 73 | && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ |
| 74 | || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) |
| 75 | { |
| 76 | std::float128_t p[2] = {}; |
| 77 | std::complex<std::float128_t> q[20] = {}; |
| 78 | test_functions(p, q); |
| 79 | } |
| 80 | #endif |
| 81 | #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) |
| 82 | { |
| 83 | std::bfloat16_t p[2] = {}; |
| 84 | std::complex<std::bfloat16_t> q[20] = {}; |
| 85 | test_functions(p, q); |
| 86 | } |
| 87 | #endif |
| 88 | } |