analyzer: Fix PR analyzer/101980
[official-gcc.git] / gcc / testsuite / gnat.dg / tagged3.adb
blob1468ee2c03e902fda2d1908a9e9bbe281660f882
1 -- { dg-do run }
3 with Tagged3_Pkg; use Tagged3_Pkg;
4 procedure Tagged3 is
5 package SP is
6 type Ref is tagged private;
8 procedure Set (Self : in out Ref'Class; Data : Parent'Class);
10 type Reference_Type (Element : access Parent'Class)
11 is limited null record with Implicit_Dereference => Element;
13 function Get (Self : Ref'Class) return Reference_Type;
15 private
16 type Element_Access is access all Parent'Class;
17 type Ref is tagged record
18 Data : Element_Access;
19 end record;
20 end;
22 package body SP is
23 procedure Set (Self : in out Ref'Class; Data : Parent'Class) is
24 begin
25 Self.Data := new Parent'Class'(Data);
26 end;
28 function Get (Self : Ref'Class) return Reference_Type is
29 begin
30 return Reference_Type'(Element => Self.Data);
31 end;
32 end;
34 DC : Child;
35 RC : SP.Ref;
36 begin
37 RC.Set (DC);
38 Prim1 (RC.Get.Element); -- Test
39 if not Tagged3_Pkg.Child_Prim1_Called then
40 raise Program_Error;
41 end if;
42 end;