===================================================================
@@ -2078,15 +2078,19 @@
-- The location of entities that come from source in the list of
-- primitives of the tagged type must follow their order of occurrence
-- in the sources to fulfill the C++ ABI. If the overridden entity is a
- -- primitive of an interface that is not an ancestor of this tagged
- -- type (that is, it is an entity added to the list of primitives by
- -- Derive_Interface_Progenitors), then we must append the new entity
- -- at the end of the list of primitives.
+ -- primitive of an interface that is not implemented by the parents of
+ -- this tagged type (that is, it is an alias of an interface primitive
+ -- generated by Derive_Interface_Progenitors), then we must append the
+ -- new entity at the end of the list of primitives.
if Present (Alias (Prev_Op))
+ and then Etype (Tagged_Type) /= Tagged_Type
and then Is_Interface (Find_Dispatching_Type (Alias (Prev_Op)))
and then not Is_Ancestor (Find_Dispatching_Type (Alias (Prev_Op)),
Tagged_Type)
+ and then not Implements_Interface
+ (Etype (Tagged_Type),
+ Find_Dispatching_Type (Alias (Prev_Op)))
then
Remove_Elmt (Primitive_Operations (Tagged_Type), Elmt);
Append_Elmt (New_Op, Primitive_Operations (Tagged_Type));