re PR c++/59347 (ICE on invalid: tree check: expected class 'type', have 'exceptional...
authorJason Merrill <jason@redhat.com>
Fri, 21 Feb 2014 21:43:29 +0000 (16:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Feb 2014 21:43:29 +0000 (16:43 -0500)
PR c++/59347
* pt.c (tsubst_decl) [TYPE_DECL]: Don't try to instantiate an
erroneous typedef.

From-SVN: r208025

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

index 01a2569..1fcf54d 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/59347
+       * pt.c (tsubst_decl) [TYPE_DECL]: Don't try to instantiate an
+       erroneous typedef.
+
        PR c++/60241
        * pt.c (lookup_template_class_1): Update DECL_TEMPLATE_INSTANTIATIONS
        of the partial instantiation, not the most general template.
index 91a8840..2dc5f32 100644 (file)
@@ -10824,6 +10824,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
        tree type = NULL_TREE;
        bool local_p;
 
+       if (TREE_TYPE (t) == error_mark_node)
+         RETURN (error_mark_node);
+
        if (TREE_CODE (t) == TYPE_DECL
            && t == TYPE_MAIN_DECL (TREE_TYPE (t)))
          {
diff --git a/gcc/testsuite/g++.dg/template/typedef41.C b/gcc/testsuite/g++.dg/template/typedef41.C
new file mode 100644 (file)
index 0000000..dc25518
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/59347
+
+template<int> struct A
+{
+  typedef int ::X;             // { dg-error "" }
+};
+
+A<0> a;