From: Ghjuvan Lacambre Date: Wed, 3 Jun 2020 09:09:20 +0000 (+0200) Subject: [Ada] Guard against access to wrong fields in Is_Renaming X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75b3609c56576e94f721322826d0d3a34778dedb;p=thirdparty%2Fgcc.git [Ada] Guard against access to wrong fields in Is_Renaming gcc/ada/ * sem_util.adb (Is_Renaming): Add ekind checks. --- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 480e6f1df0cc..59073b0355f8 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; -----------------------