[Patch] PR c++/42915

Dodji Seketeli dodji@redhat.com
Thu Feb 4 22:06:00 GMT 2010


Hello,

While chasing the "complicated" dependent typedef based type 
comparisons, it looks like I forgot the easy non-typedef based one.

Fixed thus and tested against trunk on x86_64-unknown-linux-gnu.

        Dodji

commit c9a8490ff230e4e3378d03c2a642c067569bdd4d
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Mon Feb 1 09:15:41 2010 +0100

    Fix PR c++/42915
    
    gcc/cp/ChangeLog:
    	* typeck.c (get_template_parms_of_dependent_type): Try getting
        the template parameters from the type itself first.
    
    gcc/testsuite/ChangeLog:
    	g++.dg/other/crash-9.C: New test.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 36f3065..18d56f4 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1106,9 +1106,13 @@ get_template_parms_of_dependent_type (tree t)
 {
   tree tinfo = NULL_TREE, tparms = NULL_TREE;
 
+  /* First, try the obvious case of getting the
+     template info from T itself.  */
+  if ((tinfo = get_template_info (t)))
+    ;
   /* If T1 is a typedef or whatever has a template info associated
      to its context, get the template parameters from that context.  */
-  if (typedef_variant_p (t)
+  else if (typedef_variant_p (t)
       && DECL_CONTEXT (TYPE_NAME (t))
       && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
     tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
diff --git a/gcc/testsuite/g++.dg/other/crash-9.C b/gcc/testsuite/g++.dg/other/crash-9.C
new file mode 100644
index 0000000..0953fcb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/crash-9.C
@@ -0,0 +1,15 @@
+// Origin: PR c++/42915
+// { dg-do compile }
+
+template <typename T>
+class A
+{
+  template <typename U>
+  class B
+  {
+    B foo();
+  };
+};
+template <typename T> template <typename U>
+A<T>::B<U> A<T>::B<U>::foo() {}
+



More information about the Gcc-patches mailing list