aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-10-27 09:39:48 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-10-27 09:39:48 -0400
commit7c92f4ec6107dc41199d8b61c9c4a598cadd9011 (patch)
tree02e44dc7b191487ed4b16074bb787457b4ee1a8a /gcc
parent104700f4e9e20e1c1aef0fb0f0894b073f09fdaa (diff)
downloadgcc-7c92f4ec6107dc41199d8b61c9c4a598cadd9011.zip
gcc-7c92f4ec6107dc41199d8b61c9c4a598cadd9011.tar.gz
gcc-7c92f4ec6107dc41199d8b61c9c4a598cadd9011.tar.bz2
* class.c (add_method): Allow using-declarations to coexist.
From-SVN: r241620
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/class.c5
-rw-r--r--gcc/testsuite/g++.dg/overload/using4.C19
3 files changed, 28 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1276d13..efce361 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2016-10-26 Jason Merrill <jason@redhat.com>
+
+ * class.c (add_method): Allow using-declarations to coexist.
+
2016-10-25 Jason Merrill <jason@redhat.com>
* constexpr.c (maybe_constant_init): Pull out TARGET_EXPR_INITIAL.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d334b7c..a2a9346 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1094,6 +1094,11 @@ add_method (tree type, tree method, tree using_decl)
if (TREE_CODE (fn) != TREE_CODE (method))
continue;
+ /* Two using-declarations can coexist, we'll complain about ambiguity in
+ overload resolution. */
+ if (using_decl && TREE_CODE (fns) == OVERLOAD && OVL_USED (fns))
+ continue;
+
/* [over.load] Member function declarations with the
same name and the same parameter types cannot be
overloaded if any of them is a static member
diff --git a/gcc/testsuite/g++.dg/overload/using4.C b/gcc/testsuite/g++.dg/overload/using4.C
new file mode 100644
index 0000000..e4ee823
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/using4.C
@@ -0,0 +1,19 @@
+struct A
+{
+ void f();
+};
+
+struct B
+{
+ void f();
+};
+
+struct C: A,B {
+ using A::f;
+ using B::f;
+};
+
+int main()
+{
+ C().f(); // { dg-error "ambiguous" }
+}