This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/70067 (ICE with typename typedef)


On this testcase, when strip_typedefs rebuilds a TYPENAME_TYPE to remove the typedef, in this case it looks up the same typedef and we then abort because we still have a typedef. In that case, strip the typedef explicitly.

Tested x86_64-pc-linux-gnu, applying to trunk and 5.
commit 3f1401348184108dd03d3b0d76e51d5166ca95bf
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 3 22:40:40 2016 -0500

    	PR c++/70067
    	* tree.c (strip_typedefs): Handle TYPENAME_TYPE lookup finding the
    	same type.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 0b7b144..aaf9a4f 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1437,6 +1437,9 @@ strip_typedefs (tree t, bool *remove_attributes)
 	result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t),
 						     remove_attributes),
 				     fullname, typename_type, tf_none);
+	/* Handle 'typedef typename A::N N;'  */
+	if (typedef_variant_p (result))
+	  result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (result)));
       }
       break;
     case DECLTYPE_TYPE:
diff --git a/gcc/testsuite/g++.dg/template/typename21.C b/gcc/testsuite/g++.dg/template/typename21.C
new file mode 100644
index 0000000..e5e59b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typename21.C
@@ -0,0 +1,11 @@
+// PR c++/70067
+// { dg-do compile { target c++98 } }
+
+template <class> struct A;
+template <class T> struct B { struct N { }; };
+template <class T> struct D: B<T> {
+  typedef typename D::N N;
+  A<N> *a;
+};
+
+D<int> d;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]