Commit 6ba4f08f by Eric Botcazou Committed by Eric Botcazou

trans.c (Identifier_to_gnu): Don't unshare initializer.

	* gcc-interface/trans.c (Identifier_to_gnu): Don't unshare initializer.
	(add_decl_expr): Mark external DECLs as used.
	* gcc-interface/utils.c (convert) <CONSTRUCTOR>: Copy the vector.

From-SVN: r185072
parent 95f2389a
2012-03-07 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Identifier_to_gnu): Don't unshare initializer.
(add_decl_expr): Mark external DECLs as used.
* gcc-interface/utils.c (convert) <CONSTRUCTOR>: Copy the vector.
2012-03-07 Tristan Gingold <gingold@adacore.com> 2012-03-07 Tristan Gingold <gingold@adacore.com>
* s-ransee-vms.adb: New file. * s-ransee-vms.adb: New file.
......
...@@ -1102,11 +1102,9 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) ...@@ -1102,11 +1102,9 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p)
= lvalue_required_p (gnat_node, gnu_result_type, true, = lvalue_required_p (gnat_node, gnu_result_type, true,
address_of_constant, Is_Aliased (gnat_temp)); address_of_constant, Is_Aliased (gnat_temp));
/* ??? We need to unshare the initializer if the object is external /* Finally retrieve the initializer if this is deemed valid. */
as such objects are not marked for unsharing if we are not at the
global level. This should be fixed in add_decl_expr. */
if ((constant_only && !address_of_constant) || !require_lvalue) if ((constant_only && !address_of_constant) || !require_lvalue)
gnu_result = unshare_expr (DECL_INITIAL (gnu_result)); gnu_result = DECL_INITIAL (gnu_result);
} }
/* The GNAT tree has the type of a function set to its result type, so we /* The GNAT tree has the type of a function set to its result type, so we
...@@ -7113,10 +7111,10 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity) ...@@ -7113,10 +7111,10 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
gnu_stmt = build1 (DECL_EXPR, void_type_node, gnu_decl); gnu_stmt = build1 (DECL_EXPR, void_type_node, gnu_decl);
/* If we are global, we don't want to actually output the DECL_EXPR for /* If we are external or global, we don't want to output the DECL_EXPR for
this decl since we already have evaluated the expressions in the this DECL node since we already have evaluated the expressions in the
sizes and positions as globals and doing it again would be wrong. */ sizes and positions as globals and doing it again would be wrong. */
if (global_bindings_p ()) if (DECL_EXTERNAL (gnu_decl) || global_bindings_p ())
{ {
/* Mark everything as used to prevent node sharing with subprograms. /* Mark everything as used to prevent node sharing with subprograms.
Note that walk_tree knows how to deal with TYPE_DECL, but neither Note that walk_tree knows how to deal with TYPE_DECL, but neither
...@@ -7135,7 +7133,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity) ...@@ -7135,7 +7133,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity)
&& !TYPE_FAT_POINTER_P (type)) && !TYPE_FAT_POINTER_P (type))
MARK_VISITED (TYPE_ADA_SIZE (type)); MARK_VISITED (TYPE_ADA_SIZE (type));
} }
else if (!DECL_EXTERNAL (gnu_decl)) else
add_stmt_with_node (gnu_stmt, gnat_entity); add_stmt_with_node (gnu_stmt, gnat_entity);
/* If this is a variable and an initializer is attached to it, it must be /* If this is a variable and an initializer is attached to it, it must be
......
...@@ -3894,6 +3894,8 @@ convert (tree type, tree expr) ...@@ -3894,6 +3894,8 @@ convert (tree type, tree expr)
{ {
expr = copy_node (expr); expr = copy_node (expr);
TREE_TYPE (expr) = type; TREE_TYPE (expr) = type;
CONSTRUCTOR_ELTS (expr)
= VEC_copy (constructor_elt, gc, CONSTRUCTOR_ELTS (expr));
return expr; return expr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment