[Ada] Cleanup expansion of attribute Constrained
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 6 Oct 2020 09:58:45 +0000 (11:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 24 Nov 2020 10:16:04 +0000 (05:16 -0500)
gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Replace calls to
Sloc with a local constant Loc; remove call to
Analyze_And_Resolve and return, which is exactly what happens
anyway (and other branches in the Constrained declare block
appear to rely on analysis, resolution and returning happening
in all cases).
* sem_util.adb: Remove useless parens.

gcc/ada/exp_attr.adb
gcc/ada/sem_util.adb

index f95c682..40de27b 100644 (file)
@@ -2923,8 +2923,6 @@ package body Exp_Attr is
       when Attribute_Constrained => Constrained : declare
          Formal_Ent : constant Entity_Id := Param_Entity (Pref);
 
-      --  Start of processing for Constrained
-
       begin
          --  Reference to a parameter where the value is passed as an extra
          --  actual, corresponding to the extra formal referenced by the
@@ -2938,7 +2936,7 @@ package body Exp_Attr is
          then
             Rewrite (N,
               New_Occurrence_Of
-                (Extra_Constrained (Formal_Ent), Sloc (N)));
+                (Extra_Constrained (Formal_Ent), Loc));
 
          --  If the prefix is an access to object, the attribute applies to
          --  the designated object, so rewrite with an explicit dereference.
@@ -2949,8 +2947,6 @@ package body Exp_Attr is
          then
             Rewrite (Pref,
               Make_Explicit_Dereference (Loc, Relocate_Node (Pref)));
-            Analyze_And_Resolve (N, Standard_Boolean);
-            return;
 
          --  For variables with a Extra_Constrained field, we use the
          --  corresponding entity.
@@ -2961,7 +2957,7 @@ package body Exp_Attr is
          then
             Rewrite (N,
               New_Occurrence_Of
-                (Extra_Constrained (Entity (Pref)), Sloc (N)));
+                (Extra_Constrained (Entity (Pref)), Loc));
 
          --  For all other cases, we can tell at compile time
 
@@ -2978,8 +2974,7 @@ package body Exp_Attr is
             Rewrite (N,
               New_Occurrence_Of
                 (Boolean_Literals
-                   (Exp_Util.Attribute_Constrained_Static_Value
-                      (Pref)), Sloc (N)));
+                   (Exp_Util.Attribute_Constrained_Static_Value (Pref)), Loc));
          end if;
 
          Analyze_And_Resolve (N, Standard_Boolean);
index 1190cfe..3af4f3a 100644 (file)
@@ -25694,7 +25694,7 @@ package body Sem_Util is
          end if;
       end if;
 
-      return (Empty);
+      return Empty;
    end Param_Entity;
 
    ----------------------