This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: FYI: Fix PR preprocessor/32868
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 30 Nov 2007 10:26:17 -0700
- Subject: Patch: FYI: Fix PR preprocessor/32868
- Reply-to: Tom Tromey <tromey at redhat dot com>
I'm checking this in on the trunk.
This fixes PR preprocessor/32868.
The bug is that, unlike the other __STDC macros, __STDC_FORMAT_MACROS
can be set by the user. So, it should follow the ordinary rules for
redefinition.
Test case included. Bootstrapped and regtested on x86 FC-6.
Tom
libcpp/ChangeLog:
2007-11-30 Tom Tromey <tromey@redhat.com>
PR preprocessor/32868:
* macro.c (_cpp_create_definition): Special case
__STDC_FORMAT_MACROS.
gcc/testsuite/ChangeLog:
2007-11-30 Tom Tromey <tromey@redhat.com>
PR preprocessor/32868:
* gcc.dg/cpp/pr32868.c: New file.
Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c (revision 130499)
+++ libcpp/macro.c (working copy)
@@ -1695,7 +1695,8 @@
/* Enter definition in hash table. */
node->type = NT_MACRO;
node->value.macro = macro;
- if (! ustrncmp (NODE_NAME (node), DSC ("__STDC_")))
+ if (! ustrncmp (NODE_NAME (node), DSC ("__STDC_"))
+ && ustrcmp (NODE_NAME (node), (const uchar *) "__STDC_FORMAT_MACROS"))
node->flags |= NODE_WARN;
return ok;
Index: gcc/testsuite/gcc.dg/cpp/pr32868.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/pr32868.c (revision 0)
+++ gcc/testsuite/gcc.dg/cpp/pr32868.c (revision 0)
@@ -0,0 +1,6 @@
+/* PR preprocessor/32868. It is ok to redefine __STDC_FORMAT_MACROS. */
+
+/* { dg-do preprocess } */
+
+#define __STDC_FORMAT_MACROS 1
+#define __STDC_FORMAT_MACROS 1