------- 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

Reply via email to