aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhjuvan Lacambre <lacambre@adacore.com>2020-06-03 11:09:20 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-15 09:42:53 -0400
commitfbaadba2468d29178dbd7cde8089b12129e360dc (patch)
tree929c9f7b3b8e17a912a39a9d9a4dd92ebb522a21
parentae265cdd5b2e20bdf14a4ef8c2b1458ad09b9d03 (diff)
downloadgcc-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.adb24
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;
-----------------------