$ cat >text.cxx struct name {}; int f (); void g () { if (int name = f ()) { } } $ g++-3.4 -c text.cxx test.cxx: In function `void g()': test.cxx:9: error: expected primary-expression before "int" test.cxx:9: error: expected `)' before "int"
Confirmed, most reduced testcase: struct name {}; void g () { if (int name = 1) ; } : Search converges between 2002-12-14-trunk (#159) and 2002-12-29-trunk (#160). Looks like it was introduced by the new C++ parser.
Subject: Bug 20905 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2005-04-08 21:13:57 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: cond2.C Log message: PR c++/20905 * parser.c (cp_parser_type_specifier_seq): Add is_condition parameter. (cp_parser_new_type_id): Pass it. (cp_parser_condition): Likewise. (cp_parser_conversion_type_id): Likewise. (cp_parser_type_id): Likewise. (cp_parser_type_specifier_seq): In a condition, do not allow invalid type-specifier combinations. (cp_parser_exception_declaration): Adjust call to cp_parser_type_specifier_seq. PR c++/20905 * g++.dg/parse/cond2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4695&r2=1.4696 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.326&r2=1.327 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5305&r2=1.5306 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 20905 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: mmitchel@gcc.gnu.org 2005-04-08 21:23:26 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: cond2.C Log message: PR c++/20905 * parser.c (cp_parser_type_specifier_seq): Add is_condition parameter. (cp_parser_new_type_id): Pass it. (cp_parser_condition): Likewise. (cp_parser_conversion_type_id): Likewise. (cp_parser_type_id): Likewise. (cp_parser_type_specifier_seq): In a condition, do not allow invalid type-specifier combinations. (cp_parser_exception_declaration): Adjust call to cp_parser_type_specifier_seq. PR c++/20905 * g++.dg/parse/cond2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.30&r2=1.4648.2.31 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.319.2.5&r2=1.319.2.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.118&r2=1.5084.2.119 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond2.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed in 4.0, 4.1.
Fixed in 4.0 and up. Won't fix for 3.4.6.