Bug 35578 - [4.2/4.3 Regression] Error about misplaced 'friend' word is issued on a wrong line
Summary: [4.2/4.3 Regression] Error about misplaced 'friend' word is issued on a wrong...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.1
: P2 normal
Target Milestone: 4.2.4
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2008-03-13 22:22 UTC by Yuri
Modified: 2008-05-11 19:37 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.4.0
Known to fail: 4.2.0 4.3.0
Last reconfirmed: 2008-03-29 17:57:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2008-03-13 22:22:37 UTC
When I compile the code below I get:
x.C:3: error: 'friend' used outside of class
And 'friend' word is on the line #5.

=== code begins ===
int i() {
  return (0);
} /*here an error is reported*/

friend void x() {
}
Comment 1 Volker Reichelt 2008-03-29 17:43:57 UTC
Confiremd. This happens since GCC 4.2.0.
Comment 2 Volker Reichelt 2008-03-29 17:57:16 UTC
Testing a patch.
Comment 3 Volker Reichelt 2008-03-30 22:02:54 UTC
Subject: Bug 35578

Author: reichelt
Date: Sun Mar 30 22:02:06 2008
New Revision: 133738

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133738
Log:
	PR c++/35578
	* parser.c (cp_parser_decl_specifier_seq): Add location to error
	message.

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

Added:
    trunk/gcc/testsuite/g++.dg/parse/friend8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Volker Reichelt 2008-03-30 22:08:10 UTC
Fixed on mainline.
Comment 5 Volker Reichelt 2008-05-11 19:33:35 UTC
Subject: Bug 35578

Author: reichelt
Date: Sun May 11 19:32:51 2008
New Revision: 135181

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135181
Log:
	PR c++/35578
	* parser.c (cp_parser_decl_specifier_seq): Add location to error
	message.

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

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/parse/friend8.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/parser.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 6 Volker Reichelt 2008-05-11 19:36:05 UTC
Subject: Bug 35578

Author: reichelt
Date: Sun May 11 19:35:20 2008
New Revision: 135182

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135182
Log:
	PR c++/35578
	* parser.c (cp_parser_decl_specifier_seq): Add location to error
	message.

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

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/parse/friend8.C
Modified:
    branches/gcc-4_2-branch/gcc/cp/ChangeLog
    branches/gcc-4_2-branch/gcc/cp/parser.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 7 Volker Reichelt 2008-05-11 19:37:09 UTC
Now also fixed on the 4.3 and 4.2 branch.