diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-15 15:59:54 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-15 15:59:54 +0000 |
commit | 8d8f60b9addfd83e4a016e4bcc397618117ed76e (patch) | |
tree | 6de133fd341d163b8dba67b5ce64baf3ae84e2c8 /gcc/ada/trans.c | |
parent | 18563cef8e0580374758cc830b4b4b249176875b (diff) | |
download | gcc-8d8f60b9addfd83e4a016e4bcc397618117ed76e.tar.gz |
2005-03-08 Eric Botcazou <ebotcazou@adacore.com>
Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Nicolas Setton <setton@adacore.com>
Ed Schonberg <schonberg@adacore.com>
PR ada/19900
PR ada/19408
PR ada/19140
PR ada/20255
* decl.c (gnat_to_gnu_field): Reject aliased components with a
representation clause that prescribes a size not equal to the rounded
size of their types.
(gnat_to_gnu_entity, case E_Component): Always look at
Original_Record_Component if Present and not the entity.
(gnat_to_gnu_entity, case E_Record_Subtype): Rework handling of subtypes
of tagged extension types by not making field for components that are
inside the parent.
(gnat_to_gnu_entity) <E_Record_Type>: Fix typo in the alignment formula
(gnat_to_gnu_entity) <E_Variable>: Do not convert again the
expression to the type of the object when the object is constant.
Reverse defer_debug_incomplete_list before traversing it, so that trees
are processed in the order at which they were added to the list. This
order is important when using the stabs debug format.
If we are deferring the output of debug information, also defer this
output for a function return type.
When adding fields to a record, prevent emitting debug information
for incomplete records, emit the information only when the record is
complete.
(components_to_record): New parameter defer_debug.
(gnat_to_gnu_entity, case E_Array_Subtype): Call copy_alias_set.
(gnat_to_gnu_field_decl): New function.
(substitution_list, annotate_rep): Call it.
(gnat_to_gnu_entity, case E_Record_Subtype): Likewise.
(gnat_to_gnu_entity, case E_Record_Type): Likewise.
No longer update discriminants to not be a COMPONENT_REF.
(copy_alias_set): Strip padding from input type; also handle
unconstrained arrays properly.
* gigi.h (write_record_type_debug_info): New function.
Convert to use ANSI-style prototypes. Remove unused
declarations for emit_stack_check, elab_all_gnat and
set_second_error_entity.
(gnat_to_gnu_field_decl): New decl.
* utils.c (write_record_type_debug_info): New function.
(finish_record_type): Delegate generation of debug information to
write_record_type_debug_info.
(update_pointer_to): Remove unneeded calls to rest_of_decl_compilation.
(update_pointer_to): Fix pasto.
(convert) <UNION_TYPE>: Accept slight type variations when
converting to an unchecked union type.
* exp_ch13.adb (Expand_N_Freeze_Entity): If Freeze_Type returns True,
replace the N_Freeze_Entity with a null statement.
* freeze.adb (Freeze_Expression): If the freeze nodes are generated
within a constrained subcomponent of an enclosing record, place the
freeze nodes in the scope stack entry for the enclosing record.
(Undelay_Type): New Subprogram.
(Set_Small_Size): Pass T, the type to modify; all callers changed.
(Freeze_Entity, Freeze_Record_Type): Change the way we handle types
within records; allow them to have freeze nodes if their base types
aren't frozen yet.
* sem_ch3.adb (Derived_Type_Declaration): New predicate
Comes_From_Generic, to recognize accurately that the parent type in a
derived type declaration can be traced back to a formal type, because
it is one or is derived from one, or because its completion is derived
from one.
(Constrain_Component_Type): If component comes from source and has no
explicit constraint, no need to constrain in in a subtype of the
enclosing record.
(Constrain_Access, Constrain_Array): Allow itypes to be delayed.
Minor change to propagate Is_Ada_2005 flag
* trans.c (gnat_to_gnu, case N_Aggregate): Verify that
Expansion_Delayed is False.
(assoc_to_constructor): Ignore fields that have a
Corresponding_Discriminant.
(gnat_to_gnu) <N_Return_Statement>: Restructure. If the
function returns "by target", dereference the target pointer using the
type of the actual return value.
<all>: Be prepared for a null gnu_result.
(processed_inline_subprograms): Check flag_really_no_inline
instead of flag_no_inline.
(set_second_error_entity): Remove unused function.
(gnat_to_gnu, case N_Selected_Component): Call
gnat_to_gnu_field_decl.
(assoc_to_constructor): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96492 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/trans.c')
-rw-r--r-- | gcc/ada/trans.c | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 7446359e90e..9bcc45e5e63 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -2956,7 +2956,7 @@ gnat_to_gnu (Node_Id gnat_node) NULL_TREE, gnu_prefix); else { - gnu_field = gnat_to_gnu_entity (gnat_field, NULL_TREE, 0); + gnu_field = gnat_to_gnu_field_decl (gnat_field); /* If there are discriminants, the prefix might be evaluated more than once, which is a problem if it has @@ -3013,6 +3013,8 @@ gnat_to_gnu (Node_Id gnat_node) /* ??? It is wrong to evaluate the type now, but there doesn't seem to be any other practical way of doing it. */ + gcc_assert (!Expansion_Delayed (gnat_node)); + gnu_aggr_type = gnu_result_type = get_unpadded_type (Etype (gnat_node)); @@ -3497,11 +3499,7 @@ gnat_to_gnu (Node_Id gnat_node) /* The return value from the subprogram. */ tree gnu_ret_val = NULL_TREE; /* The place to put the return value. */ - tree gnu_lhs - = (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type) - ? build_unary_op (INDIRECT_REF, NULL_TREE, - DECL_ARGUMENTS (current_function_decl)) - : DECL_RESULT (current_function_decl)); + tree gnu_lhs; /* If we are dealing with a "return;" from an Ada procedure with parameters passed by copy in copy out, we need to return a record @@ -3524,6 +3522,7 @@ gnat_to_gnu (Node_Id gnat_node) else if (TYPE_CI_CO_LIST (gnu_subprog_type)) { + gnu_lhs = DECL_RESULT (current_function_decl); if (list_length (TYPE_CI_CO_LIST (gnu_subprog_type)) == 1) gnu_ret_val = TREE_VALUE (TYPE_CI_CO_LIST (gnu_subprog_type)); else @@ -3543,12 +3542,26 @@ gnat_to_gnu (Node_Id gnat_node) are doing a call, pass that target to the call. */ if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type) && Nkind (Expression (gnat_node)) == N_Function_Call) - gnu_ret_val = call_to_gnu (Expression (gnat_node), - &gnu_result_type, gnu_lhs); + { + gnu_lhs + = build_unary_op (INDIRECT_REF, NULL_TREE, + DECL_ARGUMENTS (current_function_decl)); + gnu_result = call_to_gnu (Expression (gnat_node), + &gnu_result_type, gnu_lhs); + } else { gnu_ret_val = gnat_to_gnu (Expression (gnat_node)); + if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)) + /* The original return type was unconstrained so dereference + the TARGET pointer in the actual return value's type. */ + gnu_lhs + = build_unary_op (INDIRECT_REF, TREE_TYPE (gnu_ret_val), + DECL_ARGUMENTS (current_function_decl)); + else + gnu_lhs = DECL_RESULT (current_function_decl); + /* Do not remove the padding from GNU_RET_VAL if the inner type is self-referential since we want to allocate the fixed size in that case. */ @@ -3591,18 +3604,19 @@ gnat_to_gnu (Node_Id gnat_node) gnat_node); } } + } - gnu_result = build2 (MODIFY_EXPR, TREE_TYPE (gnu_ret_val), - gnu_lhs, gnu_ret_val); - if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)) - { - add_stmt_with_node (gnu_result, gnat_node); - gnu_ret_val = NULL_TREE; - } + if (gnu_ret_val) + gnu_result = build2 (MODIFY_EXPR, TREE_TYPE (gnu_ret_val), + gnu_lhs, gnu_ret_val); + + if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)) + { + add_stmt_with_node (gnu_result, gnat_node); + gnu_result = NULL_TREE; } - gnu_result = build1 (RETURN_EXPR, void_type_node, - gnu_ret_val ? gnu_result : gnu_ret_val); + gnu_result = build1 (RETURN_EXPR, void_type_node, gnu_result); } break; @@ -4021,12 +4035,14 @@ gnat_to_gnu (Node_Id gnat_node) current_function_decl = NULL_TREE; } - /* Set the location information into the result. If we're supposed to - return something of void_type, it means we have something we're - elaborating for effect, so just return. */ - if (EXPR_P (gnu_result)) + /* Set the location information into the result. Note that we may have + no result if we tried to build a CALL_EXPR node to a procedure with + no side-effects and optimization is enabled. */ + if (gnu_result && EXPR_P (gnu_result)) annotate_with_node (gnu_result, gnat_node); + /* If we're supposed to return something of void_type, it means we have + something we're elaborating for effect, so just return. */ if (TREE_CODE (gnu_result_type) == VOID_TYPE) return gnu_result; @@ -4807,7 +4823,7 @@ process_inlined_subprograms (Node_Id gnat_node) /* If we can inline, generate RTL for all the inlined subprograms. Define the entity first so we set DECL_EXTERNAL. */ - if (optimize > 0 && !flag_no_inline) + if (optimize > 0 && !flag_really_no_inline) for (gnat_entity = First_Inlined_Subprogram (gnat_node); Present (gnat_entity); gnat_entity = Next_Inlined_Subprogram (gnat_entity)) @@ -5439,13 +5455,19 @@ assoc_to_constructor (Node_Id gnat_assoc, tree gnu_type) gnat_assoc = Next (gnat_assoc)) { Node_Id gnat_field = First (Choices (gnat_assoc)); - tree gnu_field = gnat_to_gnu_entity (Entity (gnat_field), NULL_TREE, 0); + tree gnu_field = gnat_to_gnu_field_decl (Entity (gnat_field)); tree gnu_expr = gnat_to_gnu (Expression (gnat_assoc)); /* The expander is supposed to put a single component selector name in every record component association */ gcc_assert (No (Next (gnat_field))); + /* Ignore fields that have Corresponding_Discriminants since we'll + be setting that field in the parent. */ + if (Present (Corresponding_Discriminant (Entity (gnat_field))) + && Is_Tagged_Type (Scope (Entity (gnat_field)))) + continue; + /* Before assigning a value in an aggregate make sure range checks are done if required. Then convert to the type of the field. */ if (Do_Range_Check (Expression (gnat_assoc))) @@ -5956,14 +5978,6 @@ post_error_ne_tree_2 (const char *msg, Error_Msg_Uint_2 = UI_From_Int (num); post_error_ne_tree (msg, node, ent, t); } - -/* Set the node for a second '&' in the error message. */ - -void -set_second_error_entity (Entity_Id e) -{ - Error_Msg_Node_2 = e; -} /* Initialize the table that maps GNAT codes to GCC codes for simple binary and unary operations. */ |