[Bug preprocessor/33907] New: Empty macro definitions not considered equal
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Oct 26 13:28:00 GMT 2007
#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
More information about the Gcc-bugs
mailing list