This patch fixes a compiler bug that caused the master of incomplete views to be missing, which caused a crash when allocating an object of the type, if the full type contains tasks.
The following example must compile quietly: gcc -c -gnat05 lim_view_example.adb lim_view_example-child.adb limited with Lim_View_Example.Child; package Lim_View_Example is type Acc is access Child.Child_T; procedure P (X : out Acc); end Lim_View_Example; package Lim_View_Example.Child is task type Task_Type; type Child_T is record A_Task : Task_Type; end record; end Lim_View_Example.Child; with Lim_View_Example.Child; package body Lim_View_Example is procedure P (X : out Acc) is begin X := new Child.Child_T; end P; end Lim_View_Example; package body Lim_View_Example.Child is task body Task_Type is begin null; end Task_Type; end Lim_View_Example.Child; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-07-08 Bob Duff <d...@adacore.com> * exp_ch3.adb (Build_Master): If Desig_Type is an incomplete view coming from a limited-with'ed package, use the nonlimited view in case it has tasks.
Index: exp_ch3.adb =================================================================== --- exp_ch3.adb (revision 200709) +++ exp_ch3.adb (working copy) @@ -4632,9 +4632,19 @@ ------------------ procedure Build_Master (Ptr_Typ : Entity_Id) is - Desig_Typ : constant Entity_Id := Designated_Type (Ptr_Typ); + Desig_Typ : Entity_Id := Designated_Type (Ptr_Typ); begin + -- If the designated type is an incomplete view coming from a + -- limited-with'ed package, we need to use the nonlimited view in + -- case it has tasks. + + if Ekind (Desig_Typ) in Incomplete_Kind + and then Present (Non_Limited_View (Desig_Typ)) + then + Desig_Typ := Non_Limited_View (Desig_Typ); + end if; + -- Anonymous access types are created for the components of the -- record parameter for an entry declaration. No master is created -- for such a type.