diff options
author | Ghjuvan Lacambre <lacambre@adacore.com> | 2020-06-03 11:09:20 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-07-15 09:42:53 -0400 |
commit | fbaadba2468d29178dbd7cde8089b12129e360dc (patch) | |
tree | 929c9f7b3b8e17a912a39a9d9a4dd92ebb522a21 | |
parent | ae265cdd5b2e20bdf14a4ef8c2b1458ad09b9d03 (diff) | |
download | gcc-fbaadba2468d29178dbd7cde8089b12129e360dc.zip gcc-fbaadba2468d29178dbd7cde8089b12129e360dc.tar.gz gcc-fbaadba2468d29178dbd7cde8089b12129e360dc.tar.bz2 |
[Ada] Guard against access to wrong fields in Is_Renaming
gcc/ada/
* sem_util.adb (Is_Renaming): Add ekind checks.
-rw-r--r-- | gcc/ada/sem_util.adb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 480e6f1..59073b0 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; ----------------------- |