Bug 20905 - [3.4 Regression] confuses unrelated type name with instance name
Summary: [3.4 Regression] confuses unrelated type name with instance name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-04-08 16:54 UTC by Boris Kolpackov
Modified: 2006-02-28 10:11 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-01-07 01:54:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Kolpackov 2005-04-08 16:54:14 UTC
$ 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"
Comment 1 Andrew Pinski 2005-04-08 16:58:00 UTC
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.
Comment 2 GCC Commits 2005-04-08 21:14:05 UTC
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

Comment 3 GCC Commits 2005-04-08 21:23:35 UTC
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

Comment 4 Mark Mitchell 2005-04-08 21:41:48 UTC
Fixed in 4.0, 4.1.
Comment 5 Gabriel Dos Reis 2006-02-28 10:11:31 UTC
Fixed in 4.0 and up.  Won't fix for 3.4.6.