From: Piotr Trojanek Date: Wed, 10 Sep 2025 10:07:17 +0000 (+0200) Subject: ada: Remove unnecessary declare block X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=616d104215e7a270e221232a048260530051cba9;p=thirdparty%2Fgcc.git ada: Remove unnecessary declare block Code cleanup; semantics is unaffected. gcc/ada/ChangeLog: * sem_ch4.adb (Analyze_User_Defined_Binary_Op): Remove declare block. --- diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 31debfee85c..b0abfe4bb6b 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -6623,53 +6623,50 @@ package body Sem_Ch4 is procedure Analyze_User_Defined_Binary_Op (N : Node_Id; - Op_Id : Entity_Id) is + Op_Id : Entity_Id) + is + F1 : constant Entity_Id := First_Formal (Op_Id); + F2 : constant Entity_Id := Next_Formal (F1); begin - declare - F1 : constant Entity_Id := First_Formal (Op_Id); - F2 : constant Entity_Id := Next_Formal (F1); - - begin - -- Verify that Op_Id is a visible binary function. Note that since - -- we know Op_Id is overloaded, potentially use visible means use - -- visible for sure (RM 9.4(11)). Be prepared for previous errors. - - if Ekind (Op_Id) = E_Function - and then Present (F2) - and then (Is_Immediately_Visible (Op_Id) - or else Is_Potentially_Use_Visible (Op_Id)) - and then (Has_Compatible_Type (Left_Opnd (N), Etype (F1)) - or else Etype (F1) = Any_Type) - and then (Has_Compatible_Type (Right_Opnd (N), Etype (F2)) - or else Etype (F2) = Any_Type) - then - Add_One_Interp (N, Op_Id, Base_Type (Etype (Op_Id))); + -- Verify that Op_Id is a visible binary function. Note that since + -- we know Op_Id is overloaded, potentially use visible means use + -- visible for sure (RM 9.4(11)). Be prepared for previous errors. + + if Ekind (Op_Id) = E_Function + and then Present (F2) + and then (Is_Immediately_Visible (Op_Id) + or else Is_Potentially_Use_Visible (Op_Id)) + and then (Has_Compatible_Type (Left_Opnd (N), Etype (F1)) + or else Etype (F1) = Any_Type) + and then (Has_Compatible_Type (Right_Opnd (N), Etype (F2)) + or else Etype (F2) = Any_Type) + then + Add_One_Interp (N, Op_Id, Base_Type (Etype (Op_Id))); - -- If the operands are overloaded, indicate that the current - -- type is a viable candidate. This is redundant in most cases, - -- but for equality and comparison operators where the context - -- does not impose a type on the operands, setting the proper - -- type is necessary to avoid subsequent ambiguities during - -- resolution, when both user-defined and predefined operators - -- may be candidates. + -- If the operands are overloaded, indicate that the current + -- type is a viable candidate. This is redundant in most cases, + -- but for equality and comparison operators where the context + -- does not impose a type on the operands, setting the proper + -- type is necessary to avoid subsequent ambiguities during + -- resolution, when both user-defined and predefined operators + -- may be candidates. - if Is_Overloaded (Left_Opnd (N)) then - Set_Etype (Left_Opnd (N), Etype (F1)); - end if; + if Is_Overloaded (Left_Opnd (N)) then + Set_Etype (Left_Opnd (N), Etype (F1)); + end if; - if Is_Overloaded (Right_Opnd (N)) then - Set_Etype (Right_Opnd (N), Etype (F2)); - end if; + if Is_Overloaded (Right_Opnd (N)) then + Set_Etype (Right_Opnd (N), Etype (F2)); + end if; - if Debug_Flag_E then - Write_Str ("user defined operator "); - Write_Name (Chars (Op_Id)); - Write_Str (" on node "); - Write_Int (Int (N)); - Write_Eol; - end if; + if Debug_Flag_E then + Write_Str ("user defined operator "); + Write_Name (Chars (Op_Id)); + Write_Str (" on node "); + Write_Int (Int (N)); + Write_Eol; end if; - end; + end if; end Analyze_User_Defined_Binary_Op; -----------------------------------