Bug 14668

Summary: [3.4/4.0 Regression] no warning anymore for reevaluation of declaration
Product: gcc Reporter: Pawel Sikora <pawel_sikora>
Component: c++Assignee: Mark Mitchell <mark>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, gdr
Priority: P2 Keywords: diagnostic
Version: 3.4.0   
Target Milestone: 3.4.1   
Host: pentium3-pld-linux Target: pentium3-pld-linux
Build: pentium3-pld-linux Known to work: 3.3.4
Known to fail: 3.4.0 4.0.0 Last reconfirmed: 2004-03-25 04:47:53

Description Pawel Sikora 2004-03-21 13:09:06 UTC
class A {}; 
class B { 
  static A *A; 
}; 
A *B::A = 0; 
 
g++3.4-20040317 compiles code without errors. 
g++3.3 reports error: declaration of `A*B::A' changes meaning of `A' from 
`class A' 
 
which behavior is correct?
Comment 1 Gabriel Dos Reis 2004-03-21 15:13:16 UTC
Subject: Re:  New: declaration of `A*B::A' changes meaning of `A' from `class A'...

"pluto at ds14 dot agh dot edu dot pl" <gcc-bugzilla@gcc.gnu.org> writes:

| class A {}; 
| class B { 
|   static A *A; 
| }; 
| A *B::A = 0; 
|  
| g++3.4-20040317 compiles code without errors. 
| g++3.3 reports error: declaration of `A*B::A' changes meaning of `A' from 
| `class A' 
|  
| which behavior is correct?

The code is ill-formed.  No diagnostic is required.  GCC used to
diagnose that in the past.  This is a regression.  I would think it is
a serious one (a frequent mistake).

-- Gaby
Comment 2 Wolfgang Bangerth 2004-03-24 23:23:37 UTC
Hm, I may be blind today, but I fail to see what may be wrong with this 
code? (Clearly the initialization of the member has nothing to do with 
the problem here.) Gaby, do you refer to the "after declaration, reevaluate 
the declaration with the newly defined name and see whether it is still 
valid" rule? Or what do you refer to in saying that the code is invalid? 
 
W. 
Comment 3 Gabriel Dos Reis 2004-03-25 00:22:28 UTC
Subject: Re:  [3.4/3.5 Regression] declaration of `A*B::A' changes meaning of `A' from `class A'...

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Hm, I may be blind today, but I fail to see what may be wrong with this 
| code? (Clearly the initialization of the member has nothing to do with 
| the problem here.)

Yes, I was not talking about the initialization.

| Gaby, do you refer to the "after declaration, reevaluate 
| the declaration with the newly defined name and see whether it is still 
| valid" rule? 

Yes, that is the one I was referring to.

-- Gaby
Comment 4 Wolfgang Bangerth 2004-03-25 04:47:52 UTC
OK, this is most likely a regression with the new parser then. 
Thanks 
W. 
Comment 5 Mark Mitchell 2004-05-24 02:47:22 UTC
Working on a fix.
Comment 7 CVS Commits 2004-05-28 20:16:09 UTC
Subject: Bug 14668

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-05-28 20:16:03

Modified files:
	gcc/cp         : parser.c 
	gcc/testsuite/g++.old-deja/g++.benjamin: tem04.C 
Added files:
	gcc/testsuite/g++.dg/lookup: redecl1.C 

Log message:
	PR c++/14668
	* parser.c (cp_parser_simple_type_specifier): Call
	maybe_note_name_used_in_class.
	
	PR c++/14668
	* g++.dg/lookup/redecl1.C: New test.
	* g++.old-deja/g++.benjamin/tem04.C: Add error marker.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.195&r2=1.196
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/redecl1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C.diff?cvsroot=gcc&r1=1.7&r2=1.8

Comment 8 CVS Commits 2004-05-28 20:17:35 UTC
Subject: Bug 14668

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-05-28 20:17:22

Modified files:
	gcc/cp         : ChangeLog 
	gcc/testsuite  : ChangeLog 

Log message:
	PR c++/14668
	* parser.c (cp_parser_simple_type_specifier): Call
	maybe_note_name_used_in_class.
	
	PR c++/14668
	* g++.dg/lookup/redecl1.C: New test.
	* g++.old-deja/g++.benjamin/tem04.C: Add error marker.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4062&r2=1.4063
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3785&r2=1.3786

Comment 9 Mark Mitchell 2004-05-28 20:18:54 UTC
Fixed in GCC 3.4.1.