* Patch committed: Fix -fdump-go-spec for enum/#define constants
@ 2011-05-20 17:01 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2011-05-20 17:01 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
This patch fixes -fdump-go-spec to work correctly when the same name is
defined as both a preprocessor macro and an enum constant. This
actually happens with glibc with the name IPPORT_RESERVED. Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to
mainline.
Ian
2011-05-20 Ian Lance Taylor <iant@google.com>
* godump.c (go_output_typedef): Put enum constants in the macro
hash table to avoid duplicate Go const definitions.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1215 bytes --]
Index: godump.c
===================================================================
--- godump.c (revision 173685)
+++ godump.c (working copy)
@@ -844,9 +844,24 @@ go_output_typedef (struct godump_contain
for (element = TYPE_VALUES (TREE_TYPE (decl));
element != NULL_TREE;
element = TREE_CHAIN (element))
- fprintf (go_dump_file, "const _%s = " HOST_WIDE_INT_PRINT_DEC "\n",
- IDENTIFIER_POINTER (TREE_PURPOSE (element)),
- tree_low_cst (TREE_VALUE (element), 0));
+ {
+ const char *name;
+ void **slot;
+
+ name = IDENTIFIER_POINTER (TREE_PURPOSE (element));
+
+ /* Sometimes a name will be defined as both an enum constant
+ and a macro. Avoid duplicate definition errors by
+ treating enum constants as macros. */
+ slot = htab_find_slot (macro_hash, name, INSERT);
+ if (*slot == NULL)
+ {
+ *slot = CONST_CAST (char *, name);
+ fprintf (go_dump_file,
+ "const _%s = " HOST_WIDE_INT_PRINT_DEC "\n",
+ name, tree_low_cst (TREE_VALUE (element), 0));
+ }
+ }
pointer_set_insert (container->decls_seen, TREE_TYPE (decl));
if (TYPE_CANONICAL (TREE_TYPE (decl)) != NULL_TREE)
pointer_set_insert (container->decls_seen,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-20 16:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20 17:01 Patch committed: Fix -fdump-go-spec for enum/#define constants Ian Lance Taylor
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).