aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gnat.dg/tagged_alloc_free.adb
blob: d26916dcb6e9ced28ce59c1d33f2ebbc01253a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- { dg-do run }

with Ada.Unchecked_Deallocation;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Tagged_Alloc_Free is

  type Test_Base is tagged null record;
  type Test_Class_Access is access all Test_Base'Class;
  type Test_Extension is new Test_Base with record
    Last_Name : Unbounded_String := Null_Unbounded_String;
  end record;

  procedure Free is new Ada.Unchecked_Deallocation
    (Object => Test_Base'Class,
     Name   => Test_Class_Access);

  Handle : Test_Class_Access := new Test_Extension;

begin
  Free (Handle);
end;