From f8571e51501fcc76d7e8cad4b4e1d281c57d8008 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 3 Aug 2016 16:54:13 +0100 Subject: [PATCH] Enable Mathematical Special Functions for C++17 * include/bits/c++config (_GLIBCXX_USE_STD_SPEC_FUNCS): Define for C++17, or for C++11/C++14 when __STDCPP_WANT_MATH_SPEC_FUNCS__ is true. * include/bits/specfun.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]: Don't do #error for C++17. * include/c_global/cmath: Check _GLIBCXX_USE_STD_SPEC_FUNCS instead of __STDCPP_WANT_MATH_SPEC_FUNCS__. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/cmath: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/poly_laguerre.tcc: Likewise. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/special_function_util.h: Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++17.cc: New. From-SVN: r239081 --- libstdc++-v3/ChangeLog | 22 ++++ libstdc++-v3/include/bits/c++config | 7 ++ libstdc++-v3/include/bits/specfun.h | 2 +- libstdc++-v3/include/c_global/cmath | 2 +- libstdc++-v3/include/tr1/bessel_function.tcc | 4 +- libstdc++-v3/include/tr1/beta_function.tcc | 4 +- libstdc++-v3/include/tr1/cmath | 6 +- libstdc++-v3/include/tr1/ell_integral.tcc | 4 +- libstdc++-v3/include/tr1/exp_integral.tcc | 4 +- libstdc++-v3/include/tr1/gamma.tcc | 4 +- libstdc++-v3/include/tr1/hypergeometric.tcc | 4 +- .../include/tr1/legendre_function.tcc | 4 +- .../include/tr1/modified_bessel_func.tcc | 4 +- libstdc++-v3/include/tr1/poly_hermite.tcc | 4 +- libstdc++-v3/include/tr1/poly_laguerre.tcc | 4 +- libstdc++-v3/include/tr1/riemann_zeta.tcc | 4 +- .../include/tr1/special_function_util.h | 4 +- .../headers/cmath/functions_std_c++17.cc | 111 ++++++++++++++++++ 18 files changed, 169 insertions(+), 29 deletions(-) create mode 100644 libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c6b5ec3d3d1..d6082300e32 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,27 @@ 2016-08-03 Jonathan Wakely + * include/bits/c++config (_GLIBCXX_USE_STD_SPEC_FUNCS): Define for + C++17, or for C++11/C++14 when __STDCPP_WANT_MATH_SPEC_FUNCS__ is + true. + * include/bits/specfun.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]: Don't + do #error for C++17. + * include/c_global/cmath: Check _GLIBCXX_USE_STD_SPEC_FUNCS instead + of __STDCPP_WANT_MATH_SPEC_FUNCS__. + * include/tr1/bessel_function.tcc: Likewise. + * include/tr1/beta_function.tcc: Likewise. + * include/tr1/cmath: Likewise. + * include/tr1/ell_integral.tcc: Likewise. + * include/tr1/exp_integral.tcc: Likewise. + * include/tr1/gamma.tcc: Likewise. + * include/tr1/hypergeometric.tcc: Likewise. + * include/tr1/legendre_function.tcc: Likewise. + * include/tr1/modified_bessel_func.tcc: Likewise. + * include/tr1/poly_hermite.tcc: Likewise. + * include/tr1/poly_laguerre.tcc: Likewise. + * include/tr1/riemann_zeta.tcc: Likewise. + * include/tr1/special_function_util.h: Likewise. + * testsuite/26_numerics/headers/cmath/functions_std_c++17.cc: New. + * include/std/type_traits (has_trivial_default_constructor): Remove. (has_trivial_copy_constructor, has_trivial_copy_assign): Likewise. * testsuite/20_util/has_trivial_copy_assign/requirements/ diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 46256074251..8d2c3612afd 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -532,6 +532,13 @@ namespace std #define _GLIBCXX_TXN_SAFE_DYN #endif +#if __cplusplus > 201402L +// In C++17 mathematical special functions are in namespace std. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 +// For C++11 and C++14 they are in namespace std when requested. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. diff --git a/libstdc++-v3/include/bits/specfun.h b/libstdc++-v3/include/bits/specfun.h index 9f7bb87d2d3..93e18522d58 100644 --- a/libstdc++-v3/include/bits/specfun.h +++ b/libstdc++-v3/include/bits/specfun.h @@ -38,7 +38,7 @@ #define __cpp_lib_math_special_functions 201603L -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0 +#if __cplusplus <= 201403L && __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0 # error include and define __STDCPP_WANT_MATH_SPEC_FUNCS__ #endif diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index 6a24ebfec5b..6db9deeb996 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -1790,7 +1790,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1 +#if _GLIBCXX_USE_STD_SPEC_FUNCS # include #endif diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc b/libstdc++-v3/include/tr1/bessel_function.tcc index a2655d88b99..692f6da34f5 100644 --- a/libstdc++-v3/include/tr1/bessel_function.tcc +++ b/libstdc++-v3/include/tr1/bessel_function.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -630,7 +630,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/beta_function.tcc b/libstdc++-v3/include/tr1/beta_function.tcc index 76f5093cbec..34b22d4ea21 100644 --- a/libstdc++-v3/include/tr1/beta_function.tcc +++ b/libstdc++-v3/include/tr1/beta_function.tcc @@ -48,7 +48,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -199,7 +199,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index 48466a02854..7f77a2b01ad 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -1141,7 +1141,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } } -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS namespace std _GLIBCXX_VISIBILITY(default) { @@ -1254,7 +1254,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } } -#else // ! __STDCPP_WANT_MATH_SPEC_FUNCS__ +#else // ! _GLIBCXX_USE_STD_SPEC_FUNCS #include #include @@ -1683,6 +1683,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } } -#endif // __STDCPP_WANT_MATH_SPEC_FUNCS__ +#endif // _GLIBCXX_USE_STD_SPEC_FUNCS #endif // _GLIBCXX_TR1_CMATH diff --git a/libstdc++-v3/include/tr1/ell_integral.tcc b/libstdc++-v3/include/tr1/ell_integral.tcc index 9a60ba3b00a..c7bfe16fb78 100644 --- a/libstdc++-v3/include/tr1/ell_integral.tcc +++ b/libstdc++-v3/include/tr1/ell_integral.tcc @@ -44,7 +44,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -748,7 +748,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/exp_integral.tcc b/libstdc++-v3/include/tr1/exp_integral.tcc index ee7cdad6d91..f5b30941ee4 100644 --- a/libstdc++-v3/include/tr1/exp_integral.tcc +++ b/libstdc++-v3/include/tr1/exp_integral.tcc @@ -49,7 +49,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -525,7 +525,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/gamma.tcc b/libstdc++-v3/include/tr1/gamma.tcc index 2c84b7521a3..3eb78455823 100644 --- a/libstdc++-v3/include/tr1/gamma.tcc +++ b/libstdc++-v3/include/tr1/gamma.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -470,7 +470,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } // namespace std diff --git a/libstdc++-v3/include/tr1/hypergeometric.tcc b/libstdc++-v3/include/tr1/hypergeometric.tcc index 77fb78d058b..1c46f4ac2b4 100644 --- a/libstdc++-v3/include/tr1/hypergeometric.tcc +++ b/libstdc++-v3/include/tr1/hypergeometric.tcc @@ -43,7 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -777,7 +777,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/legendre_function.tcc b/libstdc++-v3/include/tr1/legendre_function.tcc index d5f20223b31..1980ebbf0c1 100644 --- a/libstdc++-v3/include/tr1/legendre_function.tcc +++ b/libstdc++-v3/include/tr1/legendre_function.tcc @@ -48,7 +48,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -305,7 +305,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/modified_bessel_func.tcc b/libstdc++-v3/include/tr1/modified_bessel_func.tcc index 0162727b34c..5278fb2778e 100644 --- a/libstdc++-v3/include/tr1/modified_bessel_func.tcc +++ b/libstdc++-v3/include/tr1/modified_bessel_func.tcc @@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -433,7 +433,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/poly_hermite.tcc b/libstdc++-v3/include/tr1/poly_hermite.tcc index a5a6bcbd8d0..7123e11e7f1 100644 --- a/libstdc++-v3/include/tr1/poly_hermite.tcc +++ b/libstdc++-v3/include/tr1/poly_hermite.tcc @@ -41,7 +41,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -123,7 +123,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/poly_laguerre.tcc b/libstdc++-v3/include/tr1/poly_laguerre.tcc index 6c757e40c11..a51d1dcc9c1 100644 --- a/libstdc++-v3/include/tr1/poly_laguerre.tcc +++ b/libstdc++-v3/include/tr1/poly_laguerre.tcc @@ -43,7 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -321,7 +321,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/riemann_zeta.tcc b/libstdc++-v3/include/tr1/riemann_zeta.tcc index f411b20e611..714bf9f1450 100644 --- a/libstdc++-v3/include/tr1/riemann_zeta.tcc +++ b/libstdc++-v3/include/tr1/riemann_zeta.tcc @@ -46,7 +46,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS # define _GLIBCXX_MATH_NS ::std #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 @@ -435,7 +435,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail #undef _GLIBCXX_MATH_NS -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/include/tr1/special_function_util.h b/libstdc++-v3/include/tr1/special_function_util.h index 2b8cf377e4e..93f09cea805 100644 --- a/libstdc++-v3/include/tr1/special_function_util.h +++ b/libstdc++-v3/include/tr1/special_function_util.h @@ -38,7 +38,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { -#if __STDCPP_WANT_MATH_SPEC_FUNCS__ +#if _GLIBCXX_USE_STD_SPEC_FUNCS #elif defined(_GLIBCXX_TR1_CMATH) namespace tr1 { @@ -133,7 +133,7 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace __detail -#if ! __STDCPP_WANT_MATH_SPEC_FUNCS__ && defined(_GLIBCXX_TR1_CMATH) +#if ! _GLIBCXX_USE_STD_SPEC_FUNCS && defined(_GLIBCXX_TR1_CMATH) } // namespace tr1 #endif } diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc new file mode 100644 index 00000000000..481b659f8c2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++17.cc @@ -0,0 +1,111 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +#include + +namespace gnu +{ + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + + using std::assoc_laguerre; + using std::assoc_laguerref; + using std::assoc_laguerrel; + using std::assoc_legendre; + using std::assoc_legendref; + using std::assoc_legendrel; + using std::beta; + using std::betaf; + using std::betal; + using std::comp_ellint_1; + using std::comp_ellint_1f; + using std::comp_ellint_1l; + using std::comp_ellint_2; + using std::comp_ellint_2f; + using std::comp_ellint_2l; + using std::comp_ellint_3; + using std::comp_ellint_3f; + using std::comp_ellint_3l; + using std::cyl_bessel_i; + using std::cyl_bessel_if; + using std::cyl_bessel_il; + using std::cyl_bessel_j; + using std::cyl_bessel_jf; + using std::cyl_bessel_jl; + using std::cyl_bessel_k; + using std::cyl_bessel_kf; + using std::cyl_bessel_kl; + using std::cyl_neumann; + using std::cyl_neumannf; + using std::cyl_neumannl; + using std::ellint_1; + using std::ellint_1f; + using std::ellint_1l; + using std::ellint_2; + using std::ellint_2f; + using std::ellint_2l; + using std::ellint_3; + using std::ellint_3f; + using std::ellint_3l; + using std::expint; + using std::expintf; + using std::expintl; + using std::hermite; + using std::hermitef; + using std::hermitel; + using std::laguerre; + using std::laguerref; + using std::laguerrel; + using std::legendre; + using std::legendref; + using std::legendrel; + using std::riemann_zeta; + using std::riemann_zetaf; + using std::riemann_zetal; + using std::sph_bessel; + using std::sph_besself; + using std::sph_bessell; + using std::sph_legendre; + using std::sph_legendref; + using std::sph_legendrel; + using std::sph_neumann; + using std::sph_neumannf; + using std::sph_neumannl; +} -- 2.30.2