From 337cbb9f9edaebb6cd6dba2f22c9d0437e1f81a0 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 27 Nov 2020 15:28:09 +0100 Subject: [PATCH] [Ada] Style cleanups in Parse_Aspect_Stable_Properties gcc/ada/ * sem_ch13.adb (Parse_Aspect_Stable_Properties): Fix style; limit the scope of local variables; remove extra assignment in Extract_Entity. (Validate_Aspect_Stable_Properties): Simplify with procedural Next. --- gcc/ada/sem_ch13.adb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4120a47..f1a2304 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -15094,27 +15094,39 @@ package body Sem_Ch13 is function Parse_Aspect_Stable_Properties (Aspect_Spec : Node_Id; Negated : out Boolean) return Subprogram_List is - L : List_Id; - Id : Node_Id; - function Extract_Entity (Expr : Node_Id) return Entity_Id; - -- Given an element of a Stable_Properties aspect spec, - -- return the associated entity. + -- Given an element of a Stable_Properties aspect spec, return the + -- associated entity. -- This function updates the Negated flag as a side-effect. + -------------------- + -- Extract_Entity -- + -------------------- + function Extract_Entity (Expr : Node_Id) return Entity_Id is - Name : Node_Id := Expr; + Name : Node_Id; begin if Nkind (Expr) = N_Op_Not then Negated := True; Name := Right_Opnd (Expr); + else + Name := Expr; end if; + if Nkind (Name) in N_Has_Entity then return Entity (Name); else return Empty; end if; end Extract_Entity; + + -- Local variables + + L : List_Id; + Id : Node_Id; + + -- Start of processing for Parse_Aspect_Stable_Properties + begin Negated := False; @@ -15128,7 +15140,7 @@ package body Sem_Ch13 is for I in Result'Range loop Result (I) := Extract_Entity (Id); - if not Present (Result (I)) then + if No (Result (I)) then pragma Assert (Serious_Errors_Detected > 0); goto Ignore_Aspect; end if; @@ -15308,7 +15320,7 @@ package body Sem_Ch13 is begin while Present (PF_Arg) loop Check_Property_Function_Arg (PF_Arg); - PF_Arg := Next (PF_Arg); + Next (PF_Arg); end loop; end; else -- 2.7.4