aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/gcc-interface/decl.cc')
-rw-r--r--gcc/ada/gcc-interface/decl.cc43
1 files changed, 7 insertions, 36 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 318c3be..bbbb343 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -5807,7 +5807,6 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
bool pure_flag = Is_Pure (gnat_subprog);
bool return_by_direct_ref_p = false;
bool return_by_invisi_ref_p = false;
- bool return_unconstrained_p = false;
bool incomplete_profile_p = false;
int num;
@@ -5822,7 +5821,6 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
&& !TYPE_IS_DUMMY_P (TREE_TYPE (gnu_type)))
{
gnu_return_type = TREE_TYPE (gnu_type);
- return_unconstrained_p = TYPE_RETURN_UNCONSTRAINED_P (gnu_type);
return_by_direct_ref_p = TYPE_RETURN_BY_DIRECT_REF_P (gnu_type);
return_by_invisi_ref_p = TREE_ADDRESSABLE (gnu_type);
}
@@ -5838,38 +5836,16 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
else
gnu_return_type = gnat_to_gnu_profile_type (gnat_return_type);
- /* If this function returns by reference, make the actual return type
- the reference type and make a note of that. */
- if (Returns_By_Ref (gnat_subprog))
+ /* If this function returns by reference or on the secondary stack, make
+ the actual return type the reference type and make a note of that. */
+ if (Returns_By_Ref (gnat_subprog)
+ || Needs_Secondary_Stack (gnat_return_type)
+ || Is_Secondary_Stack_Thunk (gnat_subprog))
{
gnu_return_type = build_reference_type (gnu_return_type);
return_by_direct_ref_p = true;
}
- /* If the return type is an unconstrained array type, the return value
- will be allocated on the secondary stack so the actual return type
- is the fat pointer type. */
- else if (TREE_CODE (gnu_return_type) == UNCONSTRAINED_ARRAY_TYPE)
- {
- gnu_return_type = TYPE_REFERENCE_TO (gnu_return_type);
- return_unconstrained_p = true;
- }
-
- /* This is the same unconstrained array case, but for a dummy type. */
- else if (TYPE_REFERENCE_TO (gnu_return_type)
- && TYPE_IS_FAT_POINTER_P (TYPE_REFERENCE_TO (gnu_return_type)))
- {
- gnu_return_type = TYPE_REFERENCE_TO (gnu_return_type);
- return_unconstrained_p = true;
- }
-
- /* This is for the other types returned on the secondary stack. */
- else if (Needs_Secondary_Stack (gnat_return_type))
- {
- gnu_return_type = build_reference_type (gnu_return_type);
- return_unconstrained_p = true;
- }
-
/* If the Mechanism is By_Reference, ensure this function uses the
target's by-invisible-reference mechanism, which may not be the
same as above (e.g. it might be passing an extra parameter). */
@@ -5949,8 +5925,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
}
if (kind == E_Function)
- Set_Mechanism (gnat_subprog, return_unconstrained_p
- || return_by_direct_ref_p
+ Set_Mechanism (gnat_subprog, return_by_direct_ref_p
|| return_by_invisi_ref_p
? By_Reference : By_Copy);
}
@@ -5962,7 +5937,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
Similarly, if the function returns an unconstrained type, then the
function will allocate the return value on the secondary stack and
thus calls to it cannot be CSE'ed, lest the stack be reclaimed. */
- if (VOID_TYPE_P (gnu_return_type) || return_unconstrained_p)
+ if (VOID_TYPE_P (gnu_return_type) || return_by_direct_ref_p)
pure_flag = false;
/* Loop over the parameters and get their associated GCC tree. While doing
@@ -6250,7 +6225,6 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
gnu_type = make_node (method_p ? METHOD_TYPE : FUNCTION_TYPE);
TREE_TYPE (gnu_type) = gnu_return_type;
TYPE_ARG_TYPES (gnu_type) = gnu_param_type_list;
- TYPE_RETURN_UNCONSTRAINED_P (gnu_type) = return_unconstrained_p;
TYPE_RETURN_BY_DIRECT_REF_P (gnu_type) = return_by_direct_ref_p;
TREE_ADDRESSABLE (gnu_type) = return_by_invisi_ref_p;
}
@@ -6267,7 +6241,6 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
= TYPE_MAIN_VARIANT (gnu_basetype);
}
TYPE_CI_CO_LIST (gnu_type) = gnu_cico_list;
- TYPE_RETURN_UNCONSTRAINED_P (gnu_type) = return_unconstrained_p;
TYPE_RETURN_BY_DIRECT_REF_P (gnu_type) = return_by_direct_ref_p;
TREE_ADDRESSABLE (gnu_type) = return_by_invisi_ref_p;
TYPE_CANONICAL (gnu_type) = gnu_type;
@@ -6289,13 +6262,11 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
/* GNU_TYPE may be shared since GCC hashes types. Unshare it if it
has a different TYPE_CI_CO_LIST or flags. */
if (!fntype_same_flags_p (gnu_type, gnu_cico_list,
- return_unconstrained_p,
return_by_direct_ref_p,
return_by_invisi_ref_p))
{
gnu_type = copy_type (gnu_type);
TYPE_CI_CO_LIST (gnu_type) = gnu_cico_list;
- TYPE_RETURN_UNCONSTRAINED_P (gnu_type) = return_unconstrained_p;
TYPE_RETURN_BY_DIRECT_REF_P (gnu_type) = return_by_direct_ref_p;
TREE_ADDRESSABLE (gnu_type) = return_by_invisi_ref_p;
}