From patchwork Sat Nov 13 01:21:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 71035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 27370B7129 for ; Sat, 13 Nov 2010 12:22:07 +1100 (EST) Received: (qmail 10991 invoked by alias); 13 Nov 2010 01:22:06 -0000 Received: (qmail 10976 invoked by uid 22791); 13 Nov 2010 01:22:04 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, 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.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Nov 2010 01:21:28 +0000 Received: from wpaz13.hot.corp.google.com (wpaz13.hot.corp.google.com [172.24.198.77]) by smtp-out.google.com with ESMTP id oAD1LP7T022073 for ; Fri, 12 Nov 2010 17:21:26 -0800 Received: from pxi6 (pxi6.prod.google.com [10.243.27.6]) by wpaz13.hot.corp.google.com with ESMTP id oAD1L83I029760 for ; Fri, 12 Nov 2010 17:21:24 -0800 Received: by pxi6 with SMTP id 6so822879pxi.17 for ; Fri, 12 Nov 2010 17:21:24 -0800 (PST) Received: by 10.142.142.17 with SMTP id p17mr1976424wfd.440.1289611284240; Fri, 12 Nov 2010 17:21:24 -0800 (PST) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id w22sm4625504wfd.19.2010.11.12.17.21.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 12 Nov 2010 17:21:23 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: PATCH COMMITTED: Fix PR 46332: no extra parens for function types Date: Fri, 12 Nov 2010 17:21:16 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org PR 46332 points out that the demangler currently print extra parentheses for function types. Note that function types are a relatively unusual case for the demangler; pointer to function types are more common. This patch fixes the demangler for this case, and adjusts one libstdc++ test case accordingly. Bootstrapped on x86_64-unknown-linux-gnu. Ran the g++ and libstdc++ testsuites. Committed to mainline. Ian libiberty/: 2010-11-12 Ian Lance Taylor PR other/46332 * cp-demangle.c (d_print_function_type): Don't print parentheses if there are no modifiers to print. * testsuite/demangle-expected: Tweak one test case, add another. libstdc++/: 2010-11-12 Ian Lance Taylor PR other/46332 * testsuite/abi/demangle/abi_examples/14.cc (main): Change expected demangling. Index: libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc =================================================================== --- libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc (revision 166684) +++ libstdc++-v3/testsuite/abi/demangle/abi_examples/14.cc (working copy) @@ -33,7 +33,7 @@ int main() template void foo(); */ //demangle("_Z3fooIiPFidEiEvv", "void foo(void)"); - verify_demangle("_Z3fooIiFvdEiEvv", "void foo()"); + verify_demangle("_Z3fooIiFvdEiEvv", "void foo()"); return 0; } Index: libiberty/testsuite/demangle-expected =================================================================== --- libiberty/testsuite/demangle-expected (revision 166684) +++ libiberty/testsuite/demangle-expected (working copy) @@ -3325,8 +3325,13 @@ first # --format=gnu-v3 --no-params _Z3fooIiFvdEiEvv -void foo() -foo +void foo() +foo +# +--format=gnu-v3 --no-params +_Z1fIFvvEEvv +void f() +f # --format=gnu-v3 --no-params _ZN1N1fE Index: libiberty/cp-demangle.c =================================================================== --- libiberty/cp-demangle.c (revision 166684) +++ libiberty/cp-demangle.c (working copy) @@ -4546,20 +4546,17 @@ d_print_function_type (struct d_print_in struct d_print_mod *mods) { int need_paren; - int saw_mod; int need_space; struct d_print_mod *p; struct d_print_mod *hold_modifiers; need_paren = 0; - saw_mod = 0; need_space = 0; for (p = mods; p != NULL; p = p->next) { if (p->printed) break; - saw_mod = 1; switch (p->mod->type) { case DEMANGLE_COMPONENT_POINTER: @@ -4588,9 +4585,6 @@ d_print_function_type (struct d_print_in break; } - if (d_left (dc) != NULL && ! saw_mod) - need_paren = 1; - if (need_paren) { if (! need_space)