Commit 0e7edcd5 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/25913 (Client's isnormal function is broken by cmath)

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.

From-SVN: r130443
parent e072c217
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> 2007-11-25 Paolo Carlini <pcarlini@suse.de>
* include/tr1_impl/unordered_map * include/tr1_impl/unordered_map
......
...@@ -166,7 +166,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -166,7 +166,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __builtin_atan2l(__y, __x); } { return __builtin_atan2l(__y, __x); }
template<typename _Tp, typename _Up> 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) atan2(_Tp __y, _Up __x)
{ {
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
...@@ -377,7 +381,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -377,7 +381,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __builtin_powil(__x, __n); } { return __builtin_powil(__x, __n); }
template<typename _Tp, typename _Up> 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) pow(_Tp __x, _Up __y)
{ {
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
...@@ -478,55 +486,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -478,55 +486,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
inline int inline int
__capture_fpclassify(_Tp __f) { return fpclassify(__f); } __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 _GLIBCXX_END_NAMESPACE
// Only undefine the C99 FP macros, if actually captured for namespace movement // Only undefine the C99 FP macros, if actually captured for namespace movement
...@@ -546,58 +505,112 @@ _GLIBCXX_END_NAMESPACE ...@@ -546,58 +505,112 @@ _GLIBCXX_END_NAMESPACE
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
fpclassify(_Tp __f) { return ::__gnu_cxx::__capture_fpclassify(__f); } int>::__type
fpclassify(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return ::__gnu_cxx::__capture_fpclassify(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); } int>::__type
isfinite(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isfinite(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isinf(_Tp __f) { return ::__gnu_cxx::__capture_isinf(__f); } int>::__type
isinf(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isinf(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isnan(_Tp __f) { return ::__gnu_cxx::__capture_isnan(__f); } int>::__type
isnan(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isnan(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isnormal(_Tp __f) { return ::__gnu_cxx::__capture_isnormal(__f); } int>::__type
isnormal(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isnormal(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
signbit(_Tp __f) { return ::__gnu_cxx::__capture_signbit(__f); } int>::__type
signbit(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_signbit(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isgreater(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isgreaterequal(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isless(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
islessequal(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
islessgreater(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isunordered(_Tp __f1, _Tp __f2) 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 _GLIBCXX_END_NAMESPACE
......
// -*- C++ -*- C forwarding header. // -*- 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. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -467,55 +468,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -467,55 +468,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
inline int inline int
__capture_fpclassify(_Tp __f) { return fpclassify(__f); } __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 _GLIBCXX_END_NAMESPACE
// Only undefine the C99 FP macros, if actually captured for namespace movement // Only undefine the C99 FP macros, if actually captured for namespace movement
...@@ -535,58 +487,112 @@ _GLIBCXX_END_NAMESPACE ...@@ -535,58 +487,112 @@ _GLIBCXX_END_NAMESPACE
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
fpclassify(_Tp __f) { return ::__gnu_cxx::__capture_fpclassify(__f); } int>::__type
fpclassify(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return ::__gnu_cxx::__capture_fpclassify(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); } int>::__type
isfinite(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isfinite(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isinf(_Tp __f) { return ::__gnu_cxx::__capture_isinf(__f); } int>::__type
isinf(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isinf(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isnan(_Tp __f) { return ::__gnu_cxx::__capture_isnan(__f); } int>::__type
isnan(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isnan(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
isnormal(_Tp __f) { return ::__gnu_cxx::__capture_isnormal(__f); } int>::__type
isnormal(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_isnormal(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
signbit(_Tp __f) { return ::__gnu_cxx::__capture_signbit(__f); } int>::__type
signbit(_Tp __f)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return __builtin_signbit(__type(__f));
}
template<typename _Tp> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isgreater(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isgreaterequal(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isless(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
islessequal(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
islessgreater(_Tp __f1, _Tp __f2) 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> template<typename _Tp>
inline int inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
int>::__type
isunordered(_Tp __f1, _Tp __f2) 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 _GLIBCXX_END_NAMESPACE
......
// 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);
}
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