From 113c69ff2d41091359ec37789974cc47f1169e05 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 8 Apr 2015 09:08:12 +0000 Subject: decl.c (gnat_to_gnu_entity): Do not make a function returning an unconstrained type 'const' for the middle-end. * gcc-interface/decl.c (gnat_to_gnu_entity) : Do not make a function returning an unconstrained type 'const' for the middle-end. * gcc-interface/trans.c (Pragma_to_gnu) : Use exact condition to detect Reason => "..." pattern. From-SVN: r221916 --- gcc/ada/gcc-interface/decl.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'gcc/ada/gcc-interface/decl.c') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 0027d6f..d908a1b 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -4266,8 +4266,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) return_by_direct_ref_p = true; } - /* If we are supposed to return an unconstrained array type, make - the actual return type the fat pointer type. */ + /* 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 = TREE_TYPE (gnu_return_type); @@ -4275,8 +4276,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) } /* Likewise, if the return type requires a transient scope, the - return value will be allocated on the secondary stack so the - actual return type is the pointer type. */ + return value will also be allocated on the secondary stack so + the actual return type is the pointer type. */ else if (Requires_Transient_Scope (gnat_return_type)) { gnu_return_type = build_pointer_type (gnu_return_type); @@ -4591,11 +4592,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) return_by_direct_ref_p, return_by_invisi_ref_p); - /* A subprogram (something that doesn't return anything) shouldn't - be considered const since there would be no reason for such a + /* A procedure (something that doesn't return anything) shouldn't be + considered const since there would be no reason for calling such a subprogram. Note that procedures with Out (or In Out) parameters - have already been converted into a function with a return type. */ - if (TREE_CODE (gnu_return_type) == VOID_TYPE) + have already been converted into a function with a return type. + 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 (TREE_CODE (gnu_return_type) == VOID_TYPE || return_unconstrained_p) const_flag = false; if (const_flag || volatile_flag) -- cgit v1.1