From: Ronan Desplanques <desplanq...@adacore.com> Process_Subtype can be passed either a subtype indication or a subtype mark. Before this patch, it branched directly depending on the kind of the argument, but there actually was processing common to the two branches like resolving the subtype mark. This patch factorizes this common processing out of the if statement.
gcc/ada/ChangeLog: * sem_ch3.adb (Process_Subtype): Factorize code. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.adb | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index ff5d0bab99f..75901bb8eff 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -22801,6 +22801,7 @@ package body Sem_Ch3 is -- Local variables P : constant Node_Id := Parent (S); + Mark : Node_Id; Def_Id : Entity_Id; Error_Node : Node_Id; Full_View_Id : Entity_Id; @@ -22809,22 +22810,28 @@ package body Sem_Ch3 is -- Start of processing for Process_Subtype begin + if Nkind (S) = N_Subtype_Indication then + Mark := Subtype_Mark (S); + else + Mark := S; + end if; + + Find_Type (Mark); + + -- No way to proceed if the subtype indication is malformed. This will + -- happen for example when the subtype indication in an object + -- declaration is missing altogether and the expression is analyzed as + -- if it were that indication. + + if not Is_Entity_Name (Mark) then + return Any_Type; + end if; + + Check_Incomplete (Mark); + -- Case of no constraints present if Nkind (S) /= N_Subtype_Indication then - Find_Type (S); - - -- No way to proceed if the subtype indication is malformed. This - -- will happen for example when the subtype indication in an object - -- declaration is missing altogether and the expression is analyzed - -- as if it were that indication. - - if not Is_Entity_Name (S) then - return Any_Type; - end if; - - Check_Incomplete (S); - if Excludes_Null then -- Create an Itype that is a duplicate of Entity (S) but with the -- null-exclusion attribute. @@ -22886,11 +22893,7 @@ package body Sem_Ch3 is -- node (this node is created only if constraints are present). else - Find_Type (Subtype_Mark (S)); - - Check_Incomplete (Subtype_Mark (S)); - - Subtype_Mark_Id := Entity (Subtype_Mark (S)); + Subtype_Mark_Id := Entity (Mark); -- Explicit subtype declaration case -- 2.43.0