[multiple changes]

2011-02-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/tr1/cmath (fabs): Define.
	* include/tr1/complex (acos, asin, atan): Avoid duplicate definitions
	in C++0x mode.

2011-02-12  Jonathan Wakely  <jwakely.gcc@gmail.com>

	* testsuite/tr1/headers/c++200x/complex.cc: New.

From-SVN: r170083
This commit is contained in:
Jonathan Wakely 2011-02-12 18:30:50 +00:00
parent 6ef828bc54
commit db0947327c
4 changed files with 69 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2011-02-12 Paolo Carlini <paolo.carlini@oracle.com>
* include/tr1/cmath (fabs): Define.
* include/tr1/complex (acos, asin, atan): Avoid duplicate definitions
in C++0x mode.
2011-02-12 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/tr1/headers/c++200x/complex.cc: New.
2011-02-11 Johannes Singler <singler@kit.edu>
PR libstdc++/47433

View File

@ -1,6 +1,7 @@
// TR1 cmath -*- C++ -*-
// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2006, 2007, 2008, 2009, 2010, 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
@ -575,7 +576,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return expm1(__type(__x));
}
using std::fabs;
// 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
// mode have a different return type.
using ::fabs;
inline float
fabs(float __x)
{ return __builtin_fabsf(__x); }
inline long double
fabs(long double __x)
{ return __builtin_fabsl(__x); }
template<typename _Tp>
inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
double>::__type
fabs(_Tp __x)
{ return __builtin_fabs(__x); }
inline float
fdim(float __x, float __y)

View File

@ -1,6 +1,7 @@
// TR1 complex -*- C++ -*-
// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2006, 2007, 2008, 2009, 2010, 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
@ -44,16 +45,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
// Forward declarations.
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using std::acos;
using std::asin;
using std::atan;
#else
template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&);
#endif
template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&);
template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&);
// The std::fabs return type in C++0x mode is different (just _Tp).
template<typename _Tp> std::complex<_Tp> fabs(const std::complex<_Tp>&);
#ifndef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Tp>
inline std::complex<_Tp>
__complex_acos(const std::complex<_Tp>& __z)
@ -170,6 +179,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return __complex_atan(__z); }
#endif
#endif // __GXX_EXPERIMENTAL_CXX0X__
template<typename _Tp>
std::complex<_Tp>
__complex_acosh(const std::complex<_Tp>& __z)

View File

@ -0,0 +1,26 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// 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
// <http://www.gnu.org/licenses/>.
// check for duplicates of complex overloads of acos, asin, atan and fabs
#include <complex>
#include <tr1/cmath>
#include <tr1/complex>