+2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
+
+ * einfo.ads (Is_For_Access_Subtype): Delete.
+ (Set_Is_For_Access_Subtype): Likewise.
+ * einfo.adb (Is_For_Access_Subtype): Likewise.
+ (Set_Is_For_Access_Subtype): Likewise.
+ (Write_Entity_Flags): Do not write Is_For_Access_Subtype.
+ * exp_ch4.adb (Expand_N_Selected_Component): Do not deal with
+ it.
+ * exp_spark.adb (Expand_SPARK_N_Selected_Component): Likewise.
+ * sem_ch4.adb (Analyze_Explicit_Dereference): Likewise.
+ * sem_ch3.adb (Build_Discriminated_Subtype): Do not build a
+ special private subtype for access-to-record subtypes.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch3.adb (Complete_Private_Subtype): Rework the setting of
-- Never_Set_In_Source Flag115
-- Is_Visible_Lib_Unit Flag116
-- Is_Unchecked_Union Flag117
- -- Is_For_Access_Subtype Flag118
-- Has_Convention_Pragma Flag119
-- Has_Primitive_Operations Flag120
return Flag70 (Id);
end Is_First_Subtype;
- function Is_For_Access_Subtype (Id : E) return B is
- begin
- pragma Assert (Ekind_In (Id, E_Record_Subtype, E_Private_Subtype));
- return Flag118 (Id);
- end Is_For_Access_Subtype;
-
function Is_Formal_Subprogram (Id : E) return B is
begin
return Flag111 (Id);
Set_Flag70 (Id, V);
end Set_Is_First_Subtype;
- procedure Set_Is_For_Access_Subtype (Id : E; V : B := True) is
- begin
- pragma Assert (Ekind_In (Id, E_Record_Subtype, E_Private_Subtype));
- Set_Flag118 (Id, V);
- end Set_Is_For_Access_Subtype;
-
procedure Set_Is_Formal_Subprogram (Id : E; V : B := True) is
begin
Set_Flag111 (Id, V);
W ("Is_Exported", Flag99 (Id));
W ("Is_Finalized_Transient", Flag252 (Id));
W ("Is_First_Subtype", Flag70 (Id));
- W ("Is_For_Access_Subtype", Flag118 (Id));
W ("Is_Formal_Subprogram", Flag111 (Id));
W ("Is_Frozen", Flag4 (Id));
W ("Is_Generic_Actual_Subprogram", Flag274 (Id));
-- Is_Formal_Subprogram (Flag111)
-- Defined in all entities. Set for generic formal subprograms.
--- Is_For_Access_Subtype (Flag118)
--- Defined in E_Private_Subtype and E_Record_Subtype entities. Means the
--- sole purpose of the type is to be designated by an Access_Subtype and
--- hence should not be expanded into components because the type may not
--- have been found or frozen yet.
-
-- Is_Frozen (Flag4)
-- Defined in all type and subtype entities. Set if type or subtype has
-- been frozen.
-- Stored_Constraint (Elist23)
-- Has_Completion (Flag26)
-- Is_Controlled_Active (Flag42) (base type only)
- -- Is_For_Access_Subtype (Flag118) (subtype only)
-- (plus type attributes)
-- E_Procedure
function Is_Exported (Id : E) return B;
function Is_Finalized_Transient (Id : E) return B;
function Is_First_Subtype (Id : E) return B;
- function Is_For_Access_Subtype (Id : E) return B;
function Is_Frozen (Id : E) return B;
function Is_Generic_Instance (Id : E) return B;
function Is_Hidden (Id : E) return B;
procedure Set_Is_Exported (Id : E; V : B := True);
procedure Set_Is_Finalized_Transient (Id : E; V : B := True);
procedure Set_Is_First_Subtype (Id : E; V : B := True);
- procedure Set_Is_For_Access_Subtype (Id : E; V : B := True);
procedure Set_Is_Formal_Subprogram (Id : E; V : B := True);
procedure Set_Is_Frozen (Id : E; V : B := True);
procedure Set_Is_Generic_Actual_Subprogram (Id : E; V : B := True);
pragma Inline (Is_First_Subtype);
pragma Inline (Is_Fixed_Point_Type);
pragma Inline (Is_Floating_Point_Type);
- pragma Inline (Is_For_Access_Subtype);
pragma Inline (Is_Formal);
pragma Inline (Is_Formal_Object);
pragma Inline (Is_Formal_Subprogram);
pragma Inline (Set_Is_Exported);
pragma Inline (Set_Is_Finalized_Transient);
pragma Inline (Set_Is_First_Subtype);
- pragma Inline (Set_Is_For_Access_Subtype);
pragma Inline (Set_Is_Formal_Subprogram);
pragma Inline (Set_Is_Frozen);
pragma Inline (Set_Is_Generic_Actual_Subprogram);
Insert_Explicit_Dereference (P);
Analyze_And_Resolve (P, Designated_Type (Ptyp));
- if Ekind (Etype (P)) = E_Private_Subtype
- and then Is_For_Access_Subtype (Etype (P))
- then
- Set_Etype (P, Base_Type (Etype (P)));
- end if;
-
Ptyp := Etype (P);
end if;
Insert_Explicit_Dereference (Pref);
Analyze_And_Resolve (Pref, Designated_Type (Typ));
-
- if Ekind (Etype (Pref)) = E_Private_Subtype
- and then Is_For_Access_Subtype (Etype (Pref))
- then
- Set_Etype (Pref, Base_Type (Etype (Pref)));
- end if;
end if;
end Expand_SPARK_N_Selected_Component;
-- T has discriminants but there are no discriminant constraints). The
-- Related_Nod is the same as Decl_Node in Create_Constrained_Components.
-- The For_Access says whether or not this subtype is really constraining
- -- an access type. That is its sole purpose is the designated type of an
- -- access type -- in which case a Private_Subtype Is_For_Access_Subtype
- -- is built to avoid freezing T when the access subtype is frozen.
+ -- an access type.
function Build_Scalar_Bound
(Bound : Node_Id;
begin
if Ekind (T) = E_Record_Type then
- if For_Access then
- Set_Ekind (Def_Id, E_Private_Subtype);
- Set_Is_For_Access_Subtype (Def_Id, True);
- else
- Set_Ekind (Def_Id, E_Record_Subtype);
- end if;
+ Set_Ekind (Def_Id, E_Record_Subtype);
-- Inherit preelaboration flag from base, for types for which it
-- may have been set: records, private types, protected types.
then
Create_Constrained_Components (Def_Id, Related_Nod, T, Elist);
- elsif not For_Access then
+ else
Set_Cloned_Subtype (Def_Id, T);
end if;
end if;
if not Is_Overloaded (P) then
if Is_Access_Type (Etype (P)) then
- -- Set the Etype. We need to go through Is_For_Access_Subtypes to
- -- avoid other problems caused by the Private_Subtype and it is
- -- safe to go to the Base_Type because this is the same as
- -- converting the access value to its Base_Type.
+ -- Set the Etype
declare
- DT : Entity_Id := Designated_Type (Etype (P));
+ DT : constant Entity_Id := Designated_Type (Etype (P));
begin
- if Ekind (DT) = E_Private_Subtype
- and then Is_For_Access_Subtype (DT)
- then
- DT := Base_Type (DT);
- end if;
-
-- An explicit dereference is a legal occurrence of an
-- incomplete type imported through a limited_with clause, if
-- the full view is visible, or if we are within an instance