From: Nathan Froyd Date: Sun, 30 May 2010 03:03:14 +0000 (+0000) Subject: cp-tree.h (cp_build_function_call_nary): Declare. X-Git-Tag: upstream/12.2.0~92757 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=450f429348300e614722d03966ce898ab3ffb7f5;p=platform%2Fupstream%2Fgcc.git cp-tree.h (cp_build_function_call_nary): Declare. * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 316c717..84b3bb4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,21 @@ 2010-05-29 Nathan Froyd + * 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 + * cp-tree.h (struct cp_decl_specifier_seq): Move type_location field up. (struct cp_declarator): Move id_loc field up. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index db4fb0a..da8293f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5371,6 +5371,8 @@ extern tree cp_build_array_ref (location_t, tree, tree, 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, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0d30340..b9f3ea8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6240,10 +6240,10 @@ register_dtor_fn (tree decl) { 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)) @@ -6321,25 +6321,23 @@ register_dtor_fn (tree decl) 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, @@ -12936,9 +12934,8 @@ cxx_maybe_build_cleanup (tree decl) 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); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0313101..0692e1a 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3275,7 +3275,6 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority, location_t *locus) { char function_key; - tree arguments; tree fndecl; tree body; size_t i; @@ -3308,17 +3307,18 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority, /* 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); } } diff --git a/gcc/cp/except.c b/gcc/cp/except.c index de49095..6f7f70a 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -180,9 +180,8 @@ do_get_exception_ptr (void) 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 @@ -200,9 +199,8 @@ do_begin_catch (void) 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 @@ -240,7 +238,7 @@ do_end_catch (tree type) 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; @@ -565,10 +563,8 @@ do_allocate_exception (tree type) 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 @@ -586,8 +582,7 @@ do_free_exception (tree ptr) 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. @@ -665,8 +660,8 @@ build_throw (tree exp) 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) { @@ -797,11 +792,9 @@ build_throw (tree 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); @@ -820,7 +813,7 @@ build_throw (tree exp) /* ??? 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); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 4ad9349..a7d04dd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3225,6 +3225,25 @@ cp_build_function_call (tree function, tree params, tsubst_flags_t complain) 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. */