summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-11-26 18:24:54 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-11-26 18:24:54 +0000
commit64f91bdc6c66b1bc7b832cb4cb296ed424f1867c (patch)
tree253a8e89ce7d5885ccd6131af8d42a636a2d28a8
parentb4ac3759f7a68557a5c75bf2eab95a3eb30eab4f (diff)
downloadgcc-64f91bdc6c66b1bc7b832cb4cb296ed424f1867c.tar.gz
2007-11-26 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/25913 * include/c_std/cmath (std::fpclassify, isfinite, isinf, isnan, isnormal, signbit, isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered): Guard with __enable_if and forward with __promote. * include/c_global/cmath: Likewise. * testsuite/26_numerics/headers/cmath/25913.cc: New. * include/c_std/cmath (__gnu_cxx::__capture_isfinite, __capture_isinf, __capture_isnan, __capture_isnormal, __capture_signbit, __capture_isgreater, __capture_isgreaterequal, __capture_isless, __capture_islessequal, __capture_islessgreater, __capture_isunordered): Remove. (std::isfinite, isinf, isnan, isnormal, signbit, isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered): Forward to the corresponding builtin. * include/c_global/cmath: Likewise. * include/c_global/cmath (std::atan2, pow): Guard with __enable_if. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130443 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog22
-rw-r--r--libstdc++-v3/include/c_global/cmath163
-rw-r--r--libstdc++-v3/include/c_std/cmath154
-rw-r--r--libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc47
4 files changed, 237 insertions, 149 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fe86a804690..fab7ed50c2f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,25 @@
+2007-11-26 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/25913
+ * include/c_std/cmath (std::fpclassify, isfinite, isinf, isnan,
+ isnormal, signbit, isgreater, isgreaterequal, isless, islessequal,
+ islessgreater, isunordered): Guard with __enable_if and forward
+ with __promote.
+ * include/c_global/cmath: Likewise.
+ * testsuite/26_numerics/headers/cmath/25913.cc: New.
+
+ * include/c_std/cmath (__gnu_cxx::__capture_isfinite,
+ __capture_isinf, __capture_isnan, __capture_isnormal,
+ __capture_signbit, __capture_isgreater, __capture_isgreaterequal,
+ __capture_isless, __capture_islessequal, __capture_islessgreater,
+ __capture_isunordered): Remove.
+ (std::isfinite, isinf, isnan, isnormal, signbit, isgreater,
+ isgreaterequal, isless, islessequal, islessgreater, isunordered):
+ Forward to the corresponding builtin.
+ * include/c_global/cmath: Likewise.
+
+ * include/c_global/cmath (std::atan2, pow): Guard with __enable_if.
+
2007-11-25 Paolo Carlini <pcarlini@suse.de>
* include/tr1_impl/unordered_map
diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath
index e37f4e8fb0f..f7be4d0fd0a 100644
--- a/libstdc++-v3/include/c_global/cmath
+++ b/libstdc++-v3/include/c_global/cmath
@@ -166,7 +166,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __builtin_atan2l(__y, __x); }
template<typename _Tp, typename _Up>
- 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
atan2(_Tp __y, _Up __x)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
@@ -377,7 +381,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __builtin_powil(__x, __n); }
template<typename _Tp, typename _Up>
- 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
pow(_Tp __x, _Up __y)
{
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
@@ -478,55 +486,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
inline int
__capture_fpclassify(_Tp __f) { return fpclassify(__f); }
- template<typename _Tp>
- inline int
- __capture_isfinite(_Tp __f) { return isfinite(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isinf(_Tp __f) { return isinf(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isnan(_Tp __f) { return isnan(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isnormal(_Tp __f) { return isnormal(__f); }
-
- template<typename _Tp>
- inline int
- __capture_signbit(_Tp __f) { return signbit(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isgreater(_Tp __f1, _Tp __f2)
- { return isgreater(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isgreaterequal(_Tp __f1, _Tp __f2)
- { return isgreaterequal(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_islessequal(_Tp __f1, _Tp __f2)
- { return islessequal(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_islessgreater(_Tp __f1, _Tp __f2)
- { return islessgreater(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isunordered(_Tp __f1, _Tp __f2)
- { return isunordered(__f1, __f2); }
-
_GLIBCXX_END_NAMESPACE
// Only undefine the C99 FP macros, if actually captured for namespace movement
@@ -546,58 +505,112 @@ _GLIBCXX_END_NAMESPACE
_GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
- inline int
- fpclassify(_Tp __f) { return ::__gnu_cxx::__capture_fpclassify(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ fpclassify(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return ::__gnu_cxx::__capture_fpclassify(__type(__f));
+ }
template<typename _Tp>
- inline int
- isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isfinite(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isfinite(__type(__f));
+ }
template<typename _Tp>
- inline int
- isinf(_Tp __f) { return ::__gnu_cxx::__capture_isinf(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isinf(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isinf(__type(__f));
+ }
template<typename _Tp>
- inline int
- isnan(_Tp __f) { return ::__gnu_cxx::__capture_isnan(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isnan(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isnan(__type(__f));
+ }
template<typename _Tp>
- inline int
- isnormal(_Tp __f) { return ::__gnu_cxx::__capture_isnormal(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isnormal(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isnormal(__type(__f));
+ }
template<typename _Tp>
- inline int
- signbit(_Tp __f) { return ::__gnu_cxx::__capture_signbit(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ signbit(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_signbit(__type(__f));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isgreater(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isgreater(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isgreater(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isgreaterequal(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isgreaterequal(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isgreaterequal(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isless(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isless(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isless(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
islessequal(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_islessequal(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_islessequal(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
islessgreater(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_islessgreater(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_islessgreater(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isunordered(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isunordered(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isunordered(__type(__f1), __type(__f2));
+ }
_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/include/c_std/cmath b/libstdc++-v3/include/c_std/cmath
index 897290ac089..52c1d2a3505 100644
--- a/libstdc++-v3/include/c_std/cmath
+++ b/libstdc++-v3/include/c_std/cmath
@@ -1,6 +1,7 @@
// -*- C++ -*- C forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -467,55 +468,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
inline int
__capture_fpclassify(_Tp __f) { return fpclassify(__f); }
- template<typename _Tp>
- inline int
- __capture_isfinite(_Tp __f) { return isfinite(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isinf(_Tp __f) { return isinf(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isnan(_Tp __f) { return isnan(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isnormal(_Tp __f) { return isnormal(__f); }
-
- template<typename _Tp>
- inline int
- __capture_signbit(_Tp __f) { return signbit(__f); }
-
- template<typename _Tp>
- inline int
- __capture_isgreater(_Tp __f1, _Tp __f2)
- { return isgreater(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isgreaterequal(_Tp __f1, _Tp __f2)
- { return isgreaterequal(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_islessequal(_Tp __f1, _Tp __f2)
- { return islessequal(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_islessgreater(_Tp __f1, _Tp __f2)
- { return islessgreater(__f1, __f2); }
-
- template<typename _Tp>
- inline int
- __capture_isunordered(_Tp __f1, _Tp __f2)
- { return isunordered(__f1, __f2); }
-
_GLIBCXX_END_NAMESPACE
// Only undefine the C99 FP macros, if actually captured for namespace movement
@@ -535,58 +487,112 @@ _GLIBCXX_END_NAMESPACE
_GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
- inline int
- fpclassify(_Tp __f) { return ::__gnu_cxx::__capture_fpclassify(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ fpclassify(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return ::__gnu_cxx::__capture_fpclassify(__type(__f));
+ }
template<typename _Tp>
- inline int
- isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isfinite(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isfinite(__type(__f));
+ }
template<typename _Tp>
- inline int
- isinf(_Tp __f) { return ::__gnu_cxx::__capture_isinf(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isinf(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isinf(__type(__f));
+ }
template<typename _Tp>
- inline int
- isnan(_Tp __f) { return ::__gnu_cxx::__capture_isnan(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isnan(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isnan(__type(__f));
+ }
template<typename _Tp>
- inline int
- isnormal(_Tp __f) { return ::__gnu_cxx::__capture_isnormal(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ isnormal(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isnormal(__type(__f));
+ }
template<typename _Tp>
- inline int
- signbit(_Tp __f) { return ::__gnu_cxx::__capture_signbit(__f); }
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
+ signbit(_Tp __f)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_signbit(__type(__f));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isgreater(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isgreater(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isgreater(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isgreaterequal(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isgreaterequal(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isgreaterequal(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isless(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isless(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isless(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
islessequal(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_islessequal(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_islessequal(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
islessgreater(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_islessgreater(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_islessgreater(__type(__f1), __type(__f2));
+ }
template<typename _Tp>
- inline int
+ inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
+ int>::__type
isunordered(_Tp __f1, _Tp __f2)
- { return ::__gnu_cxx::__capture_isunordered(__f1, __f2); }
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __builtin_isunordered(__type(__f1), __type(__f2));
+ }
_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc
new file mode 100644
index 00000000000..c0abab33859
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc
@@ -0,0 +1,47 @@
+// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// { dg-do compile }
+
+#include <cmath>
+#include <string>
+
+struct employee
+: private std::string { };
+
+struct manager
+: public employee { };
+
+bool isnormal(const employee&)
+{ return false; }
+
+// libstdc++/25913
+void test01()
+{
+ manager m;
+ bool b = isnormal(m);
+}