OSDN Git Service

* gcc-interface/trans.c (gnat_to_gnu): Avoid making a SAVE_EXPR for
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gnat.dg / timer_cancel.adb
1 -- { dg-do run }
2
3 with Ada.Real_Time.Timing_Events;
4 use Ada.Real_Time, Ada.Real_Time.Timing_Events;
5
6 procedure Timer_Cancel is
7
8    E : Timing_Event;
9    C : Boolean;
10
11    protected Dummy is
12       procedure Trigger (Event : in out Timing_Event);
13    end Dummy;
14
15    protected body Dummy is
16       procedure Trigger (Event : in out Timing_Event) is
17       begin
18          null;
19       end Trigger;
20    end Dummy;
21
22 begin
23    Set_Handler (E, Time_Last, Dummy.Trigger'Unrestricted_Access);
24
25    if Time_Of_Event (E) /= Time_Last then
26       raise Program_Error with "Event time not set correctly";
27    end if;
28
29    Cancel_Handler (E, C);
30
31    if not C then
32       raise Program_Error with "Event triggered already";
33    end if;
34
35    if Time_Of_Event (E) /= Time_First then
36       raise Program_Error with "Event time not reset correctly";
37    end if;
38 end Timer_Cancel;