tree.c (build_constructor_va): New.
authorJason Merrill <jason@redhat.com>
Thu, 9 May 2013 16:43:27 +0000 (12:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 9 May 2013 16:43:27 +0000 (12:43 -0400)
* tree.c (build_constructor_va): New.
* tree.h: Declare it.

From-SVN: r198744

gcc/ChangeLog
gcc/tree.c
gcc/tree.h

index 34c83ac..e163165 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-09  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (build_constructor_va): New.
+       * tree.h: Declare it.
+
 2013-05-09  Martin Jambor  <mjambor@suse.cz>
 
        PR lto/57084
index 444c876..55fa99b 100644 (file)
@@ -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
index 2b6f13b..cd1d761 100644 (file)
@@ -4763,6 +4763,7 @@ extern tree build_vector_from_val (tree, tree);
 extern tree build_constructor (tree, vec<constructor_elt, va_gc> *);
 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);