re PR c++/35405 (Internal compiler error)
authorDodji Seketeli <dodji@redhat.com>
Wed, 19 Nov 2008 22:26:56 +0000 (22:26 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 19 Nov 2008 22:26:56 +0000 (23:26 +0100)
gcc/cp/ChangeLog:
2008-11-19  Dodji Seketeli  <dodji@redhat.com>

PR c++/35405
* pt.c (lookup_template_class): Check pointers before dereferencing
  Them.
* error.c (dump_template_decl): Likewise.

gcc/testsuite/ChangeLog:
2008-11-19  Dodji Seketeli  <dodji@redhat.com>

PR c++/35405
* g++.dg/template/crash84.C: New test.

From-SVN: r142022

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash84.C [new file with mode: 0644]

index 5e47e58..73e07d7 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-19  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/35405
+       * pt.c (lookup_template_class): Check pointers before dereferencing
+         Them.
+       * error.c (dump_template_decl): Likewise.
+
 2008-11-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/36410
index 3aa9b59..a2db157 100644 (file)
@@ -1044,11 +1044,13 @@ dump_template_decl (tree t, int flags)
        }
     }
 
-  if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
+  if (DECL_TEMPLATE_RESULT (t)
+      && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
     dump_type (TREE_TYPE (t),
               ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
                | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
-  else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
+  else if (DECL_TEMPLATE_RESULT (t)
+           && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
     dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
   else
     {
index 2b938c3..96c510f 100644 (file)
@@ -5585,6 +5585,7 @@ lookup_template_class (tree d1,
       d1 = DECL_NAME (templ);
     }
   else if (TREE_CODE (d1) == TEMPLATE_DECL
+           && DECL_TEMPLATE_RESULT (d1)
           && TREE_CODE (DECL_TEMPLATE_RESULT (d1)) == TYPE_DECL)
     {
       templ = d1;
index ab27dd9..85f9f27 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-19  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/35405
+       * g++.dg/template/crash84.C: New test.
+
 2008-11-19  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/compile/pr11832.c: XFAIL even on s390*-*-*.
diff --git a/gcc/testsuite/g++.dg/template/crash84.C b/gcc/testsuite/g++.dg/template/crash84.C
new file mode 100644 (file)
index 0000000..f622aaa
--- /dev/null
@@ -0,0 +1,19 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/35405
+// { dg-do compile }
+
+template<typename T> struct a
+{
+    template <template <typename> class C, typename X, C<X>* =0>
+    struct b // { dg-error "class C' is not a template|is not a valid type" }
+    {
+    };
+};
+
+void
+foo ()
+{
+    a<int> v; // { dg-message "instantiated from here" }
+}
+
+