2009-10-06 Samuel Tardieu <sam@rfc1149.net>
+ PR ada/41383
+ * a-rttiev.adb (Time_Of_Event): Return Time_First for unset event.
+
+2009-10-06 Samuel Tardieu <sam@rfc1149.net>
+
PR ada/38333
* sem_prag.adb (Process_Import_Or_Interface): Forbid an abstract
subprogram to be completed with a "pragma Import".
function Time_Of_Event (Event : Timing_Event) return Time is
begin
- return Event.Timeout;
+ -- RM D.15(18/2): Time_First must be returned if the event is not set
+
+ if Event.Handler = null then
+ return Time_First;
+ else
+ return Event.Timeout;
+ end if;
end Time_Of_Event;
--------------
2009-10-06 Samuel Tardieu <sam@rfc1149.net>
+ PR ada/41383
+ * gnat.dg/timer_cancel.adb: New test.
+
+2009-10-06 Samuel Tardieu <sam@rfc1149.net>
+
PR ada/38333
* gnat.dg/specs/import_abstract.ads: New.
--- /dev/null
+-- { dg-do run }
+
+with Ada.Real_Time.Timing_Events;
+use Ada.Real_Time, Ada.Real_Time.Timing_Events;
+
+procedure Timer_Cancel is
+
+ E : Timing_Event;
+ C : Boolean;
+
+ protected Dummy is
+ procedure Trigger (Event : in out Timing_Event);
+ end Dummy;
+
+ protected body Dummy is
+ procedure Trigger (Event : in out Timing_Event) is
+ begin
+ null;
+ end Trigger;
+ end Dummy;
+
+begin
+ Set_Handler (E, Time_Last, Dummy.Trigger'Unrestricted_Access);
+
+ if Time_Of_Event (E) /= Time_Last then
+ raise Program_Error with "Event time not set correctly";
+ end if;
+
+ Cancel_Handler (E, C);
+
+ if not C then
+ raise Program_Error with "Event triggered already";
+ end if;
+
+ if Time_Of_Event (E) /= Time_First then
+ raise Program_Error with "Event time not reset correctly";
+ end if;
+end Timer_Cancel;