From dca56f77ee6797d96370360a8d105034223d3e6c Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Mon, 15 May 2006 08:52:29 +0000 Subject: re PR c++/27496 (ICE on broken templated friend) 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 | 6 ++++++ gcc/cp/pt.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/void2.C | 9 +++++++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/void2.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 593ee2c..632c7bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-05-15 Volker Reichelt + + PR c++/27496 + * pt.c (tsubst_friend_class): Return early on invalid friend + declarations. + 2006-05-14 H.J. Lu * Make-lang.in (cp/decl.o): Add dependency on $(TARGET_H). diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c1530fb..1634d2b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2a2ae5..ea7859d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-15 Volker Reichelt + + PR c++/27496 + * g++.dg/template/void2.C: New test. + 2006-05-14 Alexandre Oliva * 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 index 0000000..aa04178 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/void2.C @@ -0,0 +1,9 @@ +// PR c++/27496 +// { dg-do compile } + +template struct A +{ + template friend class X; // { dg-error "void" } +}; + +A<0> a; // { dg-error "instantiated" } -- cgit v1.1