aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2006-11-17 15:10:28 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2006-11-17 15:10:28 +0000
commit9fa25ead5321c9f0a35445d08f83d9116902da94 (patch)
tree954d33db5601434573843d37d6d8b505330d2f83 /gcc/ada
parent598ec7bdbe0e6e2f7c58961fd0f61e0898a3083e (diff)
downloadgcc-9fa25ead5321c9f0a35445d08f83d9116902da94.zip
gcc-9fa25ead5321c9f0a35445d08f83d9116902da94.tar.gz
gcc-9fa25ead5321c9f0a35445d08f83d9116902da94.tar.bz2
re PR ada/27936 (gnatbind fails to link)
PR ada/27936 * trans.c (add_decl_expr): Do not dynamically elaborate padded objects if the initializer takes into account the padding. From-SVN: r118939
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/trans.c60
2 files changed, 30 insertions, 36 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index cae53bb..cd6447b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-17 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/27936
+ * trans.c (add_decl_expr): Do not dynamically elaborate padded objects
+ if the initializer takes into account the padding.
+
2006-11-11 Richard Guenther <rguenther@suse.de>
* trans.c (maybe_stabilize_reference): Remove handling of
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c
index 873ad5f..8adff5e 100644
--- a/gcc/ada/trans.c
+++ b/gcc/ada/trans.c
@@ -4518,7 +4518,8 @@ add_stmt_with_node (tree gnu_stmt, Node_Id gnat_node)
void
add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
{
- tree gnu_stmt;
+ tree type = TREE_TYPE (gnu_decl);
+ tree gnu_stmt, gnu_init, gnu_lhs;
/* If this is a variable that Gigi is to ignore, we may have been given
an ERROR_MARK. So test for it. We also might have been given a
@@ -4526,7 +4527,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
ignore a TYPE_DECL for an UNCONSTRAINED_ARRAY_TYPE. */
if (!DECL_P (gnu_decl)
|| (TREE_CODE (gnu_decl) == TYPE_DECL
- && TREE_CODE (TREE_TYPE (gnu_decl)) == UNCONSTRAINED_ARRAY_TYPE))
+ && TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE))
return;
gnu_stmt = build1 (DECL_EXPR, void_type_node, gnu_decl);
@@ -4551,45 +4552,32 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
else
add_stmt_with_node (gnu_stmt, gnat_entity);
- /* If this is a DECL_EXPR for a variable with DECL_INITIAL set,
- there are two cases we need to handle here. */
- if (TREE_CODE (gnu_decl) == VAR_DECL && DECL_INITIAL (gnu_decl))
+ /* If this is a variable and an initializer is attached to it, it must be
+ valid for the context. Similar to init_const in create_var_decl_1. */
+ if (TREE_CODE (gnu_decl) == VAR_DECL
+ && (gnu_init = DECL_INITIAL (gnu_decl)) != NULL_TREE
+ && (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (gnu_init))
+ || (TREE_STATIC (gnu_decl)
+ && !initializer_constant_valid_p (gnu_init,
+ TREE_TYPE (gnu_init)))))
{
- tree gnu_init = DECL_INITIAL (gnu_decl);
- tree gnu_lhs = NULL_TREE;
-
- /* If this is a DECL_EXPR for a variable with DECL_INITIAL set
- and decl has a padded type, convert it to the unpadded type so the
- assignment is done properly. */
- if (TREE_CODE (TREE_TYPE (gnu_decl)) == RECORD_TYPE
- && TYPE_IS_PADDING_P (TREE_TYPE (gnu_decl)))
- gnu_lhs
- = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_decl))), gnu_decl);
-
- /* Otherwise, if this is going into memory and the initializer isn't
- valid for the assembler and loader. Gimplification could do this,
- but would be run too late if -fno-unit-at-a-time. */
- else if (TREE_STATIC (gnu_decl)
- && !initializer_constant_valid_p (gnu_init,
- TREE_TYPE (gnu_decl)))
+ /* If GNU_DECL has a padded type, convert it to the unpadded
+ type so the assignment is done properly. */
+ if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type))
+ gnu_lhs = convert (TREE_TYPE (TYPE_FIELDS (type)), gnu_decl);
+ else
gnu_lhs = gnu_decl;
- if (gnu_lhs)
- {
- tree gnu_assign_stmt
- = build_binary_op (MODIFY_EXPR, NULL_TREE,
- gnu_lhs, DECL_INITIAL (gnu_decl));
+ gnu_stmt = build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_lhs, gnu_init);
- DECL_INITIAL (gnu_decl) = NULL_TREE;
- if (TREE_READONLY (gnu_decl))
- {
- TREE_READONLY (gnu_decl) = 0;
- DECL_READONLY_ONCE_ELAB (gnu_decl) = 1;
- }
- annotate_with_locus (gnu_assign_stmt,
- DECL_SOURCE_LOCATION (gnu_decl));
- add_stmt (gnu_assign_stmt);
+ DECL_INITIAL (gnu_decl) = NULL_TREE;
+ if (TREE_READONLY (gnu_decl))
+ {
+ TREE_READONLY (gnu_decl) = 0;
+ DECL_READONLY_ONCE_ELAB (gnu_decl) = 1;
}
+
+ add_stmt_with_node (gnu_stmt, gnat_entity);
}
}