Patchwork [Ada] No_Relative_Delay forbids Set_Handler calls

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 7, 2010, 11 a.m.
Message ID <20101007110002.GA27889@adacore.com>
Download mbox | patch
Permalink /patch/67032/
State New
Headers show

Comments

Arnaud Charlet - Oct. 7, 2010, 11 a.m.
A call to Ada.Real_Time.Timing_Events.Set_Handler violates
restriction No_Relative_Delay (AI-0211). This patch
implements this interpertation.

The following compiled with -gnat05 -gnatws:

pragma Restrictions (No_Relative_Delay);
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Real_Time.Timing_Events;
use  Ada.Real_Time.Timing_Events;
procedure NoRelDel is
   TE  : Timing_Event;
   TEH : Timing_Event_Handler;
   TS  : Time_Span;
begin
   Set_Handler (TE, TS, TEH);
end NoRelDel;

Generates the output:

noreldel.adb:10:04: violation of restriction "No_Relative_Delay" at line 1

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-07  Robert Dewar  <dewar@adacore.com>

	* rtsfind.ads: Add entry for Ada.Real_Time.Timing_Events.Set_Handler
	* sem_res.adb (Resolve_Call): A call to
	Ada.Real_Time.Timing_Events.Set_Handler violates restriction
	No_Relative_Delay (AI-0211).

Patch

Index: rtsfind.ads
===================================================================
--- rtsfind.ads	(revision 165081)
+++ rtsfind.ads	(working copy)
@@ -536,7 +536,8 @@  package Rtsfind is
      RO_RT_Delay_Until,                  -- Ada.Real_Time.Delays
      RO_RT_To_Duration,                  -- Ada.Real_Time.Delays
 
-     RE_Timing_Event,                    -- Ada_Real_Time_Timing_Events
+     RE_Set_Handler,                     -- Ada_Real_Time.Timing_Events
+     RE_Timing_Event,                    -- Ada_Real_Time.Timing_Events
 
      RE_Root_Stream_Type,                -- Ada.Streams
      RE_Stream_Element,                  -- Ada.Streams
@@ -1707,6 +1708,7 @@  package Rtsfind is
      RO_RT_Delay_Until                   => Ada_Real_Time_Delays,
      RO_RT_To_Duration                   => Ada_Real_Time_Delays,
 
+     RE_Set_Handler                      => Ada_Real_Time_Timing_Events,
      RE_Timing_Event                     => Ada_Real_Time_Timing_Events,
 
      RE_Root_Stream_Type                 => Ada_Streams,
Index: sem_res.adb
===================================================================
--- sem_res.adb	(revision 165084)
+++ sem_res.adb	(working copy)
@@ -5554,6 +5554,13 @@  package body Sem_Res is
          Check_Potentially_Blocking_Operation (N);
       end if;
 
+      --  A call to Ada.Real_Time.Timing_Events.Set_Handler violates
+      --  restriction No_Relative_Delay (AI-0211).
+
+      if Is_RTE (Nam, RE_Set_Handler) then
+         Check_Restriction (No_Relative_Delay, N);
+      end if;
+
       --  Issue an error for a call to an eliminated subprogram. We skip this
       --  in a spec expression, e.g. a call in a default parameter value, since
       --  we are not really doing a call at this time. That's important because