From 7837a887d6672735d24737baf46ece96dc53a02d Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Mon, 23 Nov 2020 14:38:45 +0100 Subject: [PATCH] [Ada] Refactor duplicated code for First and Last attributes gcc/ada/ * sem_attr.adb (Analyze_Attribute): Merge identical code for First/Last, First_Bit/Last_Bit and First_Valid/Last_Valid attributes. --- gcc/ada/sem_attr.adb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index b243af6e1ff..526224454f6 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4066,7 +4066,9 @@ package body Sem_Attr is -- First -- ----------- - when Attribute_First => + when Attribute_First + | Attribute_Last + => Check_Array_Or_Scalar_Type; Bad_Attribute_For_Predicate; @@ -4074,7 +4076,9 @@ package body Sem_Attr is -- First_Bit -- --------------- - when Attribute_First_Bit => + when Attribute_First_Bit + | Attribute_Last_Bit + => Check_Component; Set_Etype (N, Universal_Integer); @@ -4082,7 +4086,9 @@ package body Sem_Attr is -- First_Valid -- ----------------- - when Attribute_First_Valid => + when Attribute_First_Valid + | Attribute_Last_Valid + => Check_First_Last_Valid; Set_Etype (N, P_Type); @@ -4295,25 +4301,19 @@ package body Sem_Attr is -- Last -- ---------- - when Attribute_Last => - Check_Array_Or_Scalar_Type; - Bad_Attribute_For_Predicate; + -- Shares processing with First attribute -------------- -- Last_Bit -- -------------- - when Attribute_Last_Bit => - Check_Component; - Set_Etype (N, Universal_Integer); + -- Shares processing with First_Bit attribute ---------------- -- Last_Valid -- ---------------- - when Attribute_Last_Valid => - Check_First_Last_Valid; - Set_Etype (N, P_Type); + -- Shares processing with First_Valid attribute ------------------ -- Leading_Part -- -- 2.30.2