aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorFabien ChĂȘne <fabien@gcc.gnu.org>2013-08-01 21:24:37 +0200
committerPeter Bergner <bergner@gcc.gnu.org>2013-08-01 14:24:37 -0500
commitfb23b69e140ca2448ae7360fe4a71e81e6101aac (patch)
treecd60a00f627c3f9f0d7d19e369f422b4c4290ae0 /libstdc++-v3
parent12123452e45937b341f187716a2a8343f0908465 (diff)
downloadgcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.zip
gcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.tar.gz
gcc-fb23b69e140ca2448ae7360fe4a71e81e6101aac.tar.bz2
re PR c++/54537 (undiagnosed using-declaration conflicting with used function)
gcc/cp/ PR c++/54537 * cp-tree.h: Check OVL_USED with OVERLOAD_CHECK. * name-lookup.c (do_nonmember_using_decl): Make sure we have an OVERLOAD before calling OVL_USED. Call diagnose_name_conflict instead of issuing an error without mentioning the conflicting declaration. libstdc++-v3/ PR c++/54537 * include/tr1/cmath: Remove pow(double,double) overload, remove a duplicated comment about DR 550. Add a comment to explain the issue. * testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: New. gcc/testsuite/ PR c++/54537 * g++.dg/overload/using3.C: New. * g++.dg/overload/using2.C: Adjust. * g++.dg/lookup/using9.C: Likewise. Co-Authored-By: Peter Bergner <bergner@vnet.ibm.com> From-SVN: r201414
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/tr1/cmath19
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc33
3 files changed, 53 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 48cde9e..4eea924 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-01 Fabien ChĂȘne <fabien@gcc.gnu.org>
+
+ PR c++/54537
+ * include/tr1/cmath: Remove pow(double,double) overload, remove a
+ duplicated comment about DR 550. Add a comment to explain the
+ issue.
+ * testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: New.
+
2013-07-31 Tim Shen <timshen91@gmail.com>
Thompson matcher refactored. Fix grouping problem.
diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath
index 3658afb..6e63e56 100644
--- a/libstdc++-v3/include/tr1/cmath
+++ b/libstdc++-v3/include/tr1/cmath
@@ -846,10 +846,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
nexttoward(_Tp __x, long double __y)
{ return __builtin_nexttoward(__x, __y); }
- // DR 550. What should the return type of pow(float,int) be?
- // NB: C++0x and TR1 != C++03.
- // using std::pow;
-
inline float
remainder(float __x, float __y)
{ return __builtin_remainderf(__x, __y); }
@@ -985,9 +981,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// DR 550. What should the return type of pow(float,int) be?
// NB: C++0x and TR1 != C++03.
- inline double
- pow(double __x, double __y)
- { return std::pow(__x, __y); }
+
+ // The std::tr1::pow(double, double) overload cannot be provided
+ // here, because it would clash with ::pow(double,double) declared
+ // in <math.h>, if <tr1/math.h> is included at the same time (raised
+ // by the fix of PR c++/54537). It is not possible either to use the
+ // using-declaration 'using ::pow;' here, because if the user code
+ // has a 'using std::pow;', it would bring the pow(*,int) averloads
+ // in the tr1 namespace, which is undesirable. Consequently, the
+ // solution is to forward std::tr1::pow(double,double) to
+ // std::pow(double,double) via the templatized version below. See
+ // the discussion about this issue here:
+ // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
inline float
pow(float __x, float __y)
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc
new file mode 100644
index 0000000..5775450
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc
@@ -0,0 +1,33 @@
+// { dg-do compile }
+
+// Copyright (C) 2013 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/>.
+
+#include <cmath>
+using std::pow;
+#include <tr1/cmath>
+#include <testsuite_tr1.h>
+
+void
+test01()
+{
+ using namespace __gnu_test;
+
+ float x = 2080703.375F;
+ check_ret_type<float>(std::pow(x, 2));
+ check_ret_type<double>(std::tr1::pow(x, 2));
+}