aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-05-09 12:43:27 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-05-09 12:43:27 -0400
commita3409c0279cf6f6f230c5d163472686867e2f89d (patch)
treebb9b7882752a4c7fd7ccc7af624ce9bf10c4bc5f /gcc/tree.c
parent66e6b9905b97c53e21db1de2ac3fbb0d46138a57 (diff)
downloadgcc-a3409c0279cf6f6f230c5d163472686867e2f89d.zip
gcc-a3409c0279cf6f6f230c5d163472686867e2f89d.tar.gz
gcc-a3409c0279cf6f6f230c5d163472686867e2f89d.tar.bz2
tree.c (build_constructor_va): New.
* tree.c (build_constructor_va): New. * tree.h: Declare it. From-SVN: r198744
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c21
1 files changed, 21 insertions, 0 deletions
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<constructor_elt, va_gc> *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