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;
-----------------------------------