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]

[PATCH] Fix PR c++/35578: Misplaced error message for invalid use of 'friend'


The patch below fixes a diagnostic problem in the C++ parser.
The error message for invalid usages of `friend' would sometimes
be in the wrong line. Fixed by adding the location of the keyword
to the error message.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?

Regards,
Volker

:ADDPATCH C++:


2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c++/35578
	* parser.c (cp_parser_decl_specifier_seq): Add location to error
	message.

========================================================================
--- gcc/cp/parser.c	2008-03-27 19:28:33 +0100
+++ gcc/cp/parser.c	2008-03-29 18:55:00 +0100
@@ -8103,7 +8103,7 @@ cp_parser_decl_specifier_seq (cp_parser*
 	case RID_FRIEND:
 	  if (!at_class_scope_p ())
 	    {
-	      error ("%<friend%> used outside of class");
+	      error ("%H%<friend%> used outside of class", &token->location);
 	      cp_lexer_purge_token (parser->lexer);
 	    }
 	  else
========================================================================

2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c++/35578
	* g++.dg/parse/friend8.C: New test.

========================================================================
--- gcc/testsuite/g++.dg/parse/friend8.C	2003-09-23 19:59:22 +0200
+++ gcc/testsuite/g++.dg/parse/friend8.C	2008-03-29 19:05:12 +0100
@@ -0,0 +1,7 @@
+// PR c++/35578
+// Check position of error message
+// { dg-do compile }
+
+int i;
+
+friend void foo(); // { dg-error "friend" }
========================================================================


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