-- Determines whether a type has a subcomponent of an unconstrained
-- Unchecked_Union subtype. Typ is a record type.
+ procedure Warn_On_Abstract_Equality_For_Component
+ (Comp_Type : Entity_Id);
+ -- If Comp_Type has a user-defined abstract equality function, then
+ -- issue a warning that Program_Error will be raised.
+
-------------------------
-- Build_Equality_Call --
-------------------------
Unconstrained_UU_In_Component_List (Optional_Component_List);
end Has_Unconstrained_UU_Component;
+ ---------------------------------------------
+ -- Warn_On_Abstract_Equality_For_Component --
+ ---------------------------------------------
+
+ procedure Warn_On_Abstract_Equality_For_Component
+ (Comp_Type : Entity_Id)
+ is
+ Eq : Entity_Id;
+ begin
+ if Is_Record_Type (Underlying_Type (Comp_Type)) then
+ Eq := Get_User_Defined_Equality (Comp_Type);
+
+ if Present (Eq) and then Is_Abstract_Subprogram (Eq) then
+ Error_Msg_Warn := SPARK_Mode /= On;
+ Error_Msg_NE ("call to abstract equality function of "
+ & "component type &<<", N, Comp_Type);
+ Error_Msg_N ("\Program_Error [<<", N);
+ end if;
+ end if;
+ end Warn_On_Abstract_Equality_For_Component;
+
-- Local variables
Typl : Entity_Id;
-- Array types
elsif Is_Array_Type (Typl) then
+ Warn_On_Abstract_Equality_For_Component (Component_Type (Typl));
-- If we are doing full validity checking, and it is possible for the
-- array elements to be invalid then expand out array comparisons to
elsif Is_Record_Type (Typl) then
+ declare
+ Comp : Entity_Id := First_Component (Typl);
+ begin
+ while Present (Comp) loop
+ if Chars (Comp) /= Name_uParent then
+ Warn_On_Abstract_Equality_For_Component (Etype (Comp));
+ end if;
+
+ Next_Component (Comp);
+ end loop;
+ end;
+
-- For tagged types, use the primitive "="
if Is_Tagged_Type (Typl) then