===================================================================
@@ -165,6 +165,10 @@
-- Force evaluation of bounds of a slice, which may be given by a range
-- or by a subtype indication with or without a constraint.
+ function Is_Verifiable_DIC_Pragma (Prag : Node_Id) return Boolean;
+ -- Determine whether pragma Default_Initial_Condition denoted by Prag has
+ -- an assertion expression that should be verified at run time.
+
function Make_CW_Equivalent_Type
(T : Entity_Id;
E : Node_Id) return Entity_Id;
@@ -1500,6 +1504,7 @@
-- Start of processing for Add_Own_DIC
begin
+ pragma Assert (Present (DIC_Expr));
Expr := New_Copy_Tree (DIC_Expr);
-- Perform the following substitution:
@@ -1733,8 +1738,6 @@
-- Produce an empty completing body in the following cases:
-- * Assertions are disabled
-- * The DIC Assertion_Policy is Ignore
- -- * Pragma DIC appears without an argument
- -- * Pragma DIC appears with argument "null"
if No (Stmts) then
Stmts := New_List (Make_Null_Statement (Loc));
@@ -8715,6 +8718,21 @@
and then Is_Itype (Full_Typ);
end Is_Untagged_Private_Derivation;
+ ------------------------------
+ -- Is_Verifiable_DIC_Pragma --
+ ------------------------------
+
+ function Is_Verifiable_DIC_Pragma (Prag : Node_Id) return Boolean is
+ Args : constant List_Id := Pragma_Argument_Associations (Prag);
+
+ begin
+ -- To qualify as verifiable, a DIC pragma must have a non-null argument
+
+ return
+ Present (Args)
+ and then Nkind (Get_Pragma_Arg (First (Args))) /= N_Null;
+ end Is_Verifiable_DIC_Pragma;
+
---------------------------
-- Is_Volatile_Reference --
---------------------------
===================================================================
@@ -10384,19 +10384,16 @@
function Has_Full_Default_Initialization (Typ : Entity_Id) return Boolean is
Comp : Entity_Id;
- Prag : Node_Id;
begin
- -- A type subject to pragma Default_Initial_Condition is fully default
- -- initialized when the pragma appears with a non-null argument. Since
- -- any type may act as the full view of a private type, this check must
- -- be performed prior to the specialized tests below.
+ -- A type subject to pragma Default_Initial_Condition may be fully
+ -- default initialized depending on inheritance and the argument of
+ -- the pragma. Since any type may act as the full view of a private
+ -- type, this check must be performed prior to the specialized tests
+ -- below.
- if Has_DIC (Typ) then
- Prag := Get_Pragma (Typ, Pragma_Default_Initial_Condition);
- pragma Assert (Present (Prag));
-
- return Is_Verifiable_DIC_Pragma (Prag);
+ if Has_Fully_Default_Initializing_DIC_Pragma (Typ) then
+ return True;
end if;
-- A scalar type is fully default initialized if it is subject to aspect
@@ -10463,6 +10460,47 @@
end if;
end Has_Full_Default_Initialization;
+ -----------------------------------------------
+ -- Has_Fully_Default_Initializing_DIC_Pragma --
+ -----------------------------------------------
+
+ function Has_Fully_Default_Initializing_DIC_Pragma
+ (Typ : Entity_Id) return Boolean
+ is
+ Args : List_Id;
+ Prag : Node_Id;
+
+ begin
+ -- A type that inherits pragma Default_Initial_Condition from a parent
+ -- type is automatically fully default initialized.
+
+ if Has_Inherited_DIC (Typ) then
+ return True;
+
+ -- Otherwise the type is fully default initialized only when the pragma
+ -- appears without an argument, or the argument is non-null.
+
+ elsif Has_Own_DIC (Typ) then
+ Prag := Get_Pragma (Typ, Pragma_Default_Initial_Condition);
+ pragma Assert (Present (Prag));
+ Args := Pragma_Argument_Associations (Prag);
+
+ -- The pragma appears without an argument in which case it defaults
+ -- to True.
+
+ if No (Args) then
+ return True;
+
+ -- The pragma appears with a non-null expression
+
+ elsif Nkind (Get_Pragma_Arg (First (Args))) /= N_Null then
+ return True;
+ end if;
+ end if;
+
+ return False;
+ end Has_Fully_Default_Initializing_DIC_Pragma;
+
--------------------
-- Has_Infinities --
--------------------
@@ -17018,21 +17056,6 @@
end if;
end Is_Variable;
- ------------------------------
- -- Is_Verifiable_DIC_Pragma --
- ------------------------------
-
- function Is_Verifiable_DIC_Pragma (Prag : Node_Id) return Boolean is
- Args : constant List_Id := Pragma_Argument_Associations (Prag);
-
- begin
- -- To qualify as verifiable, a DIC pragma must have a non-null argument
-
- return
- Present (Args)
- and then Nkind (Get_Pragma_Arg (First (Args))) /= N_Null;
- end Is_Verifiable_DIC_Pragma;
-
---------------------------
-- Is_Visibly_Controlled --
---------------------------
===================================================================
@@ -1238,9 +1238,15 @@
-- either include a default expression or have a type which defines
-- full default initialization. In the case of type extensions, the
-- parent type defines full default initialization.
- -- * A task type
- -- * A private type whose Default_Initial_Condition is non-null
+ -- * A task type
+ -- * A private type with pragma Default_Initial_Condition that provides
+ -- full default initialization.
+ function Has_Fully_Default_Initializing_DIC_Pragma
+ (Typ : Entity_Id) return Boolean;
+ -- Determine whether type Typ has a suitable Default_Initial_Condition
+ -- pragma which provides the full default initialization of the type.
+
function Has_Infinities (E : Entity_Id) return Boolean;
-- Determines if the range of the floating-point type E includes
-- infinities. Returns False if E is not a floating-point type.
@@ -1980,10 +1986,6 @@
-- default is True since this routine is commonly invoked as part of the
-- semantic analysis and it must not be disturbed by the rewriten nodes.
- function Is_Verifiable_DIC_Pragma (Prag : Node_Id) return Boolean;
- -- Determine whether pragma Default_Initial_Condition denoted by Prag has
- -- an assertion expression which should be verified at runtime.
-
function Is_Visibly_Controlled (T : Entity_Id) return Boolean;
-- Check whether T is derived from a visibly controlled type. This is true
-- if the root type is declared in Ada.Finalization. If T is derived
===================================================================
@@ -1742,22 +1742,17 @@
-----------------------------
function Is_OK_Fully_Initialized return Boolean is
- Prag : Node_Id;
-
begin
if Is_Access_Type (Typ) and then Is_Dereferenced (N) then
return False;
- -- A type subject to pragma Default_Initial_Condition is fully
- -- default initialized when the pragma appears with a non-null
- -- argument (SPARK RM 3.1 and SPARK RM 7.3.3).
+ -- A type subject to pragma Default_Initial_Condition may be fully
+ -- default initialized depending on inheritance and the argument of
+ -- the pragma (SPARK RM 3.1 and SPARK RM 7.3.3).
- elsif Has_DIC (Typ) then
- Prag := Get_Pragma (Typ, Pragma_Default_Initial_Condition);
- pragma Assert (Present (Prag));
+ elsif Has_Fully_Default_Initializing_DIC_Pragma (Typ) then
+ return True;
- return Is_Verifiable_DIC_Pragma (Prag);
-
else
return Is_Fully_Initialized_Type (Typ);
end if;
===================================================================
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+
+with Dflt_Init_Cond_Pkg; use Dflt_Init_Cond_Pkg;
+
+procedure Dflt_Init_Cond is
+ E : Explicit;
+ I : Implicit;
+
+begin
+ Read (E);
+ Read (I);
+end Dflt_Init_Cond;
===================================================================
@@ -0,0 +1,11 @@
+package Dflt_Init_Cond_Pkg is
+ type Explicit is limited private with Default_Initial_Condition => True;
+ type Implicit is limited private with Default_Initial_Condition;
+
+ procedure Read (Obj : Explicit);
+ procedure Read (Obj : Implicit);
+
+private
+ type Implicit is access all Integer;
+ type Explicit is access all Integer;
+end Dflt_Init_Cond_Pkg;