aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-11-15 01:21:41 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2020-11-30 09:16:21 -0500
commitad6be99f1ac24607e9c49cdbc9c300d76007f0b6 (patch)
treecda6468fa75ea0fe7442ae215d553d83fa54ea9b
parent348050563099e7b73e37d28d10beac3a7dec1a86 (diff)
downloadgcc-ad6be99f1ac24607e9c49cdbc9c300d76007f0b6.zip
gcc-ad6be99f1ac24607e9c49cdbc9c300d76007f0b6.tar.gz
gcc-ad6be99f1ac24607e9c49cdbc9c300d76007f0b6.tar.bz2
[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.
-rw-r--r--gcc/ada/sem_ch5.adb58
1 files changed, 26 insertions, 32 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index df412bd..52150df 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;
------------------------------