]>
Commit | Line | Data |
---|---|---|
56ed763e PS |
1 | --- gcc/gcc/gimplify.c 20 Jul 2005 01:18:18 -0000 2.142 |
2 | +++ gcc/gcc/gimplify.c 20 Jul 2005 17:03:36 -0000 | |
3 | @@ -298,6 +298,28 @@ create_artificial_label (void) | |
4 | return lab; | |
5 | } | |
6 | ||
7 | +/* Create an ADDR_EXPR for T, if T is a CONSTRUCTOR, create a temporary | |
8 | + variable to hold the CONSTRUCTOR. */ | |
9 | + | |
10 | +static tree | |
11 | +gimplify_build_fold_addr_expr (tree t) | |
12 | +{ | |
13 | + if (TREE_CODE (t) == CONSTRUCTOR) | |
14 | + { | |
15 | + tree new_t; | |
16 | + tree new_var | |
17 | + = create_tmp_var (TREE_TYPE (t), NULL); | |
18 | + TREE_ADDRESSABLE (new_var) = 1; | |
19 | + TREE_READONLY (new_var) = 1; | |
20 | + DECL_INITIAL (new_var) = t; | |
21 | + new_t = build1 (DECL_EXPR, void_type_node, new_var); | |
22 | + t = build_fold_addr_expr (new_var); | |
23 | + t = build2 (COMPOUND_EXPR, TREE_TYPE (t), new_t, t); | |
24 | + return t; | |
25 | + } | |
26 | + return build_fold_addr_expr (t); | |
27 | +} | |
28 | + | |
29 | /* Create a new temporary name with PREFIX. Returns an identifier. */ | |
30 | ||
31 | static GTY(()) unsigned int tmp_var_id_num; | |
32 | @@ -3224,9 +3246,9 @@ gimplify_variable_sized_compare (tree *e | |
33 | t = unshare_expr (t); | |
34 | t = SUBSTITUTE_PLACEHOLDER_IN_EXPR (t, op0); | |
35 | args = tree_cons (NULL, t, NULL); | |
36 | - t = build_fold_addr_expr (op1); | |
37 | + t = gimplify_build_fold_addr_expr (op1); | |
38 | args = tree_cons (NULL, t, args); | |
39 | - dest = build_fold_addr_expr (op0); | |
40 | + dest = gimplify_build_fold_addr_expr (op0); | |
41 | args = tree_cons (NULL, dest, args); | |
42 | t = implicit_built_in_decls[BUILT_IN_MEMCMP]; | |
43 | t = build_function_call_expr (t, args); | |
44 | @@ -3441,9 +3463,9 @@ gimplify_addr_expr (tree *expr_p, tree * | |
45 | same type. */ | |
46 | if (tree_ssa_useless_type_conversion (TREE_OPERAND (op0, 0))) | |
47 | op0 = TREE_OPERAND (op0, 0); | |
48 | - | |
49 | - *expr_p = fold_convert (TREE_TYPE (expr), | |
50 | - build_fold_addr_expr (TREE_OPERAND (op0, 0))); | |
51 | + | |
52 | + op0 = gimplify_build_fold_addr_expr (TREE_OPERAND (op0, 0)); | |
53 | + *expr_p = fold_convert (TREE_TYPE (expr), op0); | |
54 | ret = GS_OK; | |
55 | break; | |
56 | ||
57 | --- gcc/gcc/ada/trans.c 20 Jul 2005 01:18:53 -0000 1.101 | |
58 | +++ gcc/gcc/ada/trans.c 20 Jul 2005 17:03:39 -0000 | |
59 | @@ -4549,28 +4549,6 @@ gnat_gimplify_expr (tree *expr_p, tree * | |
60 | *expr_p = TREE_OPERAND (*expr_p, 0); | |
61 | return GS_OK; | |
62 | ||
63 | - case ADDR_EXPR: | |
64 | - /* If we're taking the address of a constant CONSTRUCTOR, force it to | |
65 | - be put into static memory. We know it's going to be readonly given | |
66 | - the semantics we have and it's required to be static memory in | |
67 | - the case when the reference is in an elaboration procedure. */ | |
68 | - if (TREE_CODE (TREE_OPERAND (expr, 0)) == CONSTRUCTOR | |
69 | - && TREE_CONSTANT (TREE_OPERAND (expr, 0))) | |
70 | - { | |
71 | - tree new_var | |
72 | - = create_tmp_var (TREE_TYPE (TREE_OPERAND (expr, 0)), "C"); | |
73 | - | |
74 | - TREE_READONLY (new_var) = 1; | |
75 | - TREE_STATIC (new_var) = 1; | |
76 | - TREE_ADDRESSABLE (new_var) = 1; | |
77 | - DECL_INITIAL (new_var) = TREE_OPERAND (expr, 0); | |
78 | - | |
79 | - TREE_OPERAND (expr, 0) = new_var; | |
80 | - recompute_tree_invarant_for_addr_expr (expr); | |
81 | - return GS_ALL_DONE; | |
82 | - } | |
83 | - return GS_UNHANDLED; | |
84 | - | |
85 | case COMPONENT_REF: | |
86 | /* We have a kludge here. If the FIELD_DECL is from a fat pointer and is | |
87 | from an early dummy type, replace it with the proper FIELD_DECL. */ | |
88 | @@ -5361,7 +5339,6 @@ addressable_p (tree gnu_expr) | |
89 | ||
90 | case UNCONSTRAINED_ARRAY_REF: | |
91 | case INDIRECT_REF: | |
92 | - case CONSTRUCTOR: | |
93 | case NULL_EXPR: | |
94 | case SAVE_EXPR: | |
95 | return true; | |
96 | --- gcc/gcc/ada/utils2.c 20 Jul 2005 01:18:55 -0000 1.50 | |
97 | +++ gcc/gcc/ada/utils2.c 20 Jul 2005 17:03:39 -0000 | |
98 | @@ -45,6 +45,8 @@ | |
99 | #include "einfo.h" | |
100 | #include "ada-tree.h" | |
101 | #include "gigi.h" | |
102 | +#include "tree-gimple.h" | |
103 | +#include "toplev.h" | |
104 | ||
105 | static tree find_common_type (tree, tree); | |
106 | static bool contains_save_expr_p (tree); | |
107 | @@ -1032,6 +1034,7 @@ build_unary_op (enum tree_code op_code, | |
108 | tree operation_type = result_type; | |
109 | tree result; | |
110 | bool side_effects = false; | |
111 | + tree before = NULL; | |
112 | ||
113 | if (operation_type | |
114 | && TREE_CODE (operation_type) == RECORD_TYPE | |
115 | @@ -1150,6 +1153,22 @@ build_unary_op (enum tree_code op_code, | |
116 | result); | |
117 | break; | |
118 | } | |
119 | + else | |
120 | + { | |
121 | + /* Create a temporary variable to hold the CONSTRUCTON. */ | |
122 | + tree new_var = create_tmp_var_raw (type, NULL); | |
123 | + TREE_ADDRESSABLE (new_var) = 1; | |
124 | + TREE_READONLY (new_var) = 1; | |
125 | + if (global_bindings_p ()) | |
126 | + TREE_STATIC (new_var) = 1; | |
127 | + DECL_INITIAL (new_var) = operand; | |
128 | + gnat_pushdecl (new_var, Empty); | |
129 | + if (global_bindings_p ()) | |
130 | + rest_of_decl_compilation (new_var, 1, 0); | |
131 | + else | |
132 | + before = build1 (DECL_EXPR, void_type_node, new_var); | |
133 | + operand = new_var; | |
134 | + } | |
135 | ||
136 | goto common; | |
137 | ||
138 | @@ -1198,6 +1217,9 @@ build_unary_op (enum tree_code op_code, | |
139 | } | |
140 | ||
141 | TREE_CONSTANT (result) = staticp (operand) || TREE_CONSTANT (operand); | |
142 | + if (before) | |
143 | + result = build2 (COMPOUND_EXPR, TREE_TYPE (result), before, | |
144 | + result); | |
145 | break; | |
146 | ||
147 | case INDIRECT_REF: | |
148 | @@ -1964,10 +1986,6 @@ gnat_mark_addressable (tree expr_node) | |
149 | expr_node = TREE_OPERAND (expr_node, 0); | |
150 | break; | |
151 | ||
152 | - case CONSTRUCTOR: | |
153 | - TREE_ADDRESSABLE (expr_node) = 1; | |
154 | - return true; | |
155 | - | |
156 | case VAR_DECL: | |
157 | case PARM_DECL: | |
158 | case RESULT_DECL: |