]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/41383 (Timing_Events: Event time not cleared after Cancel_Handler)
authorSamuel Tardieu <sam@rfc1149.net>
Tue, 6 Oct 2009 07:20:53 +0000 (07:20 +0000)
committerSamuel Tardieu <sam@gcc.gnu.org>
Tue, 6 Oct 2009 07:20:53 +0000 (07:20 +0000)
    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

gcc/ada/ChangeLog
gcc/ada/a-rttiev.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/timer_cancel.adb [new file with mode: 0644]

index 7af8f31c1e99f9171d8276a92e4849dd192b72d8..d5e34e916ad138ae66ac216374858011d6684b90 100644 (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
index 2068c7868505101d2606bea5c5a00a1f212ab625..55687ec8f6beb57f04c1d23cf9d65b22e2dcf84e 100644 (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;
 
    --------------
index c65aab8eb7f8837397ba9f81a69cce2b713dd949..e9214c2b3b4db31ab603972b6165527e1902cf35 100644 (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
diff --git a/gcc/testsuite/gnat.dg/timer_cancel.adb b/gcc/testsuite/gnat.dg/timer_cancel.adb
new file mode 100644 (file)
index 0000000..c300b47
--- /dev/null
@@ -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;