trans.c (Subprogram_Body_to_gnu): Add comment.

* gcc-interface/trans.c (Subprogram_Body_to_gnu): Add comment.
	(gnat_to_gnu) <N_Return_Statement>: Add 'else' to avoid doing a useless
	test.  Tweak default case.
	<N_Goto_Statement>: Use better formatting.
	* gcc-interface/utils2.c (maybe_wrap_malloc): Use INIT_EXPR instead of
	MODIFY_EXPR to initialize the storage.
	(build_allocator): Likewise.

From-SVN: r181527
This commit is contained in:
Eric Botcazou 2011-11-20 10:16:48 +00:00 committed by Eric Botcazou
parent b1a785fb5e
commit 0d24bf7601
3 changed files with 21 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2011-10-20 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Subprogram_Body_to_gnu): Add comment.
(gnat_to_gnu) <N_Return_Statement>: Add 'else' to avoid doing a useless
test. Tweak default case.
<N_Goto_Statement>: Use better formatting.
* gcc-interface/utils2.c (maybe_wrap_malloc): Use INIT_EXPR instead of
MODIFY_EXPR to initialize the storage.
(build_allocator): Likewise.
2011-11-20 Eric Botcazou <ebotcazou@adacore.com> 2011-11-20 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Adjust * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Adjust

View File

@ -3278,6 +3278,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
save_gnu_tree (gnat_param, NULL_TREE, false); save_gnu_tree (gnat_param, NULL_TREE, false);
} }
/* Disconnect the variable created for the return value. */
if (gnu_return_var_elmt) if (gnu_return_var_elmt)
TREE_VALUE (gnu_return_var_elmt) = void_type_node; TREE_VALUE (gnu_return_var_elmt) = void_type_node;
@ -5889,12 +5890,12 @@ gnat_to_gnu (Node_Id gnat_node)
gnat_node, false); gnat_node, false);
} }
/* If the function returns by invisible reference, dereference /* Otherwise, if it returns by invisible reference, dereference
the pointer it is passed using the type of the return value the pointer it is passed using the type of the return value
and build the copy operation manually. This ensures that we and build the copy operation manually. This ensures that we
don't copy too much data, for example if the return type is don't copy too much data, for example if the return type is
unconstrained with a maximum size. */ unconstrained with a maximum size. */
if (TREE_ADDRESSABLE (gnu_subprog_type)) else if (TREE_ADDRESSABLE (gnu_subprog_type))
{ {
tree gnu_ret_deref tree gnu_ret_deref
= build_unary_op (INDIRECT_REF, TREE_TYPE (gnu_ret_val), = build_unary_op (INDIRECT_REF, TREE_TYPE (gnu_ret_val),
@ -5905,11 +5906,9 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_ret_val = NULL_TREE; gnu_ret_val = NULL_TREE;
} }
} }
else else
{ gnu_ret_obj = gnu_ret_val = NULL_TREE;
gnu_ret_obj = NULL_TREE;
gnu_ret_val = NULL_TREE;
}
/* If we have a return label defined, convert this into a branch to /* If we have a return label defined, convert this into a branch to
that label. The return proper will be handled elsewhere. */ that label. The return proper will be handled elsewhere. */
@ -5934,8 +5933,8 @@ gnat_to_gnu (Node_Id gnat_node)
break; break;
case N_Goto_Statement: case N_Goto_Statement:
gnu_result = build1 (GOTO_EXPR, void_type_node, gnu_result
gnat_to_gnu (Name (gnat_node))); = build1 (GOTO_EXPR, void_type_node, gnat_to_gnu (Name (gnat_node)));
break; break;
/***************************/ /***************************/

View File

@ -2126,7 +2126,7 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node)
return return
build2 (COMPOUND_EXPR, TREE_TYPE (aligning_field_addr), build2 (COMPOUND_EXPR, TREE_TYPE (aligning_field_addr),
build_binary_op (MODIFY_EXPR, NULL_TREE, build_binary_op (INIT_EXPR, NULL_TREE,
storage_ptr_slot, storage_ptr), storage_ptr_slot, storage_ptr),
aligning_field_addr); aligning_field_addr);
} }
@ -2279,12 +2279,12 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (storage_type)), CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (storage_type)),
init); init);
storage_init storage_init
= build_binary_op (MODIFY_EXPR, NULL_TREE, storage_deref, = build_binary_op (INIT_EXPR, NULL_TREE, storage_deref,
gnat_build_constructor (storage_type, v)); gnat_build_constructor (storage_type, v));
} }
else else
storage_init storage_init
= build_binary_op (MODIFY_EXPR, NULL_TREE, = build_binary_op (INIT_EXPR, NULL_TREE,
build_component_ref (storage_deref, NULL_TREE, build_component_ref (storage_deref, NULL_TREE,
TYPE_FIELDS (storage_type), TYPE_FIELDS (storage_type),
false), false),
@ -2332,7 +2332,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
storage_deref = build_unary_op (INDIRECT_REF, NULL_TREE, storage); storage_deref = build_unary_op (INDIRECT_REF, NULL_TREE, storage);
TREE_THIS_NOTRAP (storage_deref) = 1; TREE_THIS_NOTRAP (storage_deref) = 1;
storage_init storage_init
= build_binary_op (MODIFY_EXPR, NULL_TREE, storage_deref, init); = build_binary_op (INIT_EXPR, NULL_TREE, storage_deref, init);
return build2 (COMPOUND_EXPR, result_type, storage_init, storage); return build2 (COMPOUND_EXPR, result_type, storage_init, storage);
} }