From 217bb9d2e8ce4f07a832b51ed630655807815758 Mon Sep 17 00:00:00 2001 From: paolo Date: Mon, 9 May 2011 15:38:21 +0000 Subject: [PATCH] 2011-05-09 Paolo Carlini PR libstdc++/48933 * include/c_global/cmath (acosh, asinh, atanh, cbrt, copysign, erf, erfc, exp2, expm1, fdim, fma, fmax, hypot, ilogb, lgamma, llrint, llround, log1p, log2, logb, lrint, lround, nearbyint, nextafter, nexttoward, remainder, remquo, rint, round, scalbln, scalbn, tgamma, trunc): Use __enable_if on the return type. * include/tr1/cmath: Likewise. * testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc: New. * testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173574 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 12 + libstdc++-v3/include/c_global/cmath | 259 ++++++++++----------- libstdc++-v3/include/tr1/cmath | 257 ++++++++++---------- .../headers/cmath/overloads_c++0x_neg.cc | 65 ++++++ .../tr1/8_c_compatibility/cmath/overloads_neg.cc | 66 ++++++ 5 files changed, 389 insertions(+), 270 deletions(-) create mode 100644 libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc create mode 100644 libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index af2f9b9a410..0ba711832dc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2011-05-09 Paolo Carlini + + PR libstdc++/48933 + * include/c_global/cmath (acosh, asinh, atanh, cbrt, copysign, + erf, erfc, exp2, expm1, fdim, fma, fmax, hypot, ilogb, lgamma, + llrint, llround, log1p, log2, logb, lrint, lround, nearbyint, + nextafter, nexttoward, remainder, remquo, rint, round, scalbln, + scalbn, tgamma, trunc): Use __enable_if on the return type. + * include/tr1/cmath: Likewise. + * testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc: New. + * testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc: Likewise. + 2011-05-07 François Dumont * include/debug/macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New. diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index a333eb583c0..e38ab9d6e21 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -1,7 +1,7 @@ // -*- C++ -*- C forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008, 2009, 2010 +// 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1120,12 +1120,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_acoshl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type acosh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return acosh(__type(__x)); - } + { return __builtin_acosh(__x); } inline float asinh(float __x) @@ -1136,12 +1134,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_asinhl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type asinh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return asinh(__type(__x)); - } + { return __builtin_asinh(__x); } inline float atanh(float __x) @@ -1152,12 +1148,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_atanhl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type atanh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return atanh(__type(__x)); - } + { return __builtin_atanh(__x); } inline float cbrt(float __x) @@ -1168,12 +1162,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_cbrtl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type cbrt(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return cbrt(__type(__x)); - } + { return __builtin_cbrt(__x); } inline float copysign(float __x, float __y) @@ -1184,7 +1176,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_copysignl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type copysign(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1200,12 +1196,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_erfl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type erf(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erf(__type(__x)); - } + { return __builtin_erf(__x); } inline float erfc(float __x) @@ -1216,12 +1210,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_erfcl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type erfc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erfc(__type(__x)); - } + { return __builtin_erfc(__x); } inline float exp2(float __x) @@ -1232,12 +1224,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_exp2l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type exp2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return exp2(__type(__x)); - } + { return __builtin_exp2(__x); } inline float expm1(float __x) @@ -1248,12 +1238,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_expm1l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type expm1(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return expm1(__type(__x)); - } + { return __builtin_expm1(__x); } inline float fdim(float __x, float __y) @@ -1264,7 +1252,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fdiml(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fdim(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1280,7 +1272,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fmal(__x, __y, __z); } template - inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + inline + typename __gnu_cxx::__promote_3< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value + && __is_arithmetic<_Vp>::__value, + _Tp>::__type, _Up, _Vp>::__type fma(_Tp __x, _Up __y, _Vp __z) { typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; @@ -1296,7 +1293,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fmaxl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fmax(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1312,7 +1313,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fminl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fmin(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1328,8 +1333,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_hypotl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - hypot(_Tp __x, _Up __y) + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type + hypot(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return hypot(__type(__x), __type(__y)); @@ -1344,12 +1353,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_ilogbl(__x); } template - inline int + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type ilogb(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return ilogb(__type(__x)); - } + { return __builtin_ilogb(__x); } inline float lgamma(float __x) @@ -1360,12 +1367,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lgammal(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type lgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lgamma(__type(__x)); - } + { return __builtin_lgamma(__x); } inline long long llrint(float __x) @@ -1376,12 +1381,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_llrintl(__x); } template - inline long long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type llrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llrint(__type(__x)); - } + { return __builtin_llrint(__x); } inline long long llround(float __x) @@ -1392,12 +1395,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_llroundl(__x); } template - inline long long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type llround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llround(__type(__x)); - } + { return __builtin_llround(__x); } inline float log1p(float __x) @@ -1408,12 +1409,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_log1pl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log1p(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log1p(__type(__x)); - } + { return __builtin_log1p(__x); } // DR 568. inline float @@ -1425,12 +1424,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_log2l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log2(__type(__x)); - } + { return __builtin_log2(__x); } inline float logb(float __x) @@ -1441,12 +1438,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_logbl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type logb(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return logb(__type(__x)); - } + { return __builtin_logb(__x); } inline long lrint(float __x) @@ -1457,12 +1452,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lrintl(__x); } template - inline long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type lrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lrint(__type(__x)); - } + { return __builtin_lrint(__x); } inline long lround(float __x) @@ -1473,12 +1466,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lroundl(__x); } template - inline long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type lround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lround(__type(__x)); - } + { return __builtin_lround(__x); } inline float nearbyint(float __x) @@ -1489,12 +1480,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nearbyintl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type nearbyint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nearbyint(__type(__x)); - } + { return __builtin_nearbyint(__x); } inline float nextafter(float __x, float __y) @@ -1505,7 +1494,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nextafterl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type nextafter(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1521,12 +1514,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nexttowardl(__x, __y); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type nexttoward(_Tp __x, long double __y) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nexttoward(__type(__x), __y); - } + { return __builtin_nexttoward(__x, __y); } inline float remainder(float __x, float __y) @@ -1537,7 +1528,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_remainderl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type remainder(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1553,7 +1548,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_remquol(__x, __y, __pquo); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type remquo(_Tp __x, _Up __y, int* __pquo) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -1569,12 +1568,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_rintl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type rint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return rint(__type(__x)); - } + { return __builtin_rint(__x); } inline float round(float __x) @@ -1585,12 +1582,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_roundl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type round(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return round(__type(__x)); - } + { return __builtin_round(__x); } inline float scalbln(float __x, long __ex) @@ -1601,12 +1596,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_scalblnl(__x, __ex); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type scalbln(_Tp __x, long __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbln(__type(__x), __ex); - } + { return __builtin_scalbln(__x, __ex); } inline float scalbn(float __x, int __ex) @@ -1617,12 +1610,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_scalbnl(__x, __ex); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type scalbn(_Tp __x, int __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbn(__type(__x), __ex); - } + { return __builtin_scalbn(__x, __ex); } inline float tgamma(float __x) @@ -1633,12 +1624,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_tgammal(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type tgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return tgamma(__type(__x)); - } + { return __builtin_tgamma(__x); } inline float trunc(float __x) @@ -1649,12 +1638,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_truncl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type trunc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return trunc(__type(__x)); - } + { return __builtin_trunc(__x); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index 21bdee88654..9ada6379a77 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -429,12 +429,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_acoshl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type acosh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return acosh(__type(__x)); - } + { return __builtin_acosh(__x); } using std::asin; @@ -447,12 +445,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_asinhl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type asinh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return asinh(__type(__x)); - } + { return __builtin_asinh(__x); } using std::atan; using std::atan2; @@ -466,12 +462,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_atanhl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type atanh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return atanh(__type(__x)); - } + { return __builtin_atanh(__x); } inline float cbrt(float __x) @@ -482,12 +476,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_cbrtl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type cbrt(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return cbrt(__type(__x)); - } + { return __builtin_cbrt(__x); } using std::ceil; @@ -500,7 +492,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_copysignl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type copysign(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -519,12 +515,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_erfl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type erf(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erf(__type(__x)); - } + { return __builtin_erf(__x); } inline float erfc(float __x) @@ -535,12 +529,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_erfcl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type erfc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erfc(__type(__x)); - } + { return __builtin_erfc(__x); } using std::exp; @@ -553,12 +545,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_exp2l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type exp2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return exp2(__type(__x)); - } + { return __builtin_exp2(__x); } inline float expm1(float __x) @@ -569,12 +559,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_expm1l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type expm1(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return expm1(__type(__x)); - } + { return __builtin_expm1(__x); } // Note: we deal with fabs in a special way, because an using std::fabs // would bring in also the overloads for complex types, which in C++0x @@ -604,7 +592,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fdiml(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fdim(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -622,7 +614,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fmal(__x, __y, __z); } template - inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + inline + typename __gnu_cxx::__promote_3< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value + && __is_arithmetic<_Vp>::__value, + _Tp>::__type, _Up, _Vp>::__type fma(_Tp __x, _Up __y, _Vp __z) { typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; @@ -638,7 +635,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fmaxl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fmax(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -654,7 +655,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_fminl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type fmin(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -673,11 +678,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_hypotl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - hypot(_Tp __x, _Up __y) + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type + hypot(_Tp __y, _Up __x) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return hypot(__type(__x), __type(__y)); + return hypot(__type(__y), __type(__x)); } inline int @@ -689,12 +698,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_ilogbl(__x); } template - inline int + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type ilogb(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return ilogb(__type(__x)); - } + { return __builtin_ilogb(__x); } using std::ldexp; @@ -707,12 +714,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lgammal(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type lgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lgamma(__type(__x)); - } + { return __builtin_lgamma(__x); } inline long long llrint(float __x) @@ -723,12 +728,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_llrintl(__x); } template - inline long long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type llrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llrint(__type(__x)); - } + { return __builtin_llrint(__x); } inline long long llround(float __x) @@ -739,12 +742,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_llroundl(__x); } template - inline long long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type llround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llround(__type(__x)); - } + { return __builtin_llround(__x); } using std::log; using std::log10; @@ -758,12 +759,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_log1pl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log1p(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log1p(__type(__x)); - } + { return __builtin_log1p(__x); } // DR 568. inline float @@ -775,12 +774,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_log2l(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log2(__type(__x)); - } + { return __builtin_log2(__x); } inline float logb(float __x) @@ -791,11 +788,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_logbl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type logb(_Tp __x) { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return logb(__type(__x)); + return __builtin_logb(__x); } inline long @@ -807,12 +804,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lrintl(__x); } template - inline long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type lrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lrint(__type(__x)); - } + { return __builtin_lrint(__x); } inline long lround(float __x) @@ -823,12 +818,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_lroundl(__x); } template - inline long + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type lround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lround(__type(__x)); - } + { return __builtin_lround(__x); } inline float nearbyint(float __x) @@ -839,12 +832,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nearbyintl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type nearbyint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nearbyint(__type(__x)); - } + { return __builtin_nearbyint(__x); } inline float nextafter(float __x, float __y) @@ -855,7 +846,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nextafterl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type nextafter(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -871,12 +866,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_nexttowardl(__x, __y); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type nexttoward(_Tp __x, long double __y) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nexttoward(__type(__x), __y); - } + { return __builtin_nexttoward(__x, __y); } // DR 550. What should the return type of pow(float,int) be? // NB: C++0x and TR1 != C++03. @@ -891,7 +884,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_remainderl(__x, __y); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type remainder(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -907,7 +904,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_remquol(__x, __y, __pquo); } template - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + inline + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type remquo(_Tp __x, _Up __y, int* __pquo) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; @@ -923,12 +924,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_rintl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type rint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return rint(__type(__x)); - } + { return __builtin_rint(__x); } inline float round(float __x) @@ -939,12 +938,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_roundl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type round(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return round(__type(__x)); - } + { return __builtin_round(__x); } inline float scalbln(float __x, long __ex) @@ -955,12 +952,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_scalblnl(__x, __ex); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type scalbln(_Tp __x, long __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbln(__type(__x), __ex); - } + { return __builtin_scalbln(__x, __ex); } inline float scalbn(float __x, int __ex) @@ -971,12 +966,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_scalbnl(__x, __ex); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type scalbn(_Tp __x, int __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbn(__type(__x), __ex); - } + { return __builtin_scalbn(__x, __ex); } using std::sin; using std::sinh; @@ -993,12 +986,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_tgammal(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type tgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return tgamma(__type(__x)); - } + { return __builtin_tgamma(__x); } inline float trunc(float __x) @@ -1009,12 +1000,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_truncl(__x); } template - inline typename __gnu_cxx::__promote<_Tp>::__type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type trunc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return trunc(__type(__x)); - } + { return __builtin_trunc(__x); } #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc new file mode 100644 index 00000000000..2d8862ead15 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 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 +// . + +#include + +// libstdc++/48933 + +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +struct Foo { }; + +template Foo std::atan2(Foo, Foo); // { dg-error "not match" } +template Foo std::acosh(Foo); // { dg-error "not match" } +template Foo std::asinh(Foo); // { dg-error "not match" } +template Foo std::atanh(Foo); // { dg-error "not match" } +template Foo std::cbrt(Foo); // { dg-error "not match" } +template Foo std::copysign(Foo, Foo); // { dg-error "not match" } +template Foo std::erf(Foo); // { dg-error "not match" } +template Foo std::erfc(Foo); // { dg-error "not match" } +template Foo std::exp2(Foo); // { dg-error "not match" } +template Foo std::expm1(Foo); // { dg-error "not match" } +template Foo std::fdim(Foo, Foo); // { dg-error "not match" } +template Foo std::fma(Foo(), Foo(), Foo()); // { dg-error "not match" } +template Foo std::fmax(Foo, Foo); // { dg-error "not match" } +template Foo std::fmin(Foo, Foo); // { dg-error "not match" } +template Foo std::hypot(Foo, Foo); // { dg-error "not match" } +template int std::ilogb(Foo); // { dg-error "not match" } +template Foo std::lgamma(Foo); // { dg-error "not match" } +template long long std::llrint(Foo); // { dg-error "not match" } +template long long std::llround(Foo); // { dg-error "not match" } +template Foo std::log1p(Foo); // { dg-error "not match" } +template Foo std::log2(Foo); // { dg-error "not match" } +template Foo std::logb(Foo); // { dg-error "not match" } +template long std::lrint(Foo); // { dg-error "not match" } +template long std::lround(Foo); // { dg-error "not match" } +template Foo std::nearbyint(Foo); // { dg-error "not match" } +template Foo std::nextafter(Foo, Foo); // { dg-error "not match" } +template Foo std::nexttoward(Foo, long double); // { dg-error "not match" } +template Foo std::remainder(Foo, Foo); // { dg-error "not match" } +template Foo std::remquo(Foo, Foo, int*); // { dg-error "not match" } +template Foo std::rint(Foo); // { dg-error "not match" } +template Foo std::round(Foo); // { dg-error "not match" } +template Foo std::scalbln(Foo, long); // { dg-error "not match" } +template Foo std::scalbn(Foo, int); // { dg-error "not match" } +template Foo std::tgamma(Foo); // { dg-error "not match" } +template Foo std::trunc(Foo); // { dg-error "not match" } + +#endif diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc new file mode 100644 index 00000000000..174a81dc5f9 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc @@ -0,0 +1,66 @@ +// { dg-do compile } + +// Copyright (C) 2011 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 +// . + +// 8.16.4 Additional overloads + +#include + +// libstdc++/48933 + +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +struct Foo { }; + +template Foo std::tr1::atan2(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::acosh(Foo); // { dg-error "not match" } +template Foo std::tr1::asinh(Foo); // { dg-error "not match" } +template Foo std::tr1::atanh(Foo); // { dg-error "not match" } +template Foo std::tr1::cbrt(Foo); // { dg-error "not match" } +template Foo std::tr1::copysign(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::erf(Foo); // { dg-error "not match" } +template Foo std::tr1::erfc(Foo); // { dg-error "not match" } +template Foo std::tr1::exp2(Foo); // { dg-error "not match" } +template Foo std::tr1::expm1(Foo); // { dg-error "not match" } +template Foo std::tr1::fdim(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::fma(Foo(), Foo(), Foo()); // { dg-error "not match" } +template Foo std::tr1::fmax(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::fmin(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::hypot(Foo, Foo); // { dg-error "not match" } +template int std::tr1::ilogb(Foo); // { dg-error "not match" } +template Foo std::tr1::lgamma(Foo); // { dg-error "not match" } +template long long std::tr1::llrint(Foo); // { dg-error "not match" } +template long long std::tr1::llround(Foo); // { dg-error "not match" } +template Foo std::tr1::log1p(Foo); // { dg-error "not match" } +template Foo std::tr1::log2(Foo); // { dg-error "not match" } +template Foo std::tr1::logb(Foo); // { dg-error "not match" } +template long std::tr1::lrint(Foo); // { dg-error "not match" } +template long std::tr1::lround(Foo); // { dg-error "not match" } +template Foo std::tr1::nearbyint(Foo); // { dg-error "not match" } +template Foo std::tr1::nextafter(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::nexttoward(Foo, long double); // { dg-error "not match" } +template Foo std::tr1::remainder(Foo, Foo); // { dg-error "not match" } +template Foo std::tr1::remquo(Foo, Foo, int*); // { dg-error "not match" } +template Foo std::tr1::rint(Foo); // { dg-error "not match" } +template Foo std::tr1::round(Foo); // { dg-error "not match" } +template Foo std::tr1::scalbln(Foo, long); // { dg-error "not match" } +template Foo std::tr1::scalbn(Foo, int); // { dg-error "not match" } +template Foo std::tr1::tgamma(Foo); // { dg-error "not match" } +template Foo std::tr1::trunc(Foo); // { dg-error "not match" } + +#endif -- 2.11.0