I've run so many times into this now that I feel that it is important to get it fixed. The following code snippet, struct A { void foo(bar* p); }; Gives as error message: >g++-cvs-3.5 -c test.cc test.cc:2: error: variable or field `foo' declared void test.cc:2: error: expected `;' before '(' token Only when foo is not a member function, there also appears a MUCH more correct error message: test.cc:1: error: variable or field `foo' declared void test.cc:1: error: `bar' was not declared in this scope test.cc:1: error: `p' was not declared in this scope If possible, the `bar' was not declared in this scope should come first - and it should definitely also be printed in the case of the member function. 3.4.0 does the same unclear thing. You can consider this a regression because 3.3.3 gives most sensible output: >g++-3.3.3 -c test.cc test.cc:2: error: `bar' was not declared in this scope test.cc:2: error: `p' was not declared in this scope test.cc:2: error: invalid data member initialization test.cc:2: error: (use `=' to initialize static data members) test.cc:2: error: variable or field `foo' declared void
Confirmed.
This is not a showstopper.
*** Bug 16151 has been marked as a duplicate of this bug. ***
Postponed until GCC 3.4.3.
Subject: Bug 15786 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-10-12 01:52:20 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: error22.C Log message: PR c++/15786 * parser.c (cp_parser_declarator): Add member_p parameter. (cp_parser_condition): Adjust calls to cp_parser_declarator. (cp_parser_explicit_instantiation): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_direct_declarator): Add member_p parameter. Do not parse tentatively when parsing the parameters to a member. (cp_parser_type_id): Adjust calls to cp_parser_declarator. (cp_parser_parameter_declaration): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_exception_declaration): Likewise. PR c++/15876 * g++.dg/parse/error22.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4426&r2=1.4427 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.262&r2=1.263 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4438&r2=1.4439 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error22.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 15786 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-10-12 03:07:16 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: error22.C Log message: PR c++/15786 * parser.c (cp_parser_declarator): Add member_p parameter. (cp_parser_condition): Adjust calls to cp_parser_declarator. (cp_parser_explicit_instantiation): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_direct_declarator): Add member_p parameter. Do not parse tentatively when parsing the parameters to a member. (cp_parser_type_id): Adjust calls to cp_parser_declarator. (cp_parser_parameter_declaration): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_exception_declaration): Likewise. PR c++/15876 * g++.dg/parse/error22.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.168&r2=1.3892.2.169 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.43&r2=1.157.2.44 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.284&r2=1.3389.2.285 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error22.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.3.