diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-08-16 11:28:37 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-29 15:06:28 +0200 |
commit | 499406992f48cc8da64448a107f95e681cea9039 (patch) | |
tree | 1980d21be7864ed75b67f9a976dc6a4b0981dced /gcc | |
parent | c2e3326a10f585fb252a1d54e7a83e7efecbf99a (diff) | |
download | gcc-499406992f48cc8da64448a107f95e681cea9039.zip gcc-499406992f48cc8da64448a107f95e681cea9039.tar.gz gcc-499406992f48cc8da64448a107f95e681cea9039.tar.bz2 |
ada: Fix missing finalization for call to function returning limited view
The call is legal because it is made from the body, which has visibility on
the nonlimited view, so this changes the code in Expand_Call_Helper to look
at the Etype of the call node instead of the Etype of the function.
gcc/ada/
* exp_ch6.adb (Expand_Call_Helper): In the case of a function
call, look at the Etype of the call node to determine whether
finalization actions need to be performed.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 420d5f4..3c87c0e 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5262,7 +5262,9 @@ package body Exp_Ch6 is -- function call is transformed into a reference to the result that has -- been built either on the primary or the secondary stack. - if Needs_Finalization (Etype (Subp)) then + if Nkind (Call_Node) = N_Function_Call + and then Needs_Finalization (Etype (Call_Node)) + then if not Is_Build_In_Place_Function_Call (Call_Node) and then (No (First_Formal (Subp)) @@ -5270,7 +5272,7 @@ package body Exp_Ch6 is not Is_Concurrent_Record_Type (Etype (First_Formal (Subp)))) then Expand_Ctrl_Function_Call - (Call_Node, Needs_Secondary_Stack (Etype (Subp))); + (Call_Node, Needs_Secondary_Stack (Etype (Call_Node))); -- Build-in-place function calls which appear in anonymous contexts -- need a transient scope to ensure the proper finalization of the @@ -5292,7 +5294,7 @@ package body Exp_Ch6 is Is_Build_In_Place_Function_Call (Parent (Call_Node))) then Establish_Transient_Scope - (Call_Node, Needs_Secondary_Stack (Etype (Subp))); + (Call_Node, Needs_Secondary_Stack (Etype (Call_Node))); end if; end if; end Expand_Call_Helper; |