Commit a10623fb by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Explicitly test _LEVEL variables against zero in all cases.

	* gcc-interface/decl.c (gnat_to_gnu_entity): Explicitly test _LEVEL
	variables against zero in all cases.
	(rest_of_type_decl_compilation): Likewise.
	* gcc-interface/trans.c (gigi): Pass properly typed constants to
	create_var_decl.
	(call_to_gnu): Fix formatting.
	(Handled_Sequence_Of_Statements_to_gnu): Likewise.
	(Exception_Handler_to_gnu_zcx): Likewise.
	(gnat_to_gnu) <N_Object_Declaration>: Short-circuit handling of
	constant
	expressions in presence of a freeze node.

From-SVN: r164415
parent 50a6af05
2010-09-19 Eric Botcazou <ebotcazou@adacore.com> 2010-09-19 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Explicitly test _LEVEL
variables against zero in all cases.
(rest_of_type_decl_compilation): Likewise.
* gcc-interface/trans.c (gigi): Pass properly typed constants to
create_var_decl.
(call_to_gnu): Fix formatting.
(Handled_Sequence_Of_Statements_to_gnu): Likewise.
(Exception_Handler_to_gnu_zcx): Likewise.
(gnat_to_gnu) <N_Object_Declaration>: Short-circuit handling of
constant
expressions in presence of a freeze node.
2010-09-19 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Look into * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Look into
expressions for external constants that are aggregates. expressions for external constants that are aggregates.
* gcc-interface/utils2.c (build_simple_component_ref): If the field * gcc-interface/utils2.c (build_simple_component_ref): If the field
......
...@@ -3510,7 +3510,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3510,7 +3510,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& TYPE_IS_DUMMY_P && TYPE_IS_DUMMY_P
(TREE_TYPE (get_gnu_tree (gnat_desig_equiv)))) (TREE_TYPE (get_gnu_tree (gnat_desig_equiv))))
|| (!in_main_unit || (!in_main_unit
&& defer_incomplete_level && defer_incomplete_level != 0
&& !present_gnu_tree (gnat_desig_equiv)) && !present_gnu_tree (gnat_desig_equiv))
|| (in_main_unit || (in_main_unit
&& is_from_limited_with && is_from_limited_with
...@@ -3594,7 +3594,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3594,7 +3594,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
access type may be the full view of a private type. Note access type may be the full view of a private type. Note
that the unconstrained array case is handled above. */ that the unconstrained array case is handled above. */
|| ((!in_main_unit || imported_p) || ((!in_main_unit || imported_p)
&& defer_incomplete_level && defer_incomplete_level != 0
&& !present_gnu_tree (gnat_desig_equiv) && !present_gnu_tree (gnat_desig_equiv)
&& (Is_Record_Type (gnat_desig_rep) && (Is_Record_Type (gnat_desig_rep)
|| Is_Array_Type (gnat_desig_rep))) || Is_Array_Type (gnat_desig_rep)))
...@@ -3728,7 +3728,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3728,7 +3728,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
Besides, variants of this non-dummy type might have been created Besides, variants of this non-dummy type might have been created
along the way. update_pointer_to is expected to properly take along the way. update_pointer_to is expected to properly take
care of those situations. */ care of those situations. */
if (!defer_incomplete_level && !is_from_limited_with_in_main_unit) if (defer_incomplete_level == 0
&& !is_from_limited_with_in_main_unit)
update_pointer_to (TYPE_MAIN_VARIANT (gnu_old_desig_type), update_pointer_to (TYPE_MAIN_VARIANT (gnu_old_desig_type),
gnat_to_gnu_type (gnat_desig_equiv)); gnat_to_gnu_type (gnat_desig_equiv));
else else
...@@ -5045,7 +5046,7 @@ rest_of_type_decl_compilation (tree decl) ...@@ -5045,7 +5046,7 @@ rest_of_type_decl_compilation (tree decl)
{ {
/* We need to defer finalizing the type if incomplete types /* We need to defer finalizing the type if incomplete types
are being deferred or if they are being processed. */ are being deferred or if they are being processed. */
if (defer_incomplete_level || defer_finalize_level) if (defer_incomplete_level != 0 || defer_finalize_level != 0)
VEC_safe_push (tree, heap, defer_finalize_list, decl); VEC_safe_push (tree, heap, defer_finalize_list, decl);
else else
rest_of_type_decl_compilation_no_defer (decl); rest_of_type_decl_compilation_no_defer (decl);
......
...@@ -593,12 +593,14 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED, ...@@ -593,12 +593,14 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
others_decl others_decl
= create_var_decl (get_identifier ("OTHERS"), = create_var_decl (get_identifier ("OTHERS"),
get_identifier ("__gnat_others_value"), get_identifier ("__gnat_others_value"),
integer_type_node, 0, 1, 0, 1, 1, 0, Empty); integer_type_node, NULL_TREE, true, false, true, false,
NULL, Empty);
all_others_decl all_others_decl
= create_var_decl (get_identifier ("ALL_OTHERS"), = create_var_decl (get_identifier ("ALL_OTHERS"),
get_identifier ("__gnat_all_others_value"), get_identifier ("__gnat_all_others_value"),
integer_type_node, 0, 1, 0, 1, 1, 0, Empty); integer_type_node, NULL_TREE, true, false, true, false,
NULL, Empty);
main_identifier_node = get_identifier ("main"); main_identifier_node = get_identifier ("main");
...@@ -2788,8 +2790,8 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) ...@@ -2788,8 +2790,8 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
/* Create an explicit temporary holding the copy. This ensures that /* Create an explicit temporary holding the copy. This ensures that
its lifetime is as narrow as possible around a statement. */ its lifetime is as narrow as possible around a statement. */
gnu_temp = create_var_decl (create_tmp_var_name ("A"), NULL_TREE, gnu_temp = create_var_decl (create_tmp_var_name ("A"), NULL_TREE,
TREE_TYPE (gnu_name), NULL_TREE, false, TREE_TYPE (gnu_name), NULL_TREE,
false, false, false, NULL, Empty); false, false, false, false, NULL, Empty);
DECL_ARTIFICIAL (gnu_temp) = 1; DECL_ARTIFICIAL (gnu_temp) = 1;
DECL_IGNORED_P (gnu_temp) = 1; DECL_IGNORED_P (gnu_temp) = 1;
...@@ -3210,8 +3212,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) ...@@ -3210,8 +3212,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
gnu_jmpsave_decl = create_var_decl (get_identifier ("JMPBUF_SAVE"), gnu_jmpsave_decl = create_var_decl (get_identifier ("JMPBUF_SAVE"),
NULL_TREE, jmpbuf_ptr_type, NULL_TREE, jmpbuf_ptr_type,
build_call_0_expr (get_jmpbuf_decl), build_call_0_expr (get_jmpbuf_decl),
false, false, false, false, NULL, false, false, false, false,
gnat_node); NULL, gnat_node);
DECL_ARTIFICIAL (gnu_jmpsave_decl) = 1; DECL_ARTIFICIAL (gnu_jmpsave_decl) = 1;
/* The __builtin_setjmp receivers will immediately reinstall it. Now /* The __builtin_setjmp receivers will immediately reinstall it. Now
...@@ -3220,8 +3222,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) ...@@ -3220,8 +3222,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
it is uninitialized, although they will never be actually taken. */ it is uninitialized, although they will never be actually taken. */
TREE_NO_WARNING (gnu_jmpsave_decl) = 1; TREE_NO_WARNING (gnu_jmpsave_decl) = 1;
gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"), gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"),
NULL_TREE, jmpbuf_type, NULL_TREE, jmpbuf_type, NULL_TREE,
NULL_TREE, false, false, false, false, false, false, false, false,
NULL, gnat_node); NULL, gnat_node);
DECL_ARTIFICIAL (gnu_jmpbuf_decl) = 1; DECL_ARTIFICIAL (gnu_jmpbuf_decl) = 1;
...@@ -3273,12 +3275,11 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) ...@@ -3273,12 +3275,11 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
gnat_pushlevel (); gnat_pushlevel ();
VEC_safe_push (tree, gc, gnu_except_ptr_stack, VEC_safe_push (tree, gc, gnu_except_ptr_stack,
create_var_decl (get_identifier ("EXCEPT_PTR"), create_var_decl (get_identifier ("EXCEPT_PTR"), NULL_TREE,
NULL_TREE,
build_pointer_type (except_type_node), build_pointer_type (except_type_node),
build_call_0_expr (get_excptr_decl), build_call_0_expr (get_excptr_decl),
false, false, false, false, false,
false, false, false, NULL, gnat_node)); NULL, gnat_node));
/* Generate code for each handler. The N_Exception_Handler case does the /* Generate code for each handler. The N_Exception_Handler case does the
real work and returns a COND_EXPR for each handler, which we chain real work and returns a COND_EXPR for each handler, which we chain
...@@ -3537,8 +3538,8 @@ Exception_Handler_to_gnu_zcx (Node_Id gnat_node) ...@@ -3537,8 +3538,8 @@ Exception_Handler_to_gnu_zcx (Node_Id gnat_node)
1, integer_zero_node); 1, integer_zero_node);
gnu_incoming_exc_ptr = create_var_decl (get_identifier ("EXPTR"), NULL_TREE, gnu_incoming_exc_ptr = create_var_decl (get_identifier ("EXPTR"), NULL_TREE,
ptr_type_node, gnu_current_exc_ptr, ptr_type_node, gnu_current_exc_ptr,
false, false, false, false, NULL, false, false, false, false,
gnat_node); NULL, gnat_node);
add_stmt_with_node (build_call_1_expr (begin_handler_decl, add_stmt_with_node (build_call_1_expr (begin_handler_decl,
gnu_incoming_exc_ptr), gnu_incoming_exc_ptr),
...@@ -3997,13 +3998,16 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -3997,13 +3998,16 @@ gnat_to_gnu (Node_Id gnat_node)
is frozen. */ is frozen. */
if (Present (Freeze_Node (gnat_temp))) if (Present (Freeze_Node (gnat_temp)))
{ {
if ((Is_Public (gnat_temp) || global_bindings_p ()) bool public_flag = Is_Public (gnat_temp);
&& !TREE_CONSTANT (gnu_expr))
if (TREE_CONSTANT (gnu_expr))
;
else if (public_flag || global_bindings_p ())
gnu_expr gnu_expr
= create_var_decl (create_concat_name (gnat_temp, "init"), = create_var_decl (create_concat_name (gnat_temp, "init"),
NULL_TREE, TREE_TYPE (gnu_expr), NULL_TREE, TREE_TYPE (gnu_expr), gnu_expr,
gnu_expr, false, Is_Public (gnat_temp), false, public_flag, false, false,
false, false, NULL, gnat_temp); NULL, gnat_temp);
else else
gnu_expr = gnat_save_expr (gnu_expr); gnu_expr = gnat_save_expr (gnu_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