aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2020-06-25 17:15:50 -0700
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-16 03:31:31 -0400
commit56bedb147ec7829c11f20fb613ef5780ad106e4d (patch)
tree091faf5bd8aef08fab7bb64dabbe57ed0fdd7c5e
parentd931c94ea2048db6a85e9f1685404c2d210eef4a (diff)
downloadgcc-56bedb147ec7829c11f20fb613ef5780ad106e4d.zip
gcc-56bedb147ec7829c11f20fb613ef5780ad106e4d.tar.gz
gcc-56bedb147ec7829c11f20fb613ef5780ad106e4d.tar.bz2
[Ada] Avoid premature finalization of a function result
gcc/ada/ * exp_util.adb (Is_Related_To_Func_Return): Cope with the case where the FE introduces a type conversion.
-rw-r--r--gcc/ada/exp_util.adb7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 8ef05d4..269c9e0 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -8740,9 +8740,14 @@ package body Exp_Util is
function Is_Related_To_Func_Return (Id : Entity_Id) return Boolean is
Expr : constant Node_Id := Related_Expression (Id);
begin
+ -- In the case of a function with a class-wide result that returns
+ -- a call to a function with a specific result, we introduce a
+ -- type conversion for the return expression. We do not want that
+ -- type conversion to influence the result of this function.
+
return
Present (Expr)
- and then Nkind (Expr) = N_Explicit_Dereference
+ and then Nkind (Unqual_Conv (Expr)) = N_Explicit_Dereference
and then Nkind (Parent (Expr)) = N_Simple_Return_Statement;
end Is_Related_To_Func_Return;