aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-09-29 12:40:39 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-11-26 03:39:52 -0500
commitbc0c82e99485589937789888e4bd7275c236b3be (patch)
treebc2c2d6f8ef8f2ebfd0b9f0551f601b60441d808
parent81c629f8f12765f9b1bf29ecfef7f32f5189723c (diff)
downloadgcc-bc0c82e99485589937789888e4bd7275c236b3be.zip
gcc-bc0c82e99485589937789888e4bd7275c236b3be.tar.gz
gcc-bc0c82e99485589937789888e4bd7275c236b3be.tar.bz2
[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).
-rw-r--r--gcc/ada/sem_eval.adb5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index e453bc1..4dc5248 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