From patchwork Tue May 7 03:20:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 241921 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 566052C0134 for ; Tue, 7 May 2013 13:20:17 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=a9hqmonKdIYDv9KaUHW6OZhRQpasU2Y1QGGQpxFCmkE0BB 2/s+4TP67eVvs4gE7sbwHYcXArVDYW91f2YZfblCK07mmZ3e5+WaqQnqu1SjkiQX K6yyeU+ycILRnl3V97rBZ16u6J+kv/3DBi8KCfPlEDSMJSKL4IfKo6fseVkmE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=cZ+XzY3qrtwz2bGYvROg5d9wbfU=; b=CutGRAnX+tsodgY7yMk2 07TYh8N7DwPgOn6pAzw+6h2jggJG9CzDY/iuBC//O8+UpnWB4WkclK4Kn5zA9++3 yM6A+zuDhxPgYNmHTdmAX+1DOg+x6GciijTbRsJ3eq35zzLOLs17T31+nZghWeLL 8xuqmtYQ4Z1KE2e9QtA332g= Received: (qmail 31798 invoked by alias); 7 May 2013 03:20:11 -0000 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 Received: (qmail 31762 invoked by uid 89); 7 May 2013 03:20:07 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 07 May 2013 03:20:06 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r473K1D1010524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 May 2013 23:20:01 -0400 Received: from [10.3.113.33] (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r473K0Mq004333; Mon, 6 May 2013 23:20:01 -0400 Message-ID: <518872E0.3090904@redhat.com> Date: Mon, 06 May 2013 23:20:00 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Thunderbird/22.0a2 MIME-Version: 1.0 To: gcc-patches List , Jakub Jelinek Subject: RFA: PATCH to add variadic version of build_constructor X-Virus-Found: No Most build_* functions have variadic versions, but build_constructor doesn't as of yet, and it would be convenient for a patch I'm working on. I decided to call it build_constructor_va, but am open to other naming ideas. Tested x86_64-pc-linux-gnu. OK for trunk? commit 7cab86001c233a8cac209e905aafe796560b80ff Author: Jason Merrill Date: Mon May 6 23:15:08 2013 -0400 * tree.c (build_constructor_va): New. * tree.h: Declare it. diff --git a/gcc/tree.c b/gcc/tree.c index d8f2424..9782fba 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1467,6 +1467,29 @@ build_constructor_from_list (tree type, tree vals) return build_constructor (type, v); } +/* Return a new CONSTRUCTOR node whose type is TYPE. If additional + arguments are provided, they are index/value pairs. The list must be + terminated by two NULL_TREEs. */ + +tree +build_constructor_va (tree type, ...) +{ + vec *v = NULL; + va_list p; + + va_start (p, type); + while (true) + { + tree index = va_arg (p, tree); + tree value = va_arg (p, tree); + if (index == NULL_TREE && value == NULL_TREE) + break; + CONSTRUCTOR_APPEND_ELT (v, index, value); + } + va_end (p); + return build_constructor (type, v); +} + /* Return a new FIXED_CST node whose type is TYPE and value is F. */ tree diff --git a/gcc/tree.h b/gcc/tree.h index be43440..5150237 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4763,6 +4763,7 @@ extern tree build_vector_from_val (tree, tree); extern tree build_constructor (tree, vec *); extern tree build_constructor_single (tree, tree, tree); extern tree build_constructor_from_list (tree, tree); +extern tree build_constructor_va (tree, ...); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); extern tree build_one_cst (tree);