===================================================================
@@ -7444,6 +7444,7 @@
Set_Full_View (Derived_Type, Full_Der);
else
Set_Underlying_Full_View (Derived_Type, Full_Der);
+ Set_Is_Underlying_Full_View (Full_Der);
end if;
if not Is_Base_Type (Derived_Type) then
@@ -7501,6 +7502,7 @@
Set_Full_View (Derived_Type, Full_Der);
else
Set_Underlying_Full_View (Derived_Type, Full_Der);
+ Set_Is_Underlying_Full_View (Full_Der);
end if;
-- In any case, the primitive operations are inherited from the
@@ -7607,6 +7609,7 @@
else
Build_Full_Derivation;
Set_Underlying_Full_View (Derived_Type, Full_Der);
+ Set_Is_Underlying_Full_View (Full_Der);
end if;
-- The full view will be used to swap entities on entry/exit to
@@ -10018,6 +10021,7 @@
Analyze (Indic);
Set_Underlying_Full_View (Typ, Full_View (Subt));
+ Set_Is_Underlying_Full_View (Full_View (Subt));
end Build_Underlying_Full_View;
-------------------------------
===================================================================
@@ -1736,13 +1736,24 @@
-- Start of processing for Build_DIC_Procedure_Body
begin
- Work_Typ := Typ;
+ Work_Typ := Base_Type (Typ);
- -- The input type denotes the implementation base type of a constrained
- -- array type. Work with the first subtype as the DIC pragma is on its
- -- rep item chain.
+ -- Do not process class-wide types as these are Itypes, but lack a first
+ -- subtype (see below).
- if Ekind (Work_Typ) = E_Array_Type and then Is_Itype (Work_Typ) then
+ if Is_Class_Wide_Type (Work_Typ) then
+ return;
+
+ -- Do not process the underlying full view of a private type. There is
+ -- no way to get back to the partial view, plus the body will be built
+ -- by the full view or the base type.
+
+ elsif Is_Underlying_Full_View (Work_Typ) then
+ return;
+
+ -- Use the first subtype when dealing with various base types
+
+ elsif Is_Itype (Work_Typ) then
Work_Typ := First_Subtype (Work_Typ);
-- The input denotes the corresponding record type of a protected or a
@@ -1964,13 +1975,24 @@
-- The working type
begin
- Work_Typ := Typ;
+ Work_Typ := Base_Type (Typ);
- -- The input type denotes the implementation base type of a constrained
- -- array type. Work with the first subtype as the DIC pragma is on its
- -- rep item chain.
+ -- Do not process class-wide types as these are Itypes, but lack a first
+ -- subtype (see below).
- if Ekind (Work_Typ) = E_Array_Type and then Is_Itype (Work_Typ) then
+ if Is_Class_Wide_Type (Work_Typ) then
+ return;
+
+ -- Do not process the underlying full view of a private type. There is
+ -- no way to get back to the partial view, plus the body will be built
+ -- by the full view or the base type.
+
+ elsif Is_Underlying_Full_View (Work_Typ) then
+ return;
+
+ -- Use the first subtype when dealing with various base types
+
+ elsif Is_Itype (Work_Typ) then
Work_Typ := First_Subtype (Work_Typ);
-- The input denotes the corresponding record type of a protected or a
===================================================================
@@ -2178,6 +2178,7 @@
then
Set_Full_View (Id, Underlying_Full_View (Full));
Set_Underlying_Full_View (Id, Full);
+ Set_Is_Underlying_Full_View (Full);
Set_Underlying_Full_View (Full, Empty);
Set_Is_Frozen (Full_View (Id));
===================================================================
@@ -614,8 +614,8 @@
-- Is_Ignored_Transient Flag295
-- Has_Partial_Visible_Refinement Flag296
-- Is_Entry_Wrapper Flag297
+ -- Is_Underlying_Full_View Flag298
- -- (unused) Flag298
-- (unused) Flag299
-- (unused) Flag300
@@ -2612,6 +2612,11 @@
return Flag117 (Implementation_Base_Type (Id));
end Is_Unchecked_Union;
+ function Is_Underlying_Full_View (Id : E) return B is
+ begin
+ return Flag298 (Id);
+ end Is_Underlying_Full_View;
+
function Is_Underlying_Record_View (Id : E) return B is
begin
return Flag246 (Id);
@@ -5709,6 +5714,12 @@
Set_Flag117 (Id, V);
end Set_Is_Unchecked_Union;
+ procedure Set_Is_Underlying_Full_View (Id : E; V : B := True) is
+ begin
+ pragma Assert (Is_Type (Id));
+ Set_Flag298 (Id, V);
+ end Set_Is_Underlying_Full_View;
+
procedure Set_Is_Underlying_Record_View (Id : E; V : B := True) is
begin
pragma Assert (Ekind (Id) = E_Record_Type);
@@ -9457,6 +9468,7 @@
W ("Is_Trivial_Subprogram", Flag235 (Id));
W ("Is_True_Constant", Flag163 (Id));
W ("Is_Unchecked_Union", Flag117 (Id));
+ W ("Is_Underlying_Full_View", Flag298 (Id));
W ("Is_Underlying_Record_View", Flag246 (Id));
W ("Is_Unimplemented", Flag284 (Id));
W ("Is_Unsigned_Type", Flag144 (Id));
===================================================================
@@ -3236,6 +3236,11 @@
-- Defined in all entities. Set only in record types to which the
-- pragma Unchecked_Union has been validly applied.
+-- Is_Underlying_Full_View (Flag298)
+-- Defined in all entities. Set for types which represent the true full
+-- view of a private type completed by another private type. For further
+-- details, see attribute Underlying_Full_View.
+
-- Is_Underlying_Record_View (Flag246) [base type only]
-- Defined in all entities. Set only in record types that represent the
-- underlying record view. This view is built for derivations of types
@@ -7183,6 +7188,7 @@
function Is_Trivial_Subprogram (Id : E) return B;
function Is_True_Constant (Id : E) return B;
function Is_Unchecked_Union (Id : E) return B;
+ function Is_Underlying_Full_View (Id : E) return B;
function Is_Underlying_Record_View (Id : E) return B;
function Is_Unimplemented (Id : E) return B;
function Is_Unsigned_Type (Id : E) return B;
@@ -7868,6 +7874,7 @@
procedure Set_Is_Trivial_Subprogram (Id : E; V : B := True);
procedure Set_Is_True_Constant (Id : E; V : B := True);
procedure Set_Is_Unchecked_Union (Id : E; V : B := True);
+ procedure Set_Is_Underlying_Full_View (Id : E; V : B := True);
procedure Set_Is_Underlying_Record_View (Id : E; V : B := True);
procedure Set_Is_Unimplemented (Id : E; V : B := True);
procedure Set_Is_Unsigned_Type (Id : E; V : B := True);
@@ -8705,6 +8712,7 @@
pragma Inline (Is_True_Constant);
pragma Inline (Is_Type);
pragma Inline (Is_Unchecked_Union);
+ pragma Inline (Is_Underlying_Full_View);
pragma Inline (Is_Underlying_Record_View);
pragma Inline (Is_Unimplemented);
pragma Inline (Is_Unsigned_Type);
@@ -9180,6 +9188,7 @@
pragma Inline (Set_Is_Trivial_Subprogram);
pragma Inline (Set_Is_True_Constant);
pragma Inline (Set_Is_Unchecked_Union);
+ pragma Inline (Set_Is_Underlying_Full_View);
pragma Inline (Set_Is_Underlying_Record_View);
pragma Inline (Set_Is_Unimplemented);
pragma Inline (Set_Is_Unsigned_Type);
===================================================================
@@ -2087,6 +2087,12 @@
-- Determine whether an arbitrary entity is subject to Boolean aspect
-- Import and its value is specified as True.
+ procedure Inherit_Freeze_Node
+ (Fnod : Node_Id;
+ Typ : Entity_Id);
+ -- Set type Typ's freeze node to refer to Fnode. This routine ensures
+ -- that any attributes attached to Typ's original node are preserved.
+
procedure Wrap_Imported_Subprogram (E : Entity_Id);
-- If E is an entity for an imported subprogram with pre/post-conditions
-- then this procedure will create a wrapper to ensure that proper run-
@@ -4726,6 +4732,60 @@
return False;
end Has_Boolean_Aspect_Import;
+ -------------------------
+ -- Inherit_Freeze_Node --
+ -------------------------
+
+ procedure Inherit_Freeze_Node
+ (Fnod : Node_Id;
+ Typ : Entity_Id)
+ is
+ Typ_Fnod : constant Node_Id := Freeze_Node (Typ);
+
+ begin
+ Set_Freeze_Node (Typ, Fnod);
+ Set_Entity (Fnod, Typ);
+
+ -- The input type had an existing node. Propagate relevant attributes
+ -- from the old freeze node to the inherited freeze node.
+
+ -- ??? if both freeze nodes have attributes, would they differ?
+
+ if Present (Typ_Fnod) then
+
+ -- Attribute Access_Types_To_Process
+
+ if Present (Access_Types_To_Process (Typ_Fnod))
+ and then No (Access_Types_To_Process (Fnod))
+ then
+ Set_Access_Types_To_Process (Fnod,
+ Access_Types_To_Process (Typ_Fnod));
+ end if;
+
+ -- Attribute Actions
+
+ if Present (Actions (Typ_Fnod)) and then No (Actions (Fnod)) then
+ Set_Actions (Fnod, Actions (Typ_Fnod));
+ end if;
+
+ -- Attribute First_Subtype_Link
+
+ if Present (First_Subtype_Link (Typ_Fnod))
+ and then No (First_Subtype_Link (Fnod))
+ then
+ Set_First_Subtype_Link (Fnod, First_Subtype_Link (Typ_Fnod));
+ end if;
+
+ -- Attribute TSS_Elist
+
+ if Present (TSS_Elist (Typ_Fnod))
+ and then No (TSS_Elist (Fnod))
+ then
+ Set_TSS_Elist (Fnod, TSS_Elist (Typ_Fnod));
+ end if;
+ end if;
+ end Inherit_Freeze_Node;
+
------------------------------
-- Wrap_Imported_Subprogram --
------------------------------
@@ -5776,9 +5836,9 @@
F_Node := Freeze_Node (Full);
if Present (F_Node) then
- Set_Freeze_Node (Full_View (E), F_Node);
- Set_Entity (F_Node, Full_View (E));
-
+ Inherit_Freeze_Node
+ (Fnod => F_Node,
+ Typ => Full_View (E));
else
Set_Has_Delayed_Freeze (Full_View (E), False);
Set_Freeze_Node (Full_View (E), Empty);
@@ -5789,9 +5849,9 @@
F_Node := Freeze_Node (Full_View (E));
if Present (F_Node) then
- Set_Freeze_Node (E, F_Node);
- Set_Entity (F_Node, E);
-
+ Inherit_Freeze_Node
+ (Fnod => F_Node,
+ Typ => E);
else
-- {Incomplete,Private}_Subtypes with Full_Views
-- constrained by discriminants.
@@ -5847,9 +5907,9 @@
F_Node := Freeze_Node (Underlying_Full_View (E));
if Present (F_Node) then
- Set_Freeze_Node (E, F_Node);
- Set_Entity (F_Node, E);
-
+ Inherit_Freeze_Node
+ (Fnod => F_Node,
+ Typ => E);
else
Set_Has_Delayed_Freeze (E, False);
Set_Freeze_Node (E, Empty);