From fbaadba2468d29178dbd7cde8089b12129e360dc Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Wed, 3 Jun 2020 11:09:20 +0200 Subject: [PATCH] [Ada] Guard against access to wrong fields in Is_Renaming gcc/ada/ * sem_util.adb (Is_Renaming): Add ekind checks. --- gcc/ada/sem_util.adb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 480e6f1df0c..59073b0355f 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -6422,8 +6422,28 @@ package body Sem_Util is function Is_Renaming (N : Node_Id) return Boolean is begin - return - Is_Entity_Name (N) and then Present (Renamed_Entity (Entity (N))); + if not Is_Entity_Name (N) then + return False; + end if; + + case Ekind (Entity (N)) is + when E_Variable | E_Constant => + return Present (Renamed_Object (Entity (N))); + + when E_Exception + | E_Function + | E_Generic_Function + | E_Generic_Package + | E_Generic_Procedure + | E_Operator + | E_Package + | E_Procedure + => + return Present (Renamed_Entity (Entity (N))); + + when others => + return False; + end case; end Is_Renaming; ----------------------- -- 2.30.2