Commit 86f66562 by Jonathan Wakely Committed by Jonathan Wakely

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 <cmath> 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 <tr1/cmath> 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
<tr1/cmath> 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
parent 6c072e21
2018-05-03 Jonathan Wakely <jwakely@redhat.com>
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.
......
......@@ -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 <tr1/beta_function.tcc>
#include <tr1/ell_integral.tcc>
#include <tr1/exp_integral.tcc>
#include <tr1/hypergeometric.tcc>
#include <tr1/legendre_function.tcc>
#include <tr1/modified_bessel_func.tcc>
#include <tr1/poly_hermite.tcc>
......@@ -1372,23 +1363,6 @@ namespace tr1
}
inline float
conf_hypergf(float __a, float __c, float __x)
{ return __detail::__conf_hyperg<float>(__a, __c, __x); }
inline long double
conf_hypergl(long double __a, long double __c, long double __x)
{ return __detail::__conf_hyperg<long double>(__a, __c, __x); }
/// 5.2.1.7 Confluent hypergeometric functions.
template<typename _Tpa, typename _Tpc, typename _Tp>
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<float>(__nu, __x); }
......@@ -1542,23 +1516,6 @@ namespace tr1
}
inline float
hypergf(float __a, float __b, float __c, float __x)
{ return __detail::__hyperg<float>(__a, __b, __c, __x); }
inline long double
hypergl(long double __a, long double __b, long double __c, long double __x)
{ return __detail::__hyperg<long double>(__a, __b, __c, __x); }
/// 5.2.1.17 Hypergeometric functions.
template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
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<float>(__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 <bits/stl_algobase.h>
#include <limits>
#include <tr1/type_traits>
#include <tr1/hypergeometric.tcc>
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<float>(__a, __c, __x); }
inline long double
conf_hypergl(long double __a, long double __c, long double __x)
{ return __detail::__conf_hyperg<long double>(__a, __c, __x); }
/// 5.2.1.7 Confluent hypergeometric functions.
template<typename _Tpa, typename _Tpc, typename _Tp>
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<float>(__a, __b, __c, __x); }
inline long double
hypergl(long double __a, long double __b, long double __c, long double __x)
{ return __detail::__hyperg<long double>(__a, __b, __c, __x); }
/// 5.2.1.17 Hypergeometric functions.
template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
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
// 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
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++17" }
// { dg-do compile { target c++17 } }
#include <tr1/cmath>
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);
}
// 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
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++17" }
// { dg-do compile { target c++17 } }
#include <tr1/cmath>
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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment