public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/33907] Empty macro definitions not considered equal
Date: Sun, 25 Nov 2007 22:23:00 -0000	[thread overview]
Message-ID: <20071125222351.4319.qmail@sourceware.org> (raw)
In-Reply-To: <bug-33907-10053@http.gcc.gnu.org/bugzilla/>



------- Comment #7 from manu at gcc dot gnu dot org  2007-11-25 22:23 -------
(In reply to comment #6)
> 
> But yes, there's probably nothing else than to close this bug.
> 

Well you could make the error depend on the pedantic flag. This is a recurrent
confusion: C++ does not enable pedantic-errors by default. It makes pedwarns as
errors. -pedantic-errors is pedantic flag + pedwarns as errors. 

If you can provide me with a better text for the comment (something about the
part of the standard that requires us to give a diagnostic), I can update the
patch, bootstrap it and regression test it.

Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c      (revision 130380)
+++ libcpp/macro.c      (working copy)
@@ -1284,6 +1284,12 @@
       || macro1->variadic != macro2->variadic)
     return true;

+
+  /* If the macro expansion has no tokens there is no need to compare
+     parameters spellings unless -pedantic was given.  */
+  if (!CPP_PEDANTIC (pfile) && 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])
Index: gcc/testsuite/g++.dg/cpp/redefine-empty-macro-pedantic.C
===================================================================
--- gcc/testsuite/g++.dg/cpp/redefine-empty-macro-pedantic.C    (revision 0)
+++ gcc/testsuite/g++.dg/cpp/redefine-empty-macro-pedantic.C    (revision 0)
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-pedantic" }
+#define A(a) // { dg-error "this is the location of the previous definition" }
+#define A(b) // { dg-error ".A. redefined" }
Index: gcc/testsuite/g++.dg/cpp/redefine-empty-macro.C
===================================================================
--- gcc/testsuite/g++.dg/cpp/redefine-empty-macro.C     (revision 0)
+++ gcc/testsuite/g++.dg/cpp/redefine-empty-macro.C     (revision 0)
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "" }
+#define A(a)
+#define A(b)


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-25 22:23:50
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33907


  parent reply	other threads:[~2007-11-25 22:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26 13:28 [Bug preprocessor/33907] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071125222351.4319.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).