-- Derived types that have no type extension can use the initialization
-- procedure of their parent and do not need a procedure of their own.
+ -- Same for derivations of unchecked_union types.
-- This is only correct if there are no representation clauses for the
-- type or its parent, and if the parent has in fact been frozen so
-- that its initialization procedure exists.
if Is_Derived_Type (Rec_Type)
and then not Is_Tagged_Type (Rec_Type)
- and then not Is_Unchecked_Union (Rec_Type)
+ and then Is_Unchecked_Union (Rec_Type)
+ = Is_Unchecked_Union (Etype (Rec_Type))
and then not Has_New_Non_Standard_Rep (Rec_Type)
and then not Parent_Subtype_Renaming_Discrims
and then Present (Base_Init_Proc (Etype (Rec_Type)))
Set_Has_Primitive_Operations
(Derived_Type, Has_Primitive_Operations (Parent_Base));
+ if Ekind (Derived_Type) = E_Record_Type then
+ Set_Is_Unchecked_Union
+ (Derived_Type, Is_Unchecked_Union (Parent_Base));
+ Set_Has_Unchecked_Union
+ (Derived_Type, Has_Unchecked_Union (Parent_Base));
+ end if;
+
-- Set fields for private derived types
if Is_Private_Type (Derived_Type) then
if not Is_Tagged then
Append_Elmt (Old_C, Assoc_List);
Append_Elmt (New_C, Assoc_List);
+
+ if Plain_Discrim then
+ Append_Elmt (Discriminal (Old_C), Assoc_List);
+ Append_Elmt (Discriminal (New_C), Assoc_List);
+ end if;
end if;
end Inherit_Component;