diff mbox

[Ada] Enforce new no dependence restrictions with Ravenscar

Message ID 20101021102021.GA32192@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 21, 2010, 10:20 a.m. UTC
The Ravenscar profile defined in Ada 2005 forbade dependencies on packages
Ada.Execution_Time.Group_Budget and Ada.Execution_Time.Timers (among others
which were already forbidden). The definition of the Ravenscar profile is
being updated in Ada 2012 to including a restriction of no dependency on
the new package System.Multiprocessors.Dispatching_Domains. This patch
implements these restrictions.

The following test should not compile, indicating a violation of the
Ravenscar profile restrictions:

    1. pragma Profile (Ravenscar);
    2. with System.Multiprocessors.Dispatching_Domains;
    3. procedure No_Dependences_DD is
    4. begin
    5.    null;
    6. end No_Dependences_DD;

The output when compiled with -gnat12 is:

no_dependences_dd.adb:2:06: violation of restriction "No_Dependence =>
System.Multiprocessors.Dispatching_Domains" at line 1
gnatmake: "no_dependences_dd.adb" compilation error

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

2010-10-21  Jose Ruiz  <ruiz@adacore.com>

	* sem_prag.adb (Set_Ravenscar_Profile): Enforce the restrictions of no
	dependence on Ada.Execution_Time.Timers,
	Ada.Execution_Time.Group_Budget, and
	System.Multiprocessors.Dispatching_Domains which are part of the
	Ravenscar Profile.
	* impunit.adb (Non_Imp_File_Names_05): Add the file "a-etgrbu" to the
	list of Ada 2005 files for package Ada.Execution_Time.Group_Budgets.
	(Non_Imp_File_Names_12): Add the file "s-mudido" to the list of Ada 2012
	files for package System.Mutiprocessors.Dispatching_Domains.
diff mbox

Patch

Index: impunit.adb
===================================================================
--- impunit.adb	(revision 165755)
+++ impunit.adb	(working copy)
@@ -394,6 +394,7 @@  package body Impunit is
      "a-disedf",    -- Ada.Dispatching.EDF
      "a-dispat",    -- Ada.Dispatching
      "a-envvar",    -- Ada.Environment_Variables
+     "a-etgrbu",    -- Ada.Execution_Time.Group_Budgets
      "a-exetim",    -- Ada.Execution_Time
      "a-extiti",    -- Ada.Execution_Time.Timers
      "a-izteio",    -- Ada.Integer_Wide_Wide_Text_IO
@@ -504,7 +505,8 @@  package body Impunit is
    --  The following units should be used only in Ada 2012 mode
 
    Non_Imp_File_Names_12 : constant File_List := (
-     0 => "s-multip");   -- System.Mutiprocessors
+     "s-multip",    -- System.Multiprocessors
+     "s-mudido");   -- System.Multiprocessors.Dispatching_Domains
 
    -----------------------
    -- Alternative Units --
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 165755)
+++ sem_prag.adb	(working copy)
@@ -5410,7 +5410,20 @@  package body Sem_Prag is
 
       --    Set required restrictions (see System.Rident for detailed list)
 
+      --    Set the No_Dependence rules
+      --      No_Dependence => Ada.Asynchronous_Task_Control
+      --      No_Dependence => Ada.Calendar
+      --      No_Dependence => Ada.Execution_Time.Group_Budget
+      --      No_Dependence => Ada.Execution_Time.Timers
+      --      No_Dependence => Ada.Task_Attributes
+      --      No_Dependence => System.Multiprocessors.Dispatching_Domains
+
       procedure Set_Ravenscar_Profile (N : Node_Id) is
+         Prefix_Entity   : Entity_Id;
+         Selector_Entity : Entity_Id;
+         Prefix_Node     : Node_Id;
+         Node            : Node_Id;
+
       begin
          --  pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
 
@@ -5459,6 +5472,106 @@  package body Sem_Prag is
 
          Set_Profile_Restrictions
            (Ravenscar, N, Warn => Treat_Restrictions_As_Warnings);
+
+         --  Set the No_Dependence restrictions
+
+         --  The following No_Dependence restrictions:
+         --    No_Dependence => Ada.Asynchronous_Task_Control
+         --    No_Dependence => Ada.Calendar
+         --    No_Dependence => Ada.Task_Attributes
+         --  are already set by previous call to Set_Profile_Restrictions.
+
+         --  Set the following restrictions which were added to Ada 2005:
+         --    No_Dependence => Ada.Execution_Time.Group_Budget
+         --    No_Dependence => Ada.Execution_Time.Timers
+
+         if Ada_Version >= Ada_2005 then
+            Name_Buffer (1 .. 3) := "ada";
+            Name_Len := 3;
+
+            Prefix_Entity := Make_Identifier (Loc, Name_Find);
+
+            Name_Buffer (1 .. 14) := "execution_time";
+            Name_Len := 14;
+
+            Selector_Entity := Make_Identifier (Loc, Name_Find);
+
+            Prefix_Node :=
+              Make_Selected_Component
+                (Sloc          => Loc,
+                 Prefix        => Prefix_Entity,
+                 Selector_Name => Selector_Entity);
+
+            Name_Buffer (1 .. 13) := "group_budgets";
+            Name_Len := 13;
+
+            Selector_Entity := Make_Identifier (Loc, Name_Find);
+
+            Node :=
+              Make_Selected_Component
+                (Sloc          => Loc,
+                 Prefix        => Prefix_Node,
+                 Selector_Name => Selector_Entity);
+
+            Set_Restriction_No_Dependence
+              (Unit    => Node,
+               Warn    => Treat_Restrictions_As_Warnings,
+               Profile => Ravenscar);
+
+            Name_Buffer (1 .. 6) := "timers";
+            Name_Len := 6;
+
+            Selector_Entity := Make_Identifier (Loc, Name_Find);
+
+            Node :=
+              Make_Selected_Component
+                (Sloc          => Loc,
+                 Prefix        => Prefix_Node,
+                 Selector_Name => Selector_Entity);
+
+            Set_Restriction_No_Dependence
+              (Unit    => Node,
+               Warn    => Treat_Restrictions_As_Warnings,
+               Profile => Ravenscar);
+         end if;
+
+         --  Set the following restrictions which was added to Ada 2012 (see
+         --  AI-0171):
+         --    No_Dependence => System.Multiprocessors.Dispatching_Domains
+
+         if Ada_Version >= Ada_2012 then
+            Name_Buffer (1 .. 6) := "system";
+            Name_Len := 6;
+
+            Prefix_Entity := Make_Identifier (Loc, Name_Find);
+
+            Name_Buffer (1 .. 15) := "multiprocessors";
+            Name_Len := 15;
+
+            Selector_Entity := Make_Identifier (Loc, Name_Find);
+
+            Prefix_Node :=
+              Make_Selected_Component
+                (Sloc          => Loc,
+                 Prefix        => Prefix_Entity,
+                 Selector_Name => Selector_Entity);
+
+            Name_Buffer (1 .. 19) := "dispatching_domains";
+            Name_Len := 19;
+
+            Selector_Entity := Make_Identifier (Loc, Name_Find);
+
+            Node :=
+              Make_Selected_Component
+                (Sloc          => Loc,
+                 Prefix        => Prefix_Node,
+                 Selector_Name => Selector_Entity);
+
+            Set_Restriction_No_Dependence
+              (Unit    => Node,
+               Warn    => Treat_Restrictions_As_Warnings,
+               Profile => Ravenscar);
+         end if;
       end Set_Ravenscar_Profile;
 
    --  Start of processing for Analyze_Pragma