* cp-tree.h (cp_build_function_call_nary): Declare.
* typeck.c (cp_build_function_call_nary): Define.
* decl.c (register_dtor_fn): Use it instead of
cp_build_function_call.
(cxx_maybe_build_cleanup): Likewise.
* decl2.c (generate_ctor_or_dtor_function): Likewise.
* except.c (do_get_exception_ptr): Likewise.
(do_begin_catch): Likewise.
(do_allocate_exception): Likewise.
(do_free_exception): Likewise.
(build_throw): Likewise. Use cp_build_function_call_vec instead
of cp_build_function_call.
(do_end_catch): Likewise.
From-SVN: r160045
2010-05-29 Nathan Froyd <froydnj@codesourcery.com>
+ * cp-tree.h (cp_build_function_call_nary): Declare.
+ * typeck.c (cp_build_function_call_nary): Define.
+ * decl.c (register_dtor_fn): Use it instead of
+ cp_build_function_call.
+ (cxx_maybe_build_cleanup): Likewise.
+ * decl2.c (generate_ctor_or_dtor_function): Likewise.
+ * except.c (do_get_exception_ptr): Likewise.
+ (do_begin_catch): Likewise.
+ (do_allocate_exception): Likewise.
+ (do_free_exception): Likewise.
+ (build_throw): Likewise. Use cp_build_function_call_vec instead
+ of cp_build_function_call.
+ (do_end_catch): Likewise.
+
+2010-05-29 Nathan Froyd <froydnj@codesourcery.com>
+
* cp-tree.h (struct cp_decl_specifier_seq): Move type_location field up.
(struct cp_declarator): Move id_loc field up.
tsubst_flags_t);
extern tree get_member_function_from_ptrfunc (tree *, tree);
extern tree cp_build_function_call (tree, tree, tsubst_flags_t);
+extern tree cp_build_function_call_nary (tree, tsubst_flags_t, ...)
+ ATTRIBUTE_SENTINEL;
extern tree cp_build_function_call_vec (tree, VEC(tree,gc) **,
tsubst_flags_t);
extern tree build_x_binary_op (enum tree_code, tree,
{
tree cleanup;
tree compound_stmt;
- tree args;
tree fcall;
tree type;
bool use_dtor;
+ tree arg0, arg1 = NULL_TREE, arg2 = NULL_TREE;
type = TREE_TYPE (decl);
if (TYPE_HAS_TRIVIAL_DESTRUCTOR (type))
in, and, in general, it's cheaper to pass NULL than any
other value. */
addr = null_pointer_node;
- args = tree_cons (NULL_TREE,
- cp_build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0,
- tf_warning_or_error),
- NULL_TREE);
+ arg2 = cp_build_unary_op (ADDR_EXPR, get_dso_handle_node (), 0,
+ tf_warning_or_error);
if (targetm.cxx.use_aeabi_atexit ())
{
- args = tree_cons (NULL_TREE, cleanup, args);
- args = tree_cons (NULL_TREE, addr, args);
+ arg1 = cleanup;
+ arg0 = addr;
}
else
{
- args = tree_cons (NULL_TREE, addr, args);
- args = tree_cons (NULL_TREE, cleanup, args);
+ arg1 = addr;
+ arg0 = cleanup;
}
}
else
- args = tree_cons (NULL_TREE, cleanup, NULL_TREE);
- return cp_build_function_call (get_atexit_node (), args,
- tf_warning_or_error);
+ arg0 = cleanup;
+ return cp_build_function_call_nary (get_atexit_node (), tf_warning_or_error,
+ arg0, arg1, arg2, NULL_TREE);
}
/* DECL is a VAR_DECL with static storage duration. INIT, if present,
fn = lookup_name (id);
arg = build_address (decl);
mark_used (decl);
- cleanup = cp_build_function_call (fn, build_tree_list (NULL_TREE,
- arg),
- tf_warning_or_error);
+ cleanup = cp_build_function_call_nary (fn, tf_warning_or_error,
+ arg, NULL_TREE);
}
/* Handle ordinary C++ destructors. */
type = TREE_TYPE (decl);
location_t *locus)
{
char function_key;
- tree arguments;
tree fndecl;
tree body;
size_t i;
/* Calls to pure or const functions will expand to nothing. */
if (! (flags_from_decl_or_type (fndecl) & (ECF_CONST | ECF_PURE)))
{
+ tree call;
+
if (! body)
body = start_objects (function_key, priority);
- arguments = tree_cons (NULL_TREE,
- build_int_cst (NULL_TREE, priority),
- NULL_TREE);
- arguments = tree_cons (NULL_TREE,
- build_int_cst (NULL_TREE, constructor_p),
- arguments);
- finish_expr_stmt (cp_build_function_call (fndecl, arguments,
- tf_warning_or_error));
+ call = cp_build_function_call_nary (fndecl, tf_warning_or_error,
+ build_int_cst (NULL_TREE,
+ constructor_p),
+ build_int_cst (NULL_TREE,
+ priority),
+ NULL_TREE);
+ finish_expr_stmt (call);
}
}
fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
}
- return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
- NULL_TREE),
- tf_warning_or_error);
+ return cp_build_function_call_nary (fn, tf_warning_or_error,
+ build_exc_ptr (), NULL_TREE);
}
/* Build up a call to __cxa_begin_catch, to tell the runtime that the
fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
}
- return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
- NULL_TREE),
- tf_warning_or_error);
+ return cp_build_function_call_nary (fn, tf_warning_or_error,
+ build_exc_ptr (), NULL_TREE);
}
/* Returns nonzero if cleaning up an exception of type TYPE (which can be
TREE_NOTHROW (fn) = 0;
}
- cleanup = cp_build_function_call (fn, NULL_TREE, tf_warning_or_error);
+ cleanup = cp_build_function_call_vec (fn, NULL, tf_warning_or_error);
TREE_NOTHROW (cleanup) = dtor_nothrow (type);
return cleanup;
fn = declare_nothrow_library_fn (fn, ptr_type_node, size_type_node);
}
- return cp_build_function_call (fn,
- tree_cons (NULL_TREE, size_in_bytes (type),
- NULL_TREE),
- tf_warning_or_error);
+ return cp_build_function_call_nary (fn, tf_warning_or_error,
+ size_in_bytes (type), NULL_TREE);
}
/* Call __cxa_free_exception from a cleanup. This is never invoked
fn = declare_nothrow_library_fn (fn, void_type_node, ptr_type_node);
}
- return cp_build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE),
- tf_warning_or_error);
+ return cp_build_function_call_nary (fn, tf_warning_or_error, ptr, NULL_TREE);
}
/* Wrap all cleanups for TARGET_EXPRs in MUST_NOT_THROW_EXPR.
return error_mark_node;
}
fn = OVL_CURRENT (fn);
- exp = cp_build_function_call (fn, tree_cons (NULL_TREE, exp, NULL_TREE),
- tf_warning_or_error);
+ exp = cp_build_function_call_nary (fn, tf_warning_or_error,
+ exp, NULL_TREE);
}
else if (exp)
{
else
cleanup = build_int_cst (cleanup_type, 0);
- tmp = tree_cons (NULL_TREE, cleanup, NULL_TREE);
- tmp = tree_cons (NULL_TREE, throw_type, tmp);
- tmp = tree_cons (NULL_TREE, ptr, tmp);
/* ??? Indicate that this function call throws throw_type. */
- tmp = cp_build_function_call (fn, tmp, tf_warning_or_error);
+ tmp = cp_build_function_call_nary (fn, tf_warning_or_error,
+ ptr, throw_type, cleanup, NULL_TREE);
/* Tack on the initialization stuff. */
exp = build2 (COMPOUND_EXPR, TREE_TYPE (tmp), exp, tmp);
/* ??? Indicate that this function call allows exceptions of the type
of the enclosing catch block (if known). */
- exp = cp_build_function_call (fn, NULL_TREE, tf_warning_or_error);
+ exp = cp_build_function_call_vec (fn, NULL, tf_warning_or_error);
}
exp = build1 (THROW_EXPR, void_type_node, exp);
return ret;
}
+/* Build a function call using varargs. */
+
+tree
+cp_build_function_call_nary (tree function, tsubst_flags_t complain, ...)
+{
+ VEC(tree,gc) *vec;
+ va_list args;
+ tree ret, t;
+
+ vec = make_tree_vector ();
+ va_start (args, complain);
+ for (t = va_arg (args, tree); t != NULL_TREE; t = va_arg (args, tree))
+ VEC_safe_push (tree, gc, vec, t);
+ va_end (args);
+ ret = cp_build_function_call_vec (function, &vec, complain);
+ release_tree_vector (vec);
+ return ret;
+}
+
/* Build a function call using a vector of arguments. PARAMS may be
NULL if there are no parameters. This changes the contents of
PARAMS. */