diff mbox

C++ PATCH for c++/57831 (ICE with using-declaration and qualified-id in template)

Message ID 51DC47EE.20800@redhat.com
State New
Headers show

Commit Message

Jason Merrill July 9, 2013, 5:27 p.m. UTC
Here instantiating the SCOPE_REF didn't know how to handle seeing a 
USING_DECL for the name.  The right answer is to strip the USING_DECL 
and return the identifier, as we do in other cases.

Tested x86_64-pc-linux-gnu, applying to trunk, 4.8 and 4.7.
diff mbox

Patch

commit 1d678e7704b74e7dfc0c927c47a0271c8d599b7c
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jul 8 23:36:12 2013 -0400

    	PR c++/57831
    	* pt.c (tsubst_copy): Handle USING_DECL.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7a36521..6f290f6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12508,6 +12508,9 @@  tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
     case TYPE_DECL:
       return tsubst (t, args, complain, in_decl);
 
+    case USING_DECL:
+      t = DECL_NAME (t);
+      /* Fall through.  */
     case IDENTIFIER_NODE:
       if (IDENTIFIER_TYPENAME_P (t))
 	{
diff --git a/gcc/testsuite/g++.dg/template/using23.C b/gcc/testsuite/g++.dg/template/using23.C
new file mode 100644
index 0000000..abb90de
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/using23.C
@@ -0,0 +1,15 @@ 
+// PR c++/57831
+
+struct A {
+  void f();
+};
+template <class T> struct B : T {
+  typedef T base;
+  using base::f;         // If I write "using B<T>::f" it's ok
+  void g( ) {
+    B<T>::f();           // This is OK as expected
+    (this->*&T::f)();    // This is also OK
+    (this->*&B<T>::f)(); // This causes error
+  }
+};
+template struct B< A >;