public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3] libstdc++/25913 (and more)
@ 2007-11-26 21:30 Paolo Carlini
  0 siblings, 0 replies; only message in thread
From: Paolo Carlini @ 2007-11-26 21:30 UTC (permalink / raw)
  To: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

Hi,

tested x86_64-linux, committed to mainline.

Paolo.

////////////////////

[-- Attachment #2: CL_25913 --]
[-- Type: text/plain, Size: 925 bytes --]

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.

[-- Attachment #3: patch_25913 --]
[-- Type: text/plain, Size: 15712 bytes --]

Index: include/c_std/cmath
===================================================================
--- include/c_std/cmath	(revision 130437)
+++ include/c_std/cmath	(working copy)
@@ -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 @@
     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_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
 
Index: include/c_global/cmath
===================================================================
--- include/c_global/cmath	(revision 130437)
+++ include/c_global/cmath	(working copy)
@@ -166,7 +166,11 @@
   { 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 @@
   { 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 @@
     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_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
 
Index: testsuite/26_numerics/headers/cmath/25913.cc
===================================================================
--- testsuite/26_numerics/headers/cmath/25913.cc	(revision 0)
+++ testsuite/26_numerics/headers/cmath/25913.cc	(revision 0)
@@ -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);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-26 18:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-26 21:30 [v3] libstdc++/25913 (and more) Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).