From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30577 invoked by alias); 20 May 2011 16:22:23 -0000 Received: (qmail 30545 invoked by uid 22791); 20 May 2011 16:22:15 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD,T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 May 2011 16:22:01 +0000 Received: from kpbe11.cbf.corp.google.com (kpbe11.cbf.corp.google.com [172.25.105.75]) by smtp-out.google.com with ESMTP id p4KGLxab016071 for ; Fri, 20 May 2011 09:22:00 -0700 Received: from pwj5 (pwj5.prod.google.com [10.241.219.69]) by kpbe11.cbf.corp.google.com with ESMTP id p4KGLvJG017962 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 20 May 2011 09:21:58 -0700 Received: by pwj5 with SMTP id 5so2041613pwj.26 for ; Fri, 20 May 2011 09:21:57 -0700 (PDT) Received: by 10.68.0.102 with SMTP id 6mr7190374pbd.487.1305908516184; Fri, 20 May 2011 09:21:56 -0700 (PDT) Received: from coign.google.com (adsl-71-133-8-30.dsl.pltn13.pacbell.net [71.133.8.30]) by mx.google.com with ESMTPS id a6sm2534958pbs.81.2011.05.20.09.21.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2011 09:21:55 -0700 (PDT) From: Ian Lance Taylor 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 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01487.txt.bz2 --=-=-= Content-length: 460 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 * godump.c (go_output_typedef): Put enum constants in the macro hash table to avoid duplicate Go const definitions. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=foo.patch Content-Description: patch Content-length: 1215 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, --=-=-=--