From 3fe82414fe09ce30d5dac1534b93a99b31e3e59a Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 24 Jan 2008 19:54:11 +0000 Subject: [PATCH] re PR c++/34603 (ICE with broken template declaration) /cp 2008-01-24 Paolo Carlini PR c++/34603 * pt.c (push_template_decl_real): Return error_mark_node in case of template definition of non-template. /testsuite 2008-01-24 Paolo Carlini PR c++/34603 * g++.dg/template/crash77.C: New. From-SVN: r131804 --- gcc/cp/ChangeLog | 9 ++++++++- gcc/cp/pt.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash77.C | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/crash77.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b6593cf..d842f77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,10 +1,17 @@ +2008-01-24 Paolo Carlini + + PR c++/34603 + * pt.c (push_template_decl_real): Return error_mark_node in case + of template definition of non-template. + 2008-01-24 Jason Merrill PR c++/34913 * decl2.c (is_late_template_attribute): Defer any attribute with dependent args. Also defer type attributes if the type is dependent. -2008-01-22 Jakub Jelinek , Alexandre Oliva +2008-01-22 Jakub Jelinek + Alexandre Oliva PR c++/33984 * call.c (reference_binding): For bitfields use the declared bitfield diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e61915d..56fcd4d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1,6 +1,6 @@ /* Handle parameterized types (templates) for GNU C++. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Rewritten by Jason Merrill (jason@cygnus.com). @@ -3977,7 +3977,7 @@ push_template_decl_real (tree decl, bool is_friend) if (!tinfo) { error ("template definition of non-template %q#D", decl); - return decl; + return error_mark_node; } tmpl = TI_TEMPLATE (tinfo); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96515ab..70f1e0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-24 Paolo Carlini + + PR c++/34603 + * g++.dg/template/crash77.C: New. + 2008-01-24 Uros Bizjak PR target/34856 diff --git a/gcc/testsuite/g++.dg/template/crash77.C b/gcc/testsuite/g++.dg/template/crash77.C new file mode 100644 index 0000000..b4d6e8f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash77.C @@ -0,0 +1,5 @@ +// PR c++/34603 + +template struct A; // { dg-error "declaration" } + +template A::A( struct A; // { dg-error "definition|expected|incomplete" } -- 2.7.4