From 86f66562b73c61ae927b301d5dd907d7564c2e3f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 3 May 2018 23:58:43 +0100 Subject: [PATCH] PR libstdc++/82644 define TR1 hypergeometric functions in strict modes Following a recent change for PR 82644 the non-standard hypergeomtric functions are not defined by when __STRICT_ANSI__ is defined (e.g. for -std=c++17, or -std=c++14 -D__STDCPP_WANT_MATH_SPEC_FUNCS__). That caused errors in because the using-declarations for tr1::hyperg et al are invalid in strict modes. The solution is to define the TR1 hypergeometric functions inline in if __STRICT_ANSI__ is defined. PR libstdc++/82644 * include/tr1/cmath [__STRICT_ANSI__] (hypergf, hypergl, hyperg): Use inline definitions instead of using-declarations. [__STRICT_ANSI__] (conf_hypergf, conf_hypergl, conf_hyperg): Likewise. * testsuite/tr1/5_numerical_facilities/special_functions/ 07_conf_hyperg/compile_cxx17.cc: New. * testsuite/tr1/5_numerical_facilities/special_functions/ 17_hyperg/compile_cxx17.cc: New. From-SVN: r259912 --- libstdc++-v3/ChangeLog | 9 ++ libstdc++-v3/include/tr1/cmath | 116 +++++++++++------- .../07_conf_hyperg/compile_cxx17.cc | 31 +++++ .../17_hyperg/compile_cxx17.cc | 31 +++++ 4 files changed, 144 insertions(+), 43 deletions(-) create mode 100644 libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc create mode 100644 libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 823d284d1d4..ed616dfa8f1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 2018-05-03 Jonathan Wakely + PR libstdc++/82644 + * include/tr1/cmath [__STRICT_ANSI__] (hypergf, hypergl, hyperg): Use + inline definitions instead of using-declarations. + [__STRICT_ANSI__] (conf_hypergf, conf_hypergl, conf_hyperg): Likewise. + * testsuite/tr1/5_numerical_facilities/special_functions/ + 07_conf_hyperg/compile_cxx17.cc: New. + * testsuite/tr1/5_numerical_facilities/special_functions/ + 17_hyperg/compile_cxx17.cc: New. + PR libstdc++/84769 * include/std/variant (visit): Qualify std::get call. diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index d1df3804120..c07dd5c73a5 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -1160,10 +1160,6 @@ namespace tr1 using std::comp_ellint_3l; using std::comp_ellint_3; - using __gnu_cxx::conf_hypergf; - using __gnu_cxx::conf_hypergl; - using __gnu_cxx::conf_hyperg; - using std::cyl_bessel_if; using std::cyl_bessel_il; using std::cyl_bessel_i; @@ -1200,10 +1196,6 @@ namespace tr1 using std::hermitel; using std::hermite; - using __gnu_cxx::hypergf; - using __gnu_cxx::hypergl; - using __gnu_cxx::hyperg; - using std::laguerref; using std::laguerrel; using std::laguerre; @@ -1246,7 +1238,6 @@ _GLIBCXX_END_NAMESPACE_VERSION #include #include #include -#include #include #include #include @@ -1371,23 +1362,6 @@ namespace tr1 return __detail::__comp_ellint_3<__type>(__k, __nu); } - inline float - conf_hypergf(float __a, float __c, float __x) - { return __detail::__conf_hyperg(__a, __c, __x); } - - inline long double - conf_hypergl(long double __a, long double __c, long double __x) - { return __detail::__conf_hyperg(__a, __c, __x); } - - /// 5.2.1.7 Confluent hypergeometric functions. - template - inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type - conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x) - { - typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type; - return __detail::__conf_hyperg<__type>(__a, __c, __x); - } - inline float cyl_bessel_if(float __nu, float __x) { return __detail::__cyl_bessel_i(__nu, __x); } @@ -1541,23 +1515,6 @@ namespace tr1 return __detail::__poly_hermite<__type>(__n, __x); } - inline float - hypergf(float __a, float __b, float __c, float __x) - { return __detail::__hyperg(__a, __b, __c, __x); } - - inline long double - hypergl(long double __a, long double __b, long double __c, long double __x) - { return __detail::__hyperg(__a, __b, __c, __x); } - - /// 5.2.1.17 Hypergeometric functions. - template - inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type - hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x) - { - typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type; - return __detail::__hyperg<__type>(__a, __b, __c, __x); - } - inline float laguerref(unsigned int __n, float __x) { return __detail::__laguerre(__n, __x); } @@ -1668,4 +1625,77 @@ namespace tr1 _GLIBCXX_END_NAMESPACE_VERSION } // namespace std +#if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__) +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace tr1 +{ + using __gnu_cxx::conf_hypergf; + using __gnu_cxx::conf_hypergl; + using __gnu_cxx::conf_hyperg; + + using __gnu_cxx::hypergf; + using __gnu_cxx::hypergl; + using __gnu_cxx::hyperg; +} // namespace tr1 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)) + +#include +#include +#include + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace tr1 +{ + inline float + conf_hypergf(float __a, float __c, float __x) + { return __detail::__conf_hyperg(__a, __c, __x); } + + inline long double + conf_hypergl(long double __a, long double __c, long double __x) + { return __detail::__conf_hyperg(__a, __c, __x); } + + /// 5.2.1.7 Confluent hypergeometric functions. + template + inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type + conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type; + return __detail::__conf_hyperg<__type>(__a, __c, __x); + } + + inline float + hypergf(float __a, float __b, float __c, float __x) + { return __detail::__hyperg(__a, __b, __c, __x); } + + inline long double + hypergl(long double __a, long double __b, long double __c, long double __x) + { return __detail::__hyperg(__a, __b, __c, __x); } + + /// 5.2.1.17 Hypergeometric functions. + template + inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type + hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type; + return __detail::__hyperg<__type>(__a, __b, __c, __x); + } + +} // namespace tr1 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__) + #endif // _GLIBCXX_TR1_CMATH diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc new file mode 100644 index 00000000000..f0b0f96af27 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/07_conf_hyperg/compile_cxx17.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2018 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=c++17" } +// { dg-do compile { target c++17 } } + +#include + +void +test01() +{ + // For C++17 most TR1 special functions re-use the C++17 functions + // in namespace std, but in strict -std=c++17 mode the hypergeometric + // functions are not defined in namespace std. This test ensures they + // are still available in namespace std::tr1. + (void) std::tr1::conf_hyperg(1.0, 2.0, 3.0); +} diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc new file mode 100644 index 00000000000..048328b6c00 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/compile_cxx17.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2018 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=c++17" } +// { dg-do compile { target c++17 } } + +#include + +void +test01() +{ + // For C++17 most TR1 special functions re-use the C++17 functions + // in namespace std, but in strict -std=c++17 mode the hypergeometric + // functions are not defined in namespace std. This test ensures they + // are still available in namespace std::tr1. + (void) std::tr1::hyperg(1.0, 2.0, 3.0, 4.0); +} -- 2.30.2