From daf68dd71ff9dc5c3f97743d702204be6fe253ae Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 26 Jul 1999 22:43:56 -0700 Subject: [PATCH] builtins.c (stabilize_va_list): Don't INDIRECT_REF through an ARRAY_TYPE. * builtins.c (stabilize_va_list): Don't INDIRECT_REF through an ARRAY_TYPE. (std_expand_builtin_va_start): Back out one word if !stdarg_p. (expand_builtin_va_end): Evaluate arg for side effects. * c-common.c (c_common_nodes_and_builtins): Construct a va_list_arg_type_node to handle array decomposition to pointer. From-SVN: r28283 --- gcc/ChangeLog | 9 +++++++++ gcc/builtins.c | 31 ++++++++++++++++++++++--------- gcc/c-common.c | 11 +++++++++-- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7685e77cae2..48610c366bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Mon Jul 26 22:43:12 1999 Richard Henderson + + * builtins.c (stabilize_va_list): Don't INDIRECT_REF through + an ARRAY_TYPE. + (std_expand_builtin_va_start): Back out one word if !stdarg_p. + (expand_builtin_va_end): Evaluate arg for side effects. + * c-common.c (c_common_nodes_and_builtins): Construct a + va_list_arg_type_node to handle array decomposition to pointer. + Mon Jul 26 18:51:34 1999 Richard Henderson * except.c (start_dynamic_cleanup): Use force_operand on the diff --git a/gcc/builtins.c b/gcc/builtins.c index 6d622ff2d17..20c8f1c0ed7 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1840,13 +1840,17 @@ stabilize_va_list (valist, was_ptr) if (is_array && TREE_CODE (valist) == ADDR_EXPR && TREE_CODE (TREE_TYPE (TREE_OPERAND (valist, 0))) == POINTER_TYPE) - valist = TREE_OPERAND (valist, 0); - - if (TREE_SIDE_EFFECTS (valist)) - valist = save_expr (valist); - - if (! is_array) - valist = fold (build1 (INDIRECT_REF, va_list_type_node, valist)); + { + valist = TREE_OPERAND (valist, 0); + if (TREE_SIDE_EFFECTS (valist)) + valist = save_expr (valist); + } + else + { + if (TREE_SIDE_EFFECTS (valist)) + valist = save_expr (valist); + valist = fold (build1 (INDIRECT_REF, va_list_type_node, valist)); + } } else if (TREE_SIDE_EFFECTS (valist)) { @@ -1875,6 +1879,9 @@ std_expand_builtin_va_start (stdarg_p, valist, nextarg) { tree t; + if (!stdarg_p) + nextarg = plus_constant (nextarg, -UNITS_PER_WORD); + t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, make_tree (ptr_type_node, nextarg)); TREE_SIDE_EFFECTS (t) = 1; @@ -2002,12 +2009,18 @@ expand_builtin_va_arg (valist, type) /* Expand ARGLIST, from a call to __builtin_va_end. */ static rtx expand_builtin_va_end (arglist) - tree arglist ATTRIBUTE_UNUSED; + tree arglist; { + tree valist = TREE_VALUE (arglist); + #ifdef EXPAND_BUILTIN_VA_END - tree valist = TREE_VALUE (arglist, 0); valist = stabilize_va_list (valist, 0); EXPAND_BUILTIN_VA_END(arglist); +#else + /* Evaluate for side effects, if needed. I hate macros that don't + do that. */ + if (TREE_SIDE_EFFECTS (valist)) + expand_expr (valist, const0_rtx, VOIDmode, EXPAND_NORMAL); #endif return const0_rtx; diff --git a/gcc/c-common.c b/gcc/c-common.c index 50a27fee96b..4c083de60f6 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3435,6 +3435,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) /* Either char* or void*. */ tree traditional_ptr_type_node; tree va_list_ptr_type_node; + tree va_list_arg_type_node; #ifdef BUILD_VA_LIST_TYPE BUILD_VA_LIST_TYPE(va_list_type_node); @@ -3443,8 +3444,14 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) #endif pushdecl (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"), va_list_type_node)); + va_list_ptr_type_node = build_pointer_type (va_list_type_node); + if (TREE_CODE (va_list_type_node) == ARRAY_TYPE) + va_list_arg_type_node = build_pointer_type (TREE_TYPE (va_list_type_node)); + else + va_list_arg_type_node = va_list_type_node; + endlink = void_list_node; int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink); double_endlink = tree_cons (NULL_TREE, double_type_node, endlink); @@ -3636,7 +3643,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) builtin_function ("__builtin_va_end", build_function_type (void_type_node, tree_cons (NULL_TREE, - va_list_type_node, + va_list_arg_type_node, endlink)), BUILT_IN_VA_END, NULL_PTR); @@ -3645,7 +3652,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) tree_cons (NULL_TREE, va_list_ptr_type_node, tree_cons (NULL_TREE, - va_list_type_node, + va_list_arg_type_node, endlink))), BUILT_IN_VA_COPY, NULL_PTR);