public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/33907]  New: Empty macro definitions not considered equal
@ 2007-10-26 13:28 rguenth at gcc dot gnu dot org
  2007-10-26 13:44 ` [Bug preprocessor/33907] " schwab at suse dot de
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-26 13:28 UTC (permalink / raw)
  To: gcc-bugs

#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


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2007-11-30 21:10 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 13:28 [Bug preprocessor/33907] New: Empty macro definitions not considered equal rguenth at gcc dot gnu dot org
2007-10-26 13:44 ` [Bug preprocessor/33907] " schwab at suse dot de
2007-10-26 13:46 ` rguenth at gcc dot gnu dot org
2007-10-26 13:56 ` schwab at suse dot de
2007-10-26 14:45 ` joseph at codesourcery dot com
2007-11-25 21:11 ` tromey at gcc dot gnu dot org
2007-11-25 21:34 ` rguenther at suse dot de
2007-11-25 22:23 ` manu at gcc dot gnu dot org
2007-11-25 22:29 ` rguenther at suse dot de
2007-11-25 22:56 ` manu at gcc dot gnu dot org
2007-11-25 22:59 ` manu at gcc dot gnu dot org
2007-11-26  9:56 ` rguenther at suse dot de
2007-11-26 12:44 ` joseph at codesourcery dot com
2007-11-26 13:03 ` manu at gcc dot gnu dot org
2007-11-26 13:15 ` rguenther at suse dot de
2007-11-26 17:47 ` manu at gcc dot gnu dot org
2007-11-27  9:10 ` rguenther at suse dot de
2007-11-27 13:51 ` manu at gcc dot gnu dot org
2007-11-27 13:57 ` manu at gcc dot gnu dot org
2007-11-30 21:10 ` gdr at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).