+2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * freeze.adb (Freeze_Entity): Do not freeze the partial view of
+ a private subtype if its base type is also private with delayed
+ freeze before the full type declaration of the base type has
+ been seen.
+ * sem_ch7.adb (Preserve_Full_Attributes): Add assertion on
+ freeze node.
+
2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
* exp_ch3.adb (Build_Record_Init_Proc): Inherit an
goto Leave;
- -- Case of no full view present. If entity is derived or subtype,
+ -- Case of no full view present. If entity is subtype or derived,
-- it is safe to freeze, correctness depends on the frozen status
-- of parent. Otherwise it is either premature usage, or a Taft
-- amendment type, so diagnosis is at the point of use and the
-- type might be frozen later.
- elsif E /= Base_Type (E) or else Is_Derived_Type (E) then
+ elsif E /= Base_Type (E) then
+ declare
+ Btyp : constant Entity_Id := Base_Type (E);
+
+ begin
+ -- However, if the base type is itself private and has no
+ -- (underlying) full view either, wait until the full type
+ -- declaration is seen and all the full views are created.
+
+ if Is_Private_Type (Btyp)
+ and then No (Full_View (Btyp))
+ and then No (Underlying_Full_View (Btyp))
+ and then Has_Delayed_Freeze (Btyp)
+ and then No (Freeze_Node (Btyp))
+ then
+ Set_Is_Frozen (E, False);
+ Result := No_List;
+ goto Leave;
+ end if;
+ end;
+
+ elsif Is_Derived_Type (E) then
null;
else
Propagate_Concurrent_Flags (Priv, Base_Type (Full));
end if;
+ -- As explained in Freeze_Entity, private types are required to point
+ -- to the same freeze node as their corresponding full view, if any.
+ -- But we ought not to overwrite a node already inserted in the tree.
+
+ pragma Assert (Serious_Errors_Detected /= 0
+ or else No (Freeze_Node (Priv))
+ or else No (Parent (Freeze_Node (Priv)))
+ or else Freeze_Node (Priv) = Freeze_Node (Full));
+
Set_Freeze_Node (Priv, Freeze_Node (Full));
-- Propagate Default_Initial_Condition-related attributes from the
+2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/generic_inst2.adb, gnat.dg/generic_inst2.ads,
+ gnat.dg/generic_inst2_c.ads: New testcase.
+
2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/overload2.adb, gnat.dg/overload2_p.adb,
--- /dev/null
+-- { dg-do compile }
+
+package body Generic_Inst2 is
+ procedure Foo (X : not null access T) is null;
+end;
--- /dev/null
+with Generic_Inst2_C;
+
+package Generic_Inst2 is
+ type T is private;
+ procedure Foo (X : not null access T);
+ package CI is new Generic_Inst2_C (T, Foo => Foo);
+private
+ type S is access Integer;
+ type T is new S;
+end;
--- /dev/null
+generic
+ type T;
+ with procedure Foo (X : not null access T) is null;
+ with procedure Bar (X : not null access T) is null;
+package Generic_Inst2_C is end;