diff options
author | Jonathan Wakely <redi@gcc.gnu.org> | 2011-02-12 18:30:50 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2011-02-12 18:30:50 +0000 |
commit | db0947327c7fb49fda878ce9d9f2fadfd19b1f3b (patch) | |
tree | 0d65c0fc3d14361ba33a737f05ed54960acede9f /libstdc++-v3 | |
parent | 6ef828bc548bc2b47d6a20e6ccb3d3dc67d0aaec (diff) | |
download | gcc-db0947327c7fb49fda878ce9d9f2fadfd19b1f3b.zip gcc-db0947327c7fb49fda878ce9d9f2fadfd19b1f3b.tar.gz gcc-db0947327c7fb49fda878ce9d9f2fadfd19b1f3b.tar.bz2 |
[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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/cmath | 22 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/complex | 15 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc | 26 |
4 files changed, 69 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index df669c6..7e1445d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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 diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index 3cf1a10..21bdee8 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -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) diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex index 908b522..fc213b8 100644 --- a/libstdc++-v3/include/tr1/complex +++ b/libstdc++-v3/include/tr1/complex @@ -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) diff --git a/libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc b/libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc new file mode 100644 index 0000000..1df9701 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc @@ -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> + |