-- avoided here, when the created subtype declaration is analyzed. (See
-- Build_Derived_Types)
- -- This also happens when the full view of a private type is derived
+ -- This also happens when the full view of a private type is a derived
-- type with constraints. In this case the entity has been introduced
-- in the private declaration.
-- 5. FIRST TRANSFORMATION FOR DERIVED RECORDS
--
- -- Regardless of whether we dealing with a tagged or untagged type
+ -- Regardless of whether we are dealing with a tagged or untagged type
-- we will transform all derived type declarations of the form
--
-- type T is new R (...) [with ...];
Parent_Base := Base_Type (Parent_Base);
end if;
+ -- If the parent base is a private type and only its full view has
+ -- discriminants, use the full view's base type.
+
+ -- This can happen when we are deriving from a subtype of a derived type
+ -- of a private type derived from a discriminated type with known
+ -- discriminant:
+ --
+ -- package Pkg;
+ -- type Root_Type(I: Positive) is record
+ -- ...
+ -- end record;
+ -- type Bounded_Root_Type is private;
+ -- private
+ -- type Bounded_Root_Type is new Root_Type(10);
+ -- end Pkg;
+ --
+ -- package Pkg2 is
+ -- type Constrained_Root_Type is new Pkg.Bounded_Root_Type;
+ -- end Pkg2;
+ -- subtype Sub_Base is Pkg2.Constrained_Root_Type;
+ -- type New_Der_Type is new Sub_Base;
+
+ if Is_Private_Type (Parent_Base)
+ and then Present (Full_View (Parent_Base))
+ and then not Has_Discriminants (Parent_Base)
+ and then Has_Discriminants (Full_View (Parent_Base))
+ then
+ Parent_Base := Base_Type (Full_View (Parent_Base));
+ end if;
+
-- AI05-0115: if this is a derivation from a private type in some
-- other scope that may lead to invisible components for the derived
-- type, mark it accordingly.
Is_Completion => False, Derive_Subps => False);
-- ??? This needs re-examination to determine whether the
- -- above call can simply be replaced by a call to Analyze.
+ -- following call can simply be replaced by a call to Analyze.
Set_Analyzed (New_Decl);