-- We need a predicate check if the type has predicates that are not
-- ignored, and if either there is an initializing expression, or for
-- default initialization when we have at least one case of an explicit
- -- default initial value and then this is not an internal declaration
- -- whose initialization comes later (as for an aggregate expansion).
+ -- default initial value (including via a Default_Value or
+ -- Default_Component_Value aspect, see AI12-0301) and then this is not
+ -- an internal declaration whose initialization comes later (as for an
+ -- aggregate expansion).
-- If expression is an aggregate it may be expanded into assignments
-- and the declaration itself is marked with No_Initialization, but
-- the predicate still applies.
is
begin
if Is_Scalar_Type (Typ) then
- return False;
+ return Has_Default_Aspect (Base_Type (Typ));
elsif Is_Access_Type (Typ) then
return Include_Implicit;
-- If component type is partially initialized, so is array type
- if Is_Partially_Initialized_Type
- (Component_Type (Typ), Include_Implicit)
+ if Has_Default_Aspect (Base_Type (Typ))
+ or else Is_Partially_Initialized_Type
+ (Component_Type (Typ), Include_Implicit)
then
return True;
-- Typ is a type entity. This function returns true if this type is partly
-- initialized, meaning that an object of the type is at least partly
-- initialized (in particular in the record case, that at least one
- -- component has an initialization expression). Note that initialization
+ -- component has an initialization expression, including via Default_Value
+ -- and Default_Component_Value aspects). Note that initialization
-- resulting from the use of pragma Normalize_Scalars does not count.
-- Include_Implicit controls whether implicit initialization of access
-- values to null, and of discriminant values, is counted as making the