--- gcc/gcc/gimplify.c 20 Jul 2005 01:18:18 -0000 2.142 +++ gcc/gcc/gimplify.c 24 Jul 2005 10:10:35 -0000 @@ -298,6 +298,25 @@ return lab; } +static tree +gimplify_build_fold_addr_expr (tree t) +{ + if (TREE_CODE (t) == CONSTRUCTOR) + { + tree new_t; + tree new_var + = create_tmp_var (TREE_TYPE (t), "ATP"); + TREE_ADDRESSABLE (new_var) = 1; + TREE_READONLY (new_var) = 1; + DECL_INITIAL (new_var) = t; + new_t = build1 (DECL_EXPR, void_type_node, new_var); + t = build_fold_addr_expr (new_var); + t = build2 (COMPOUND_EXPR, TREE_TYPE (t), new_t, t); + return t; + } + return build_fold_addr_expr (t); +} + /* Create a new temporary name with PREFIX. Returns an identifier. */ static GTY(()) unsigned int tmp_var_id_num; @@ -3224,9 +3243,10 @@ t = unshare_expr (t); t = SUBSTITUTE_PLACEHOLDER_IN_EXPR (t, op0); args = tree_cons (NULL, t, NULL); - t = build_fold_addr_expr (op1); + + t = gimplify_build_fold_addr_expr (op1); args = tree_cons (NULL, t, args); - dest = build_fold_addr_expr (op0); + dest = gimplify_build_fold_addr_expr (op0); args = tree_cons (NULL, dest, args); t = implicit_built_in_decls[BUILT_IN_MEMCMP]; t = build_function_call_expr (t, args); @@ -3443,7 +3463,7 @@ op0 = TREE_OPERAND (op0, 0); *expr_p = fold_convert (TREE_TYPE (expr), - build_fold_addr_expr (TREE_OPERAND (op0, 0))); + gimplify_build_fold_addr_expr (TREE_OPERAND (op0, 0))); ret = GS_OK; break; @@ -4473,7 +4493,7 @@ /* An lvalue will do. Take the address of the expression, store it in a temporary, and replace the expression with an INDIRECT_REF of that temporary. */ - tmp = build_fold_addr_expr (*expr_p); + tmp = gimplify_build_fold_addr_expr (*expr_p); gimplify_expr (&tmp, pre_p, post_p, is_gimple_reg, fb_rvalue); *expr_p = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (tmp)), tmp); } --- gcc/gcc/ada/trans.c 20 Jul 2005 01:18:53 -0000 1.101 +++ gcc/gcc/ada/trans.c 24 Jul 2005 10:10:37 -0000 @@ -3585,6 +3585,7 @@ else gnu_lhs = DECL_RESULT (current_function_decl); +#if 0 /* Do not remove the padding from GNU_RET_VAL if the inner type is self-referential since we want to allocate the fixed size in that case. */ @@ -3596,6 +3597,7 @@ && (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (TREE_TYPE (gnu_ret_val))))) gnu_ret_val = TREE_OPERAND (gnu_ret_val, 0); +#endif if (TYPE_RETURNS_BY_REF_P (gnu_subprog_type) || By_Ref (gnat_node)) @@ -4549,28 +4551,6 @@ *expr_p = TREE_OPERAND (*expr_p, 0); return GS_OK; - case ADDR_EXPR: - /* If we're taking the address of a constant CONSTRUCTOR, force it to - be put into static memory. We know it's going to be readonly given - the semantics we have and it's required to be static memory in - the case when the reference is in an elaboration procedure. */ - if (TREE_CODE (TREE_OPERAND (expr, 0)) == CONSTRUCTOR - && TREE_CONSTANT (TREE_OPERAND (expr, 0))) - { - tree new_var - = create_tmp_var (TREE_TYPE (TREE_OPERAND (expr, 0)), "C"); - - TREE_READONLY (new_var) = 1; - TREE_STATIC (new_var) = 1; - TREE_ADDRESSABLE (new_var) = 1; - DECL_INITIAL (new_var) = TREE_OPERAND (expr, 0); - - TREE_OPERAND (expr, 0) = new_var; - recompute_tree_invarant_for_addr_expr (expr); - return GS_ALL_DONE; - } - return GS_UNHANDLED; - case COMPONENT_REF: /* We have a kludge here. If the FIELD_DECL is from a fat pointer and is from an early dummy type, replace it with the proper FIELD_DECL. */ @@ -5361,7 +5341,7 @@ case UNCONSTRAINED_ARRAY_REF: case INDIRECT_REF: - case CONSTRUCTOR: +/* case CONSTRUCTOR:*/ case NULL_EXPR: case SAVE_EXPR: return true; --- gcc/gcc/ada/utils2.c 20 Jul 2005 01:18:55 -0000 1.50 +++ gcc/gcc/ada/utils2.c 24 Jul 2005 10:10:37 -0000 @@ -45,6 +45,8 @@ #include "einfo.h" #include "ada-tree.h" #include "gigi.h" +#include "tree-gimple.h" +#include "toplev.h" static tree find_common_type (tree, tree); static bool contains_save_expr_p (tree); @@ -1032,6 +1034,7 @@ tree operation_type = result_type; tree result; bool side_effects = false; + tree before = NULL; if (operation_type && TREE_CODE (operation_type) == RECORD_TYPE @@ -1150,6 +1153,22 @@ result); break; } + else + { + tree new_var = create_tmp_var_raw (type, "C"); + TREE_ADDRESSABLE (new_var) = 1; + TREE_READONLY (new_var) = 1; + if (global_bindings_p ()) + TREE_STATIC (new_var) = 1; + DECL_INITIAL (new_var) = operand; + gnat_pushdecl (new_var, Empty); + + if (global_bindings_p ()) + rest_of_decl_compilation (new_var, 1, 0); + else + before = build1 (DECL_EXPR, void_type_node, new_var); + operand = new_var; + } goto common; @@ -1198,6 +1217,9 @@ } TREE_CONSTANT (result) = staticp (operand) || TREE_CONSTANT (operand); + if (before) + result = build2 (COMPOUND_EXPR, TREE_TYPE (result), before, + result); break; case INDIRECT_REF: