From b2df41098c97d35a0cb5388a8de61cb413ec5fbb Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 17 Aug 2007 09:35:23 +0000 Subject: [PATCH] /cp 2007-08-17 Paolo Carlini PR c++/32870 * parser.c (cp_parser_class_head): Improve error message. /testsuite 2007-08-17 Paolo Carlini PR c++/32870 * g++.dg/other/error17.C: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127581 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 9 +++++++-- gcc/cp/parser.c | 8 ++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/error17.C | 13 +++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/error17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 89172af..15e1819 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,7 +1,12 @@ +2007-08-17 Paolo Carlini + + PR c++/32870 + * parser.c (cp_parser_class_head): Improve error message. + 2007-08-16 Seongbae Park - * pt.c (instantiate_decl): Set input_location - for the function end. + * pt.c (instantiate_decl): Set input_location + for the function end. 2007-08-16 Kaveh R. Ghazi diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b4ffd2f..70006c9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14417,8 +14417,12 @@ cp_parser_class_head (cp_parser* parser, class was originally declared, the program is invalid. */ if (scope && !is_ancestor (scope, nested_name_specifier)) { - error ("declaration of %qD in %qD which does not enclose %qD", - type, scope, nested_name_specifier); + if (at_namespace_scope_p ()) + error ("declaration of %qD in namespace %qD which does not " + "enclose %qD", type, scope, nested_name_specifier); + else + error ("declaration of %qD in %qD which does not enclose %qD", + type, scope, nested_name_specifier); type = NULL_TREE; goto done; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b8f5839..ee7d70a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-17 Paolo Carlini + + PR c++/32870 + * g++.dg/other/error17.C: Adjust. + 2007-08-17 Ben Elliston PR middle-end/32970 diff --git a/gcc/testsuite/g++.dg/other/error17.C b/gcc/testsuite/g++.dg/other/error17.C new file mode 100644 index 0000000..18769ef --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error17.C @@ -0,0 +1,13 @@ +// PR c++/32870 + +struct Foo { + struct Bar; +}; + +namespace N { + struct Foo::Bar { }; // { dg-error "in namespace 'N'" } +} + +struct Baz { + struct Foo::Bar { }; // { dg-error "in 'struct Baz'" } +}; -- 2.7.4