[COMMITTED] ada: Fix crash on semi-recursive call in access-to-subprogram contract
Commit Message
From: Piotr Trojanek <trojanek@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_res.adb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -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