[Ada] Remove repeated calls to Attribute_Name
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 9 Oct 2020 13:49:29 +0000 (15:49 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 25 Nov 2020 13:22:24 +0000 (08:22 -0500)
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
gcc/ada/sem_attr.adb

index ff26f17..bec7456 100644 (file)
@@ -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
index 8d8903a..3374e9a 100644 (file)
@@ -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,