From patchwork Fri May 20 14:01:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 96606 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 45945B71A2 for ; Sat, 21 May 2011 00:02:00 +1000 (EST) Received: (qmail 2406 invoked by alias); 20 May 2011 14:01:58 -0000 Received: (qmail 2394 invoked by uid 22791); 20 May 2011 14:01:56 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 May 2011 14:01:42 +0000 Received: (qmail 15771 invoked from network); 20 May 2011 14:01:41 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 May 2011 14:01:41 -0000 Date: Fri, 20 May 2011 10:01:40 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: iant@google.com Subject: [PATCH] remove TYPE_ARG_TYPES from godump.c Message-ID: <20110520140139.GB22416@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 As $SUBJECT suggests. It may be worth noting that we now do more work after this patch (stdarg_p and prototype_p both traverse TYPE_ARG_TYPES under the hood); one day those will be simple boolean tests. Tested on x86_64-unknown-linux-gnu with go. OK to commit? -Nathan gcc/ * godump.c (go_format_type): Don't use TYPE_ARG_TYPES. diff --git a/gcc/godump.c b/gcc/godump.c index 16a4803..c4557f8 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -741,9 +741,11 @@ go_format_type (struct godump_container *container, tree type, case FUNCTION_TYPE: { - tree args; + tree arg_type; bool is_varargs; tree result; + function_args_iterator iter; + bool seen_arg = false; /* Go has no way to write a type which is a function but not a pointer to a function. */ @@ -754,25 +756,20 @@ go_format_type (struct godump_container *container, tree type, } obstack_1grow (ob, '('); - is_varargs = true; - for (args = TYPE_ARG_TYPES (type); - args != NULL_TREE; - args = TREE_CHAIN (args)) + is_varargs = stdarg_p (type); + FOREACH_FUNCTION_ARGS (type, arg_type, iter) { - if (VOID_TYPE_P (TREE_VALUE (args))) - { - gcc_assert (TREE_CHAIN (args) == NULL); - is_varargs = false; - break; - } - if (args != TYPE_ARG_TYPES (type)) + if (VOID_TYPE_P (arg_type)) + break; + if (seen_arg) obstack_grow (ob, ", ", 2); - if (!go_format_type (container, TREE_VALUE (args), true, false)) + if (!go_format_type (container, arg_type, true, false)) ret = false; + seen_arg = true; } if (is_varargs) { - if (TYPE_ARG_TYPES (type) != NULL_TREE) + if (prototype_p (type)) obstack_grow (ob, ", ", 2); obstack_grow (ob, "...interface{}", 14); }