Bug 16637 - [3.4/4.0 regression] syntax error on valid input code
Summary: [3.4/4.0 regression] syntax error on valid input code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P1 critical
Target Milestone: 3.4.2
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
: 16846 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-19 22:52 UTC by Rich Newman
Modified: 2004-09-13 14:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-07-20 08:07:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rich Newman 2004-07-19 22:52:28 UTC
reduced test-case:

--- foo.cc ----
struct a {
    int x;
};

struct foo {
    union {
        ::a a;
    } u;
};

int main(void)
{
    foo bar;
    retun 0;
}
---- end ----

3.4.0 compiles w/o error.  3.4.1 produces syntax error at declaration of "foo
bar".  Workaround is to write it as: "struct foo bar;"  

The "regression hunter" found the error at: 

2004-05-15-3.4 (#7) and 
2004-06-01-3.4 (#8)
Comment 1 Andrew Pinski 2004-07-20 08:07:47 UTC
Reduced example, I think this is correct C++ as ::a references to the global type:
typedef int a;
struct y
{
  ::a a;
};

: Search converges between 2004-05-23-trunk (#458) and 2004-06-01-trunk (#459).

Most (All) of the changes inbetween that time that went on both the mainline and the 3.4 branch was 
from Mark.
Comment 2 Mark Mitchell 2004-07-20 16:17:11 UTC
It sounds like we're talking about two different issues.

The initial report is about a problem with the declaration of "bar" in "main". 
I can't reproduce that on either mainline or with the current 3.4 branch.

I do still get an error about the meaning of a name changing, which does indeed
look odd.  I'm looking into that.
Comment 3 Mark Mitchell 2004-07-20 16:19:06 UTC
Working on a fix.
Comment 4 Rich Newman 2004-07-20 16:23:06 UTC
If it helps, here's another example, (reduced from ACE 5.2 sources):

 struct t_bind { }; 
 class ACE_OS_TLI { 
    public: static int t_bind(::t_bind *, ::t_bind *); 
 }; 
Comment 5 Rich Newman 2004-07-20 16:30:45 UTC
Whoops.  Wrong work around in original comment -- sorry.  The workaround is to
declare struct foo as:

struct foo {
    union {
        struct a a; 
    } u;
};

Comment 6 GCC Commits 2004-07-20 17:27:36 UTC
Subject: Bug 16637

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-07-20 17:27:13

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

Log message:
	PR c++/16637
	* parser.c (cp_parser_simple_type_specifier): Do not record usage
	of globally-qualified names.
	
	PR c++/16637
	* g++.dg/parse/lookup4.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.132&r2=1.3892.2.133
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.34&r2=1.157.2.35
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.230&r2=1.3389.2.231
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/lookup4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 7 GCC Commits 2004-07-20 17:58:55 UTC
Subject: Bug 16637

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-07-20 17:58:43

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

Log message:
	PR c++/16637
	* parser.c (cp_parser_simple_type_specifier): Do not record usage
	of globally-qualified names.
	
	PR c++/16637
	* g++.dg/parse/lookup4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4024&r2=1.4025
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4232&r2=1.4233
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.228&r2=1.229
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/lookup4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 8 Mark Mitchell 2004-07-20 18:00:51 UTC
Fixed in GCC 3.4.2.
Comment 9 Andrew Pinski 2004-07-24 02:10:36 UTC
Closing as fixed.
Comment 10 Andrew Pinski 2004-08-01 09:01:04 UTC
*** Bug 16846 has been marked as a duplicate of this bug. ***