This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/35578: Misplaced error message for invalid use of 'friend'
- From: Volker Reichelt <v dot reichelt at netcologne dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 30 Mar 2008 12:44:38 +0200 (CEST)
- Subject: [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" }
========================================================================