From ad6be99f1ac24607e9c49cdbc9c300d76007f0b6 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Sun, 15 Nov 2020 01:21:41 +0100 Subject: [PATCH] [Ada] Simplify analysis of assignment statements gcc/ada/ * sem_ch5.adb (Set_Assignment_Type): Combine calls to Ekind using membership test. (Should_Transform_BIP_Assignment): Replace assignment to a "Result" variable with simple return statements; avoid repeated calls to Unqual_Conv by declaring a local constant. --- gcc/ada/sem_ch5.adb | 58 ++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index df412bd4714..52150df5e69 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -303,9 +303,9 @@ package body Sem_Ch5 is -- also have an actual subtype. if Is_Entity_Name (Opnd) - and then (Ekind (Entity (Opnd)) = E_Out_Parameter - or else Ekind (Entity (Opnd)) in - E_In_Out_Parameter | E_Generic_In_Out_Parameter + and then (Ekind (Entity (Opnd)) in E_Out_Parameter + | E_In_Out_Parameter + | E_Generic_In_Out_Parameter or else (Ekind (Entity (Opnd)) = E_Variable and then Nkind (Parent (Entity (Opnd))) = @@ -349,8 +349,6 @@ package body Sem_Ch5 is function Should_Transform_BIP_Assignment (Typ : Entity_Id) return Boolean is - Result : Boolean; - begin if Expander_Active and then not Is_Limited_View (Typ) @@ -364,37 +362,33 @@ package body Sem_Ch5 is -- parameterless function call if it denotes a function. -- Finally, an attribute reference can be a function call. - case Nkind (Unqual_Conv (Rhs)) is - when N_Function_Call - | N_Op - => - Result := True; - - when N_Expanded_Name - | N_Identifier - => - case Ekind (Entity (Unqual_Conv (Rhs))) is - when E_Function - | E_Operator - => - Result := True; - - when others => - Result := False; - end case; - - when N_Attribute_Reference => - Result := Attribute_Name (Unqual_Conv (Rhs)) = Name_Input; + declare + Unqual_Rhs : constant Node_Id := Unqual_Conv (Rhs); + begin + case Nkind (Unqual_Rhs) is + when N_Function_Call + | N_Op + => + return True; + + when N_Expanded_Name + | N_Identifier + => + return + Ekind (Entity (Unqual_Rhs)) in E_Function | E_Operator; + -- T'Input will turn into a call whose result type is T - when others => - Result := False; - end case; + when N_Attribute_Reference => + return Attribute_Name (Unqual_Rhs) = Name_Input; + + when others => + return False; + end case; + end; else - Result := False; + return False; end if; - - return Result; end Should_Transform_BIP_Assignment; ------------------------------ -- 2.30.2