From: Ian Lance Taylor <iant@google.com>
To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com
Subject: Patch committed: Fix -fdump-go-spec for enum/#define constants
Date: Fri, 20 May 2011 17:01:00 -0000 [thread overview]
Message-ID: <mcr62p5jqam.fsf@coign.corp.google.com> (raw)
[-- 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,
reply other threads:[~2011-05-20 16:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mcr62p5jqam.fsf@coign.corp.google.com \
--to=iant@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gofrontend-dev@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).