1-- { dg-do compile }
2-- { dg-options "-O" }
3
4with Ada.Unchecked_Deallocation;
5
6with Opt46_Pkg;
7
8package body Opt46 is
9
10   type Pattern is abstract tagged null record;
11
12   type Pattern_Access is access Pattern'Class;
13
14   procedure Free is new Ada.Unchecked_Deallocation
15     (Pattern'Class, Pattern_Access);
16
17   type Action is abstract tagged null record;
18
19   type Action_Access is access Action'Class;
20
21   procedure Free is new Ada.Unchecked_Deallocation
22     (Action'Class, Action_Access);
23
24   type Pattern_Action is record
25      Pattern : Pattern_Access;
26      Action  : Action_Access;
27   end record;
28
29   package Pattern_Action_Table is new Opt46_Pkg (Pattern_Action, Natural, 1);
30
31   type Session_Data is record
32      Filters : Pattern_Action_Table.Instance;
33   end record;
34
35   procedure Close (Session : Session_Type) is
36      Filters : Pattern_Action_Table.Instance renames Session.Data.Filters;
37   begin
38      for F in 1 .. Pattern_Action_Table.Last (Filters) loop
39         Free (Filters.Table (F).Pattern);
40         Free (Filters.Table (F).Action);
41      end loop;
42
43   end Close;
44
45end Opt46;
46