From 79faac542c819aaf3b985486059dd16155580a02 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 25 Sep 2008 20:38:32 +0000 Subject: [PATCH] re PR c++/37649 (ICE with invalid template class) /cp 2008-09-25 Paolo Carlini PR c++/37649 * name-lookup.c (maybe_process_template_type_declaration): Check return value of push_template_decl_real for error_mark_node. /testsuite 2008-09-25 Paolo Carlini PR c++/37649 * g++.dg/template/crash82.C: New. From-SVN: r140670 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/name-lookup.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash82.C | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/crash82.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 88f8686..8c722d8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-09-25 Paolo Carlini + + PR c++/37649 + * name-lookup.c (maybe_process_template_type_declaration): Check + return value of push_template_decl_real for error_mark_node. + 2008-09-24 Aldy Hernandez * semantics.c (finish_fname): Pass location to fname_decl. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 946b321..a04d731 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4936,6 +4936,9 @@ maybe_process_template_type_declaration (tree type, int is_friend, tree name = DECL_NAME (decl); decl = push_template_decl_real (decl, is_friend); + if (decl == error_mark_node) + return error_mark_node; + /* If the current binding level is the binding level for the template parameters (see the comment in begin_template_parm_list) and the enclosing level is a class diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2941ac9..03d9d18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-25 Paolo Carlini + + PR c++/37649 + * g++.dg/template/crash82.C: New. + 2008-09-25 Tobias Burnus PR fortran/37504 diff --git a/gcc/testsuite/g++.dg/template/crash82.C b/gcc/testsuite/g++.dg/template/crash82.C new file mode 100644 index 0000000..4145691 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash82.C @@ -0,0 +1,6 @@ +// PR c++/37649 + +struct A +{ + template struct {}; // { dg-error "template class without a name" } +}; -- 2.7.4