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() { }
Confiremd. This happens since GCC 4.2.0.
Testing a patch.
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
Fixed on mainline.
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
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
Now also fixed on the 4.3 and 4.2 branch.