re PR ada/41383 (Timing_Events: Event time not cleared after Cancel_Handler)

gcc/ada/
	PR ada/41383
	* a-rttiev.adb (Time_Of_Event): Return Time_First for unset event.

    gcc/testsuite/
	PR ada/41383
	* gnat.dg/timer_cancel.adb: New test.

From-SVN: r152487
This commit is contained in:
Samuel Tardieu 2009-10-06 07:20:53 +00:00 committed by Samuel Tardieu
parent 6fa30ef281
commit 2c12a29243
4 changed files with 55 additions and 1 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -332,7 +332,13 @@ package body Ada.Real_Time.Timing_Events is
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;
--------------

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,38 @@
-- { 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;