From 6b0c5c722709d41d2c7a9ccacb7a4f0cf3bd38e2 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 9 Oct 2020 15:49:29 +0200 Subject: [PATCH] [Ada] Remove repeated calls to Attribute_Name gcc/ada/ * exp_util.adb (Attribute_Constrained_Static_Value): Fix body box. * sem_attr.adb (Eval_Attribute): Replace repeated calls to Attribute_Name with a captured value of the Attribute_Id; also, remove extra parens around Is_Generic_Type. --- gcc/ada/exp_util.adb | 8 ++++---- gcc/ada/sem_attr.adb | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index ff26f17ffa1..bec7456c336 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -471,9 +471,9 @@ package body Exp_Util is end if; end Append_Freeze_Actions; - -------------------------------------- - -- Attr_Constrained_Statically_True -- - -------------------------------------- + ---------------------------------------- + -- Attribute_Constrained_Static_Value -- + ---------------------------------------- function Attribute_Constrained_Static_Value (Pref : Node_Id) return Boolean is @@ -535,7 +535,7 @@ package body Exp_Util is if Is_Entity_Name (Pref) then declare - Ent : constant Entity_Id := Entity (Pref); + Ent : constant Entity_Id := Entity (Pref); Res : Boolean; begin diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 8d8903a01e4..3374e9a320e 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -7793,7 +7793,7 @@ package body Sem_Attr is -- we will do the folding right here (things get confused if we let this -- case go through the normal circuitry). - if Attribute_Name (N) = Name_Img + if Id = Attribute_Img and then Is_Entity_Name (P) and then Is_Enumeration_Type (Etype (Entity (P))) and then Is_OK_Static_Expression (P) @@ -8127,7 +8127,7 @@ package body Sem_Attr is -- T'Descriptor_Size is never static, even if T is static. if Is_Scalar_Type (P_Entity) - and then (not Is_Generic_Type (P_Entity)) + and then not Is_Generic_Type (P_Entity) and then Is_Static_Subtype (P_Entity) and then Is_Scalar_Type (Etype (N)) and then @@ -8151,7 +8151,7 @@ package body Sem_Attr is if Is_Type (P_Entity) and then (Is_Scalar_Type (P_Entity) or Is_Array_Type (P_Entity)) - and then (not Is_Generic_Type (P_Entity)) + and then not Is_Generic_Type (P_Entity) then P_Type := P_Entity; @@ -8159,7 +8159,7 @@ package body Sem_Attr is elsif Ekind (P_Entity) in E_Variable | E_Constant and then Is_Array_Type (Etype (P_Entity)) - and then (not Is_Generic_Type (Etype (P_Entity))) + and then not Is_Generic_Type (Etype (P_Entity)) then P_Type := Etype (P_Entity); @@ -8208,7 +8208,7 @@ package body Sem_Attr is elsif (Id = Attribute_Size or Id = Attribute_Max_Size_In_Storage_Elements) and then Is_Type (P_Entity) - and then (not Is_Generic_Type (P_Entity)) + and then not Is_Generic_Type (P_Entity) and then Known_Static_RM_Size (P_Entity) then declare @@ -8230,7 +8230,7 @@ package body Sem_Attr is elsif Id = Attribute_Alignment and then Is_Type (P_Entity) - and then (not Is_Generic_Type (P_Entity)) + and then not Is_Generic_Type (P_Entity) and then Known_Alignment (P_Entity) then Compile_Time_Known_Attribute (N, Alignment (P_Entity)); @@ -8239,7 +8239,7 @@ package body Sem_Attr is -- If this is an access attribute that is known to fail accessibility -- check, rewrite accordingly. - elsif Attribute_Name (N) = Name_Access + elsif Id = Attribute_Address and then Raises_Constraint_Error (N) then Rewrite (N, -- 2.30.2