Bug 11022

Summary: [3.3 regression] no warning for non-compatible macro redefine
Product: gcc Reporter: Loren Rittle <ljrittle>
Component: preprocessorAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P2    
Version: 3.3   
Target Milestone: 3.3.1   
Host: i386-unknown-freebsd4.8 Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Loren Rittle 2003-05-29 02:42:45 UTC
Also seen on sparc-sun-solaris2.7 (3.3 prerelease).  Preprocess the following
self-contained test (yet not preprocessed for obvious reasons):

#define FOO
#define FOO 1
#define FOO
#define FOO 2

gcc 3.2.X and before used to warn about this.  If you delete the third line, gcc
3.3 will warn about it as expected.
Comment 1 Andrew Pinski 2003-05-29 03:13:45 UTC
I can confirm this on 3.3 branch (20030526) and mainline (20030528):
tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_3/bin/gcc -Wall -W pr11022.c -c
tin:~/src/gnu/gcctest>gcc -Wall -W pr11022.c -c



tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_2/bin/gcc -Wall -W pr11022.c -c
pr11022.c:2:1: warning: "FOO" redefined
pr11022.c:1:1: warning: this is the location of the previous definition
pr11022.c:3:1: warning: "FOO" redefined
pr11022.c:2:1: warning: this is the location of the previous definition
pr11022.c:4:1: warning: "FOO" redefined
pr11022.c:3:1: warning: this is the location of the previous definition
Comment 2 DJ Delorie 2003-06-01 18:58:34 UTC
3.4: http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00054.html
Comment 3 Andrew Pinski 2003-06-02 03:54:33 UTC
Should this patch be also approved for 3.3?
Comment 4 Neil Booth 2003-06-02 05:44:41 UTC
Subject: Re:  [3.3 regression] no warning for non-compatible macro redefine

pinskia@physics.uc.edu wrote:-

> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11022
> 
> 
> pinskia@physics.uc.edu changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Summary|[3.3/3.4 regression]no      |[3.3 regression] no warning
>                    |warning for non-compatible  |for non-compatible macro
>                    |macro redefine              |redefine
> 
> 
> ------- Additional Comments From pinskia@physics.uc.edu  2003-06-02 03:54 -------
> Should this patch be also approved for 3.3?

Yes, it's approved for 3.3 too.

Neil.
Comment 5 GCC Commits 2003-06-19 05:40:37 UTC
Subject: Bug 11022

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	neil@gcc.gnu.org	2003-06-19 05:40:33

Modified files:
	gcc            : ChangeLog cppmacro.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/cpp: redef3.c 

Log message:
	PR preprocessor/11022
	* cppmacro.c (warn_of_redefinition): Handle cases where the two
	definitions have different numbers of tokens.
	testsuite:
	* gcc.dg/cpp/redef3.c: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.591&r2=1.16114.2.592
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cppmacro.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.126.4.1&r2=1.126.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.189&r2=1.2261.2.190
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/redef3.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.6.1

Comment 6 Neil Booth 2003-06-19 05:40:43 UTC
Fix backported from 3.4.