From a3409c0279cf6f6f230c5d163472686867e2f89d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 9 May 2013 12:43:27 -0400 Subject: [PATCH] tree.c (build_constructor_va): New. * tree.c (build_constructor_va): New. * tree.h: Declare it. From-SVN: r198744 --- gcc/ChangeLog | 5 +++++ gcc/tree.c | 21 +++++++++++++++++++++ gcc/tree.h | 1 + 3 files changed, 27 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 34c83ac..e163165 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-05-09 Jason Merrill + + * tree.c (build_constructor_va): New. + * tree.h: Declare it. + 2013-05-09 Martin Jambor PR lto/57084 diff --git a/gcc/tree.c b/gcc/tree.c index 444c876..55fa99b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1467,6 +1467,27 @@ build_constructor_from_list (tree type, tree vals) return build_constructor (type, v); } +/* Return a new CONSTRUCTOR node whose type is TYPE. NELTS is the number + of elements, provided as index/value pairs. */ + +tree +build_constructor_va (tree type, int nelts, ...) +{ + vec *v = NULL; + va_list p; + + va_start (p, nelts); + vec_alloc (v, nelts); + while (nelts--) + { + tree index = va_arg (p, tree); + tree value = va_arg (p, tree); + 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 2b6f13b..cd1d7613 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, int, ...); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); extern tree build_one_cst (tree); -- 2.7.4