This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch committed: Fix -fdump-go-spec with large enum values
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Oct 2011 22:30:13 +0200
- Subject: Re: Patch committed: Fix -fdump-go-spec with large enum values
- References: <mcrk48lzvki.fsf@coign.corp.google.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Oct 03, 2011 at 01:09:17PM -0700, Ian Lance Taylor wrote:
> Jakub discovered that -fdump-go-spec crashes when it tries to print an
> enum value which does not fit in a signed HOST_WIDE_INT. This patch
> fixes the problem. Bootstrapped and tested on x86_64-unknown-linux-gnu.
> Committed to mainline.
And here is 4.6 backport that I've committed to 4.6 branch.
2011-10-03 Jakub Jelinek <jakub@redhat.com>
Ian Lance Taylor <iant@google.com>
* godump.c (go_output_typedef): Support printing enum values that
don't fit in a signed HOST_WIDE_INT.
--- gcc/godump.c (revision 179479)
+++ gcc/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));
+ {
+ fprintf (go_dump_file, "const _%s = ",
+ IDENTIFIER_POINTER (TREE_PURPOSE (element)));
+ if (host_integerp (TREE_VALUE (element), 0))
+ fprintf (go_dump_file, HOST_WIDE_INT_PRINT_DEC,
+ tree_low_cst (TREE_VALUE (element), 0));
+ else if (host_integerp (TREE_VALUE (element), 1))
+ fprintf (go_dump_file, HOST_WIDE_INT_PRINT_UNSIGNED,
+ ((unsigned HOST_WIDE_INT)
+ tree_low_cst (TREE_VALUE (element), 1)));
+ else
+ fprintf (go_dump_file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
+ ((unsigned HOST_WIDE_INT)
+ TREE_INT_CST_HIGH (TREE_VALUE (element))),
+ TREE_INT_CST_LOW (TREE_VALUE (element)));
+ fprintf (go_dump_file, "\n");
+ }
+
pointer_set_insert (container->decls_seen, TREE_TYPE (decl));
if (TYPE_CANONICAL (TREE_TYPE (decl)) != NULL_TREE)
pointer_set_insert (container->decls_seen,
Jakub