https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112781
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Eric Botcazou <ebotca...@gcc.gnu.org>: https://gcc.gnu.org/g:36ddb5230f56a30317630a928dd73ed46eda03f1 commit r13-8205-g36ddb5230f56a30317630a928dd73ed46eda03f1 Author: Eric Botcazou <ebotca...@adacore.com> Date: Tue Jan 9 11:06:23 2024 +0100 Fix internal error on function call returning extension of limited interface The problem occurs when this function call is the expression of a return in a function returning the limited interface; in this peculiar case, there is a mismatch between the callee, which has BIP formals but is not a BIP call, and the caller, which is a BIP function, that is spotted by an assertion. This is fixed by restoring the semantics of Is_Build_In_Place_Function_Call, which returns again true only for calls to BIP functions, introducing the Is_Function_Call_With_BIP_Formals predicate, which also returns true for calls to functions with BIP formals that are not BIP functions, and moving down the assertion in Expand_Simple_Function_Return. gcc/ada/ PR ada/112781 * exp_ch6.ads (Is_Build_In_Place_Function): Adjust description. * exp_ch6.adb (Is_True_Build_In_Place_Function_Call): Delete. (Is_Function_Call_With_BIP_Formals): New predicate. (Is_Build_In_Place_Function_Call): Restore original semantics. (Expand_Call_Helper): Adjust conditions guarding the calls to Add_Dummy_Build_In_Place_Actuals to above renaming. (Expand_N_Extended_Return_Statement): Adjust to above renaming. (Expand_Simple_Function_Return): Likewise. Move the assertion to after the transformation into an extended return statement. (Make_Build_In_Place_Call_In_Allocator): Remove unreachable code. (Make_Build_In_Place_Call_In_Assignment): Likewise. gcc/testsuite/ * gnat.dg/bip_prim_func2.adb: New test. * gnat.dg/bip_prim_func2_pkg.ads, gnat.dg/bip_prim_func2_pkg.adb: New helper package.