re PR c++/27496 (ICE on broken templated friend)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 15 May 2006 08:52:29 +0000 (08:52 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 15 May 2006 08:52:29 +0000 (08:52 +0000)
PR c++/27496
* pt.c (tsubst_friend_class): Return early on invalid friend
declarations.

* g++.dg/template/void2.C: New test.

From-SVN: r113776

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

index 593ee2ce566f83dcc96d4602c5ec085bf15a9f3f..632c7bbc29a300e5373b84c310f2ea23e0ff548f 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-15  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27496
+       * pt.c (tsubst_friend_class): Return early on invalid friend
+       declarations.
+
 2006-05-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        * Make-lang.in (cp/decl.o): Add dependency on $(TARGET_H).
index c1530fb120ff985392f8cf65b96b26d3d0cbde48..1634d2b932fb0f6ca6006433d38f4b28472b278d 100644 (file)
@@ -5435,6 +5435,8 @@ tsubst_friend_class (tree friend_tmpl, tree args)
         case, the instantiation of the template class will cause the
         injection of this template into the global scope.  */
       tmpl = tsubst (friend_tmpl, args, tf_warning_or_error, NULL_TREE);
+      if (tmpl == error_mark_node)
+       return error_mark_node;
 
       /* The new TMPL is not an instantiation of anything, so we
         forget its origins.  We don't reset CLASSTYPE_TI_TEMPLATE for
index a2a2ae5edf4532691af1b4d825d76f1f6cd70071..ea7859d31224d6adb91c45368918b74181d44509 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-15  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27496
+       * g++.dg/template/void2.C: New test.
+
 2006-05-14  Alexandre Oliva  <aoliva@redhat.com>
 
        * g++.dg/template/dependent-expr5.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/void2.C b/gcc/testsuite/g++.dg/template/void2.C
new file mode 100644 (file)
index 0000000..aa04178
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/27496
+// { dg-do compile }
+
+template<int> struct A
+{
+  template<void> friend class X;  // { dg-error "void" }
+};
+
+A<0> a;  // { dg-error "instantiated" }