diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-20 16:21:48 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-20 16:21:48 +0000 |
commit | 32874486b6a71366e6b4a05f12a6f247d3fdb6ee (patch) | |
tree | 477d7dfdf8acac2f1c76b47ecb9d8ee700e5e095 /gcc/godump.c | |
parent | 0b4f4daf75c25fb3b60a72801ed9443a390a8db7 (diff) | |
download | gcc-32874486b6a71366e6b4a05f12a6f247d3fdb6ee.tar.gz |
* godump.c (go_output_typedef): Put enum constants in the macro
hash table to avoid duplicate Go const definitions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173962 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/godump.c')
-rw-r--r-- | gcc/godump.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/godump.c b/gcc/godump.c index 16a4803ab74..4f83777bc9d 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -844,9 +844,24 @@ go_output_typedef (struct godump_container *container, tree decl) 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, |