From db0947327c7fb49fda878ce9d9f2fadfd19b1f3b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 12 Feb 2011 18:30:50 +0000 Subject: [multiple changes] 2011-02-12 Paolo Carlini * include/tr1/cmath (fabs): Define. * include/tr1/complex (acos, asin, atan): Avoid duplicate definitions in C++0x mode. 2011-02-12 Jonathan Wakely * testsuite/tr1/headers/c++200x/complex.cc: New. From-SVN: r170083 --- libstdc++-v3/ChangeLog | 10 +++++++++ libstdc++-v3/include/tr1/cmath | 22 ++++++++++++++++-- libstdc++-v3/include/tr1/complex | 15 +++++++++++-- .../testsuite/tr1/headers/c++200x/complex.cc | 26 ++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc (limited to 'libstdc++-v3') 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 + + * include/tr1/cmath (fabs): Define. + * include/tr1/complex (acos, asin, atan): Avoid duplicate definitions + in C++0x mode. + +2011-02-12 Jonathan Wakely + + * testsuite/tr1/headers/c++200x/complex.cc: New. + 2011-02-11 Johannes Singler 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 + 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 std::complex<_Tp> acos(const std::complex<_Tp>&); template std::complex<_Tp> asin(const std::complex<_Tp>&); template std::complex<_Tp> atan(const std::complex<_Tp>&); +#endif template std::complex<_Tp> acosh(const std::complex<_Tp>&); template std::complex<_Tp> asinh(const std::complex<_Tp>&); template std::complex<_Tp> atanh(const std::complex<_Tp>&); + + // The std::fabs return type in C++0x mode is different (just _Tp). template std::complex<_Tp> fabs(const std::complex<_Tp>&); +#ifndef __GXX_EXPERIMENTAL_CXX0X__ template 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 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 +// . + +// check for duplicates of complex overloads of acos, asin, atan and fabs + +#include +#include +#include + -- cgit v1.1