From patchwork Sun Aug 8 01:27:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 61194 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 CAD3CB6EE9 for ; Sun, 8 Aug 2010 11:27:20 +1000 (EST) Received: (qmail 15476 invoked by alias); 8 Aug 2010 01:27:18 -0000 Received: (qmail 15468 invoked by uid 22791); 8 Aug 2010 01:27:17 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_CD, 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; Sun, 08 Aug 2010 01:27:12 +0000 Received: (qmail 5484 invoked from network); 8 Aug 2010 01:27:11 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Aug 2010 01:27:11 -0000 Date: Sat, 7 Aug 2010 18:27:11 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] convert c_arg_info.tags into a VEC Message-ID: <20100808012709.GQ17362@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-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 indicates. Most TREE_LIST removal, hooray, hooray. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan * c-tree.h (c_arg_tag): Define. Define a VEC containing it. (struct c_arg_info): Change type of tags field. * c-decl.c (grokdeclarator): Update for changed type of tags field. (get_parm_info): Likewise. (store_parm_decls_newstyle): Likewise. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 010421c..e4e872d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5541,12 +5541,11 @@ grokdeclarator (const struct c_declarator *declarator, the formal parameter list of this FUNCTION_TYPE to point to the FUNCTION_TYPE node itself. */ { - tree link; + c_arg_tag *tag; + unsigned ix; - for (link = arg_info->tags; - link; - link = TREE_CHAIN (link)) - TYPE_CONTEXT (TREE_VALUE (link)) = type; + FOR_EACH_VEC_ELT_REVERSE (c_arg_tag, arg_info->tags, ix, tag) + TYPE_CONTEXT (tag->type) = type; } break; } @@ -6192,7 +6191,7 @@ get_parm_info (bool ellipsis) struct c_arg_info *arg_info = XOBNEW (&parser_obstack, struct c_arg_info); tree parms = 0; - tree tags = 0; + VEC(c_arg_tag,gc) *tags = NULL; tree types = 0; tree others = 0; @@ -6246,6 +6245,7 @@ get_parm_info (bool ellipsis) { tree decl = b->decl; tree type = TREE_TYPE (decl); + c_arg_tag *tag; const char *keyword; switch (TREE_CODE (decl)) @@ -6319,7 +6319,9 @@ get_parm_info (bool ellipsis) } } - tags = tree_cons (b->id, decl, tags); + tag = VEC_safe_push (c_arg_tag, gc, tags, NULL); + tag->id = b->id; + tag->type = decl; break; case CONST_DECL: @@ -7644,6 +7646,8 @@ static void store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info) { tree decl; + c_arg_tag *tag; + unsigned ix; if (current_scope->bindings) { @@ -7696,9 +7700,9 @@ store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info) } /* And all the tag declarations. */ - for (decl = arg_info->tags; decl; decl = TREE_CHAIN (decl)) - if (TREE_PURPOSE (decl)) - bind (TREE_PURPOSE (decl), TREE_VALUE (decl), current_scope, + FOR_EACH_VEC_ELT_REVERSE (c_arg_tag, arg_info->tags, ix, tag) + if (tag->id) + bind (tag->id, tag->type, current_scope, /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION); } diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 984b597..745dd05 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -295,12 +295,22 @@ enum c_declarator_kind { cdk_attrs }; +typedef struct GTY(()) c_arg_tag_d { + /* The argument name. */ + tree id; + /* The type of the argument. */ + tree type; +} c_arg_tag; + +DEF_VEC_O(c_arg_tag); +DEF_VEC_ALLOC_O(c_arg_tag,gc); + /* Information about the parameters in a function declarator. */ struct c_arg_info { /* A list of parameter decls. */ tree parms; /* A list of structure, union and enum tags defined. */ - tree tags; + VEC(c_arg_tag,gc) *tags; /* A list of argument types to go in the FUNCTION_TYPE. */ tree types; /* A list of non-parameter decls (notably enumeration constants)