From bc0c82e99485589937789888e4bd7275c236b3be Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 29 Sep 2020 12:40:39 +0200 Subject: [PATCH] [Ada] Avoid potentially repeated calls to Prefix in Eval_Slice gcc/ada/ * sem_eval.adb (Eval_Slice): Refactor repeated calls to Prefix with a local constant (named just like in Resolve_Slice). --- gcc/ada/sem_eval.adb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index e453bc1676b..4dc524817b6 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -3944,6 +3944,7 @@ package body Sem_Eval is procedure Eval_Slice (N : Node_Id) is Drange : constant Node_Id := Discrete_Range (N); + Name : constant Node_Id := Prefix (N); begin if Nkind (Drange) = N_Range then @@ -3955,9 +3956,9 @@ package body Sem_Eval is -- the type of A, is redundant, the slice can be replaced with A, and -- this is worth a warning. - if Is_Entity_Name (Prefix (N)) then + if Is_Entity_Name (Name) then declare - E : constant Entity_Id := Entity (Prefix (N)); + E : constant Entity_Id := Entity (Name); T : constant Entity_Id := Etype (E); begin -- 2.30.2