From 3a6fa9a81bdbd5491204e68b2ad5a5d8516d56a1 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 6 Oct 2020 11:58:45 +0200 Subject: [PATCH] [Ada] Cleanup expansion of attribute Constrained 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 | 11 +++-------- gcc/ada/sem_util.adb | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index f95c682a638..40de27b86bc 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -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); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 1190cfe21bf..3af4f3a4e12 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -25694,7 +25694,7 @@ package body Sem_Util is end if; end if; - return (Empty); + return Empty; end Param_Entity; ---------------------- -- 2.30.2