OSDN Git Service

2011-02-12 Paolo Carlini <paolo.carlini@oracle.com>
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 Feb 2011 18:30:50 +0000 (18:30 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 Feb 2011 18:30:50 +0000 (18:30 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170083 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/tr1/cmath
libstdc++-v3/include/tr1/complex
libstdc++-v3/testsuite/tr1/headers/c++200x/complex.cc [new file with mode: 0644]

index df669c6..7e1445d 100644 (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
index 3cf1a10..21bdee8 100644 (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)
index 908b522..fc213b8 100644 (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)
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 (file)
index 0000000..1df9701
--- /dev/null
@@ -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>
+