From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3028 invoked by alias); 26 Oct 2007 13:28:14 -0000 Received: (qmail 2990 invoked by uid 48); 26 Oct 2007 13:28:01 -0000 Date: Fri, 26 Oct 2007 13:28:00 -0000 Subject: [Bug preprocessor/33907] New: Empty macro definitions not considered equal X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg02293.txt.bz2 #define A(a) #define A(b) g++-4.3 -S t.C t.C:2:1: error: "A" redefined t.C:1:1: error: this is the location of the previous definition We check the parameter names before the expansion, but if the expansion is empty in both cases there is no need to warn about different names. Of course watch out to still warn for #define A(a) a #define A(b) a which is why this only works for empty macros. The following would work for example: Index: macro.c =================================================================== --- macro.c (revision 129646) +++ macro.c (working copy) @@ -1281,6 +1281,12 @@ warn_of_redefinition (cpp_reader *pfile, || macro1->variadic != macro2->variadic) return true; + /* If the macro expansion has no tokens there is no need to compare + parameters spellings. */ + if (macro1->count == 0 + && macro2->count == 0) + return false; + /* Check parameter spellings. */ for (i = 0; i < macro1->paramc; i++) if (macro1->params[i] != macro2->params[i]) -- Summary: Empty macro definitions not considered equal Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33907