Error_Msg_N ("?q?equality should be parenthesized here!", N);
end if;
- -- If the equality is overloaded and the operands have resolved
- -- properly, set the proper equality operator on the node. The
- -- current setting is the first one found during analysis, which
- -- is not necessarily the one to which the node has resolved.
-
- if Is_Overloaded (N) then
- declare
- I : Interp_Index;
- It : Interp;
-
- begin
- Get_First_Interp (N, I, It);
-
- -- If the equality is user-defined, the type of the operands
- -- matches that of the formals. For a predefined operator,
- -- it is the scope that matters, given that the predefined
- -- equality has Any_Type formals. In either case the result
- -- type (most often Boolean) must match the context. The scope
- -- is either that of the type, if there is a generated equality
- -- (when there is an equality for the component type), or else
- -- Standard otherwise.
-
- while Present (It.Typ) loop
- if Etype (It.Nam) = Typ
- and then
- (Etype (First_Entity (It.Nam)) = Etype (L)
- or else Scope (It.Nam) = Standard_Standard
- or else Scope (It.Nam) = Scope (T))
- then
- Set_Entity (N, It.Nam);
-
- Set_Is_Overloaded (N, False);
- exit;
- end if;
-
- Get_Next_Interp (I, It);
- end loop;
-
- -- If expansion is active and this is an inherited operation,
- -- replace it with its ancestor. This must not be done during
- -- preanalysis because the type may not be frozen yet, as when
- -- the context is a precondition or postcondition.
-
- if Present (Alias (Entity (N))) and then Expander_Active then
- Set_Entity (N, Alias (Entity (N)));
- end if;
- end;
- end if;
-
Check_Unset_Reference (L);
Check_Unset_Reference (R);
Generate_Operator_Reference (N, T);
end if;
-- Complete resolution and evaluation of NOT
- -- If argument is an equality and expected type is boolean, that
- -- expected type has no effect on resolution, and there are
- -- special rules for resolution of Eq, Neq in the presence of
- -- overloaded operands, so we directly call its resolution routines.
-
- declare
- Opnd : constant Node_Id := Right_Opnd (N);
- Op_Id : Entity_Id;
-
- begin
- if B_Typ = Standard_Boolean
- and then Nkind (Opnd) in N_Op_Eq | N_Op_Ne
- and then Is_Overloaded (Opnd)
- then
- Resolve_Equality_Op (Opnd, B_Typ);
- Op_Id := Entity (Opnd);
-
- if Ekind (Op_Id) = E_Function
- and then not Is_Intrinsic_Subprogram (Op_Id)
- then
- Rewrite_Operator_As_Call (Opnd, Op_Id);
- end if;
-
- if not Inside_A_Generic or else Is_Entity_Name (Opnd) then
- Freeze_Expression (Opnd);
- end if;
-
- Expand (Opnd);
-
- else
- Resolve (Opnd, B_Typ);
- end if;
-
- Check_Unset_Reference (Opnd);
- end;
+ Resolve (Right_Opnd (N), B_Typ);
+ Check_Unset_Reference (Right_Opnd (N));
Set_Etype (N, B_Typ);
Generate_Operator_Reference (N, B_Typ);
Eval_Op_Not (N);
return It2;
end if;
- -- An immediately visible operator hides a use-visible user-
- -- defined operation. This disambiguation cannot take place
- -- earlier because the visibility of the predefined operator
- -- can only be established when operand types are known.
+ -- RM 8.4(10): an immediately visible operator hides a use-visible
+ -- user-defined operation that is a homograph. This disambiguation
+ -- cannot take place earlier because visibility of the predefined
+ -- operator can only be established when operand types are known.
elsif Ekind (User_Subp) = E_Function
and then Ekind (Predef_Subp) = E_Operator
+ and then Operator_Matches_Spec (Predef_Subp, User_Subp)
and then Nkind (N) in N_Op
and then not Is_Overloaded (Right_Opnd (N))
and then