This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch] PR 32870


Hi,

really a pure enhancement request, but I'm finding it pretty convincing.

Tested x86_64-linux, Ok for mainline?

Paolo.

//////////////
/cp
2007-08-15  Paolo Carlini  <pcarlini@suse.de>

	PR c++/32870
	* parser.c (cp_parser_class_head): Improve error message.

/testsuite
2007-08-15  Paolo Carlini  <pcarlini@suse.de>

	PR c++/32870
	* g++.dg/other/error17.C: Adjust.
Index: testsuite/g++.dg/other/error17.C
===================================================================
*** testsuite/g++.dg/other/error17.C	(revision 0)
--- testsuite/g++.dg/other/error17.C	(revision 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'" }
+ };
Index: cp/parser.c
===================================================================
*** cp/parser.c	(revision 127509)
--- cp/parser.c	(working copy)
*************** cp_parser_class_head (cp_parser* parser,
*** 14417,14424 ****
  	 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);
  	  type = NULL_TREE;
  	  goto done;
  	}
--- 14417,14428 ----
  	 class was originally declared, the program is invalid.  */
        if (scope && !is_ancestor (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;
  	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]