From: Piotr Trojanek Date: Fri, 7 Apr 2023 11:55:09 +0000 (+0200) Subject: ada: Fix crash on semi-recursive call in access-to-subprogram contract X-Git-Tag: basepoints/gcc-15~8792 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f29fc75351870da24c1a94986be031989a88509;p=thirdparty%2Fgcc.git ada: Fix crash on semi-recursive call in access-to-subprogram contract Calls to access-to-subprogram from its own pre/post aspects are rejected as illegal, e.g.: type F is access function (X : Natural) return Boolean with Pre => F.all (X); but they caused an assertion failure in detection of recursive calls. Now they are properly recognized as recursive, but the error is suppressed, because it has been already posted at the call node. gcc/ada/ * sem_res.adb (Invoked_With_Different_Arguments): Use Get_Called_Entity, which properly deals with calls via an access-to-subprogram; fix inconsistent use of a Call object declared in enclosing subprogram. --- diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1d4b9acb8ea2..8a5f87b80edf 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -947,7 +947,7 @@ package body Sem_Res is -------------------------------------- function Invoked_With_Different_Arguments (N : Node_Id) return Boolean is - Subp : constant Entity_Id := Entity (Name (N)); + Subp : constant Entity_Id := Get_Called_Entity (N); Actual : Node_Id; Formal : Entity_Id; @@ -956,7 +956,7 @@ package body Sem_Res is -- Determine whether the formals of the invoked subprogram are not -- used as actuals in the call. - Actual := First_Actual (Call); + Actual := First_Actual (N); Formal := First_Formal (Subp); while Present (Actual) and then Present (Formal) loop