This fixes an assertion failure for the Finalizable aspect applied on a
tagged type with discriminant-dependent component.
gcc/ada/
PR ada/120705
* exp_ch6.adb (Needs_BIP_Collection): Always return False if the
type has relaxed finalization.
gcc/testsuite/
* gnat.dg/specs/finalizable2.ads: New test.
-- such build-in-place functions, primitive or not.
return not Restriction_Active (No_Finalization)
- and then ((Needs_Finalization (Typ)
- and then not Has_Relaxed_Finalization (Typ))
- or else Is_Tagged_Type (Typ))
+ and then (Needs_Finalization (Typ) or else Is_Tagged_Type (Typ))
+ and then not Has_Relaxed_Finalization (Typ)
and then not Has_Foreign_Convention (Typ);
end Needs_BIP_Collection;
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatX0" }
+
+package Finalizable2 is
+
+ type Root is abstract tagged limited null record
+ with Finalizable => (Initialize => Initialize);
+
+ procedure Initialize (this : in out Root) is abstract;
+
+ type Ext (L : Natural) is new Root with record
+ A : String (1 .. L);
+ end record;
+
+ overriding procedure Initialize (this : in out Ext) is null;
+
+ function Make return Ext is (L => 3, A => "asd");
+
+ Obj : Ext := Make;
+
+end Finalizable2;