re PR c++/35578 (Error about misplaced 'friend' word is issued on a wrong line)
authorVolker Reichelt <v.reichelt@netcologne.de>
Sun, 30 Mar 2008 22:02:06 +0000 (22:02 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sun, 30 Mar 2008 22:02:06 +0000 (22:02 +0000)
PR c++/35578
* parser.c (cp_parser_decl_specifier_seq): Add location to error
message.

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

From-SVN: r133738

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/friend8.C [new file with mode: 0644]

index 9627a535cb9422a5bce2767e8799f8315e7eaa55..ac3deb4c780367b3e981f6933576207d945635fc 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>
+
+       PR c++/35578
+       * parser.c (cp_parser_decl_specifier_seq): Add location to error
+       message.
+
 2008-03-27  Tom Tromey  <tromey@redhat.com>
 
        * Make-lang.in: Revert automatic dependency patch.
index 35a2fc3286f64f771586a4363de9049957fefefd..bb16edf03609a50bb4d7ffcc84a158f0e7694abc 100644 (file)
@@ -8103,7 +8103,7 @@ cp_parser_decl_specifier_seq (cp_parser* 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
index e7e4b30824bbcac553af10da628657a9b3a4c5e7..515f5fdb5fb963304b84c6ff3e878b906481da4f 100644 (file)
@@ -1,5 +1,8 @@
 2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>
 
+       PR c++/35578
+       * g++.dg/parse/friend8.C: New test.
+
        PR c/35748
        * gcc.dg/union-cast-4.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/parse/friend8.C b/gcc/testsuite/g++.dg/parse/friend8.C
new file mode 100644 (file)
index 0000000..aac5f0e
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/35578
+// Check position of error message
+// { dg-do compile }
+
+int i;
+
+friend  // { dg-error "friend" }
+  void foo();