diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-04-07 13:55:09 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-29 10:23:21 +0200 |
commit | 9f29fc75351870da24c1a94986be031989a88509 (patch) | |
tree | 75ee1ec6b9d8f5dff57ab0f601621155675bbfb2 /gcc/ada/sem_res.adb | |
parent | 11f406ee4747e48a9b0e34aa6f6b3cdb38665a1b (diff) | |
download | gcc-9f29fc75351870da24c1a94986be031989a88509.zip gcc-9f29fc75351870da24c1a94986be031989a88509.tar.gz gcc-9f29fc75351870da24c1a94986be031989a88509.tar.bz2 |
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.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1d4b9ac..8a5f87b 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 |