From 6be06ae88b8be8543094d712f24c52a4d2d73220 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 11 Dec 2024 13:06:07 +0100 Subject: ada: Fix assertion failure on 'Old in post-condition with -gnat2022 It comes from a small oversight in the updated implementation for Ada 2022. gcc/ada/ChangeLog: PR ada/117956 * sem_util.adb (Is_Known_On_Entry): Be prepared for constants coming from a renaming declaration. --- gcc/ada/sem_util.adb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 595d3d1..ffc631a 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -31188,8 +31188,17 @@ package body Sem_Util is -- removal, e.g. by validity checks. if not Comes_From_Source (Obj) then - return - Is_Known_On_Entry (Expression (Parent (Obj))); + declare + D : constant Node_Id := + Declaration_Node (Obj); + begin + if Nkind (D) = N_Object_Renaming_Declaration + then + return Is_Known_On_Entry (Name (D)); + else + return Is_Known_On_Entry (Expression (D)); + end if; + end; end if; -- return False if not "all views are constant". -- cgit v1.1