From: Paolo Carlini Date: Tue, 12 Aug 2008 19:38:02 +0000 (+0000) Subject: re PR c++/37087 (Segfault on compiling template defined in wrong namespace.) X-Git-Tag: releases/gcc-4.4.0~3170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=905319d95e57f935e3f7fab102901334ee0afa02;p=thirdparty%2Fgcc.git re PR c++/37087 (Segfault on compiling template defined in wrong namespace.) /cp 2008-08-12 Paolo Carlini PR c++/37087 * parser.c (cp_parser_class_head): Early return error_mark_node in case of global qualification of class name or qualified name that does not name a class. /testsuite 2008-08-12 Paolo Carlini PR c++/37087 * g++.dg/template/crash80.C: New. * g++.old-deja/g++.other/decl5.C: Adjust. From-SVN: r139034 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5763e3f3b482..00b3613802d2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2008-08-12 Paolo Carlini + + PR c++/37087 + * parser.c (cp_parser_class_head): Early return error_mark_node in + case of global qualification of class name or qualified name that + does not name a class. + 2008-08-09 Manuel Lopez-Ibanez PR c++/12242 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 1bb52e5e01c4..fd4e1bbbe7b7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14981,11 +14981,17 @@ cp_parser_class_head (cp_parser* parser, cp_parser_commit_to_tentative_parse (parser); /* Issue the error about the overly-qualified name now. */ if (qualified_p) - cp_parser_error (parser, - "global qualification of class name is invalid"); + { + cp_parser_error (parser, + "global qualification of class name is invalid"); + return error_mark_node; + } else if (invalid_nested_name_p) - cp_parser_error (parser, - "qualified name does not name a class"); + { + cp_parser_error (parser, + "qualified name does not name a class"); + return error_mark_node; + } else if (nested_name_specifier) { tree scope; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f30067d9a676..8399de6d9790 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-08-12 Paolo Carlini + + PR c++/37087 + * g++.dg/template/crash80.C: New. + * g++.old-deja/g++.other/decl5.C: Adjust. + 2008-08-12 Jakub Jelinek PR middle-end/37014 diff --git a/gcc/testsuite/g++.dg/template/crash80.C b/gcc/testsuite/g++.dg/template/crash80.C new file mode 100644 index 000000000000..ed462ac9d19e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash80.C @@ -0,0 +1,9 @@ +// PR c++/37087 + +namespace a { + template class Foo; +} + +namespace b { + template <> class ::a::Foo {}; // { dg-error "error: global qualification of class name is invalid" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl5.C b/gcc/testsuite/g++.old-deja/g++.other/decl5.C index f8c447c01d3b..62a18e5822f7 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/decl5.C +++ b/gcc/testsuite/g++.old-deja/g++.other/decl5.C @@ -16,7 +16,7 @@ struct A { int m; }; struct Z; - expand me; + expand me; // { dg-error "" } not name a type void foo(struct A::e); void foo(struct A::z); // { dg-warning "" } extra qualification }; @@ -71,7 +71,7 @@ namespace NMS }; } -NMS::D thing; +NMS::D thing; // { dg-error "" } not name a type void NMS::fn() { i = 3;