From: Eric Botcazou Date: Thu, 12 Jun 2025 19:58:49 +0000 (+0200) Subject: ada: Fix missing finalization with conditional expression in extended return X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=448e857b977ef673fa8a28d24dcd4567f4d5d0cd;p=thirdparty%2Fgcc.git ada: Fix missing finalization with conditional expression in extended return Declarations of return objects are not (yet) distributed into the dependent expressions of conditional expressions. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not bail out for the declarations of return objects. --- diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 72d00bcb318..e9a73e16b07 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5387,8 +5387,13 @@ package body Exp_Ch6 is -- Note that object declarations are also distributed into conditional -- expressions, but we may be invoked before this distribution is done. + -- However that's not the case for the declarations of return objects, + -- see the twin Is_Optimizable_Declaration predicates that are present + -- in Expand_N_Case_Expression and Expand_N_If_Expression of Exp_Ch4. - elsif Nkind (Uncond_Par) = N_Object_Declaration then + elsif Nkind (Uncond_Par) = N_Object_Declaration + and then not Is_Return_Object (Defining_Identifier (Uncond_Par)) + then return; end if;