diff mbox

[Ada] Preliminary work for new restriction No_Use_Of_Entity

Message ID 20150106093217.GA11293@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Jan. 6, 2015, 9:32 a.m. UTC
This checkin is preliminary work for a new restriction No_Use_Of_Entity.
No test needed, since no external effect yet!

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

2015-01-06  Robert Dewar  <dewar@adacore.com>

	* namet.ads: Document use of Boolean2 for No_Use_Of_Entity.
	* restrict.ads (No_Use_Of_Entity): New table.
	* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
	Ignore No_Use_Of_Entity (will be processed in parser).
	* snames.ads-tmpl: Add entry for Name_No_Use_Of_Entity.
diff mbox

Patch

Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 219230)
+++ sem_prag.adb	(working copy)
@@ -8857,7 +8857,7 @@ 
                   raise Pragma_Exit;
                end if;
 
-            --  Case of No_Specification_Of_Aspect => Identifier.
+            --  Case of No_Specification_Of_Aspect => aspect-identifier
 
             elsif Id = Name_No_Specification_Of_Aspect then
                declare
@@ -8877,6 +8877,8 @@ 
                   end if;
                end;
 
+            --  Case of No_Use_Of_Attribute => attribute-identifier
+
             elsif Id = Name_No_Use_Of_Attribute then
                if Nkind (Expr) /= N_Identifier
                  or else not Is_Attribute_Name (Chars (Expr))
@@ -8887,6 +8889,15 @@ 
                   Set_Restriction_No_Use_Of_Attribute (Expr, Warn);
                end if;
 
+            --  Case of No_Use_Of_Entity => fully-qualified-name. Note that the
+            --  parser already processed this case commpletely, including error
+            --  checking and making an entry in the No_Use_Of_Entity table.
+
+            elsif Id = Name_No_Use_Of_Entity then
+               null;
+
+            --  Case of No_Use_Of_Pragma => pragma-identifier
+
             elsif Id = Name_No_Use_Of_Pragma then
                if Nkind (Expr) /= N_Identifier
                  or else not Is_Pragma_Name (Chars (Expr))
Index: restrict.ads
===================================================================
--- restrict.ads	(revision 219191)
+++ restrict.ads	(working copy)
@@ -51,8 +51,8 @@ 
    --  set from package Standard by the processing in Targparm.
 
    Restriction_Profile_Name : array (All_Restrictions) of Profile_Name;
-   --  Entries in this array are valid only if the corresponding restriction
-   --  in Restrictions set. The value is the corresponding profile name if the
+   --  Entries in this array are valid only if the corresponding restriction in
+   --  Restrictions is set. The value is the corresponding profile name if the
    --  restriction was set by a Profile or Profile_Warnings pragma. The value
    --  is No_Profile in all other cases.
 
@@ -148,6 +148,10 @@ 
       SPARK_05                           => True,
       others                             => False);
 
+   --------------------------
+   -- No_Dependences Table --
+   --------------------------
+
    --  The following table records entries made by Restrictions pragmas
    --  that specify a parameter for No_Dependence. Each such pragma makes
    --  an entry in this table.
@@ -179,6 +183,43 @@ 
      Table_Increment      => 200,
      Table_Name           => "Name_No_Dependences");
 
+   ----------------------------
+   -- No_Use_Of_Entity Table --
+   ----------------------------
+
+   --  The following table records entries made by Restrictions pragmas
+   --  that specify a parameter for No_Use_Of_Entity. Each such pragma makes
+   --  an entry in this table.
+
+   --  Note: we have chosen to implement this restriction in the "syntactic"
+   --  form, where we allow arbitrary fully qualified names to be specified.
+
+   type NE_Entry is record
+      Entity : Node_Id;
+      --  The entity parameter from the No_Use_Of_Entity pragma. This is in
+      --  the form of a selected component, since that is the way the parser
+      --  processes it, and we don't further analyze it.
+
+      Warn : Boolean;
+      --  True if from Restriction_Warnings, False if from Restrictions
+
+      Profile : Profile_Name;
+      --  Set to name of profile from which No_Use_Of_Entity entry came, or to
+      --  No_Profile if a pragma Restriction set the No_Use_Of_Entity entry.
+   end record;
+
+   package No_Use_Of_Entity is new Table.Table (
+     Table_Component_Type => NE_Entry,
+     Table_Index_Type     => Int,
+     Table_Low_Bound      => 0,
+     Table_Initial        => 200,
+     Table_Increment      => 200,
+     Table_Name           => "Name_No_Use_Of_Entity");
+
+   --  Note that in addition to making an entry in this table, we also set the
+   --  Boolean2 flag of the Name_Table entry for the simple name of the entity.
+   --  This is used to avoid most useless searches of this table.
+
    -----------------
    -- Subprograms --
    -----------------
Index: namet.ads
===================================================================
--- namet.ads	(revision 219231)
+++ namet.ads	(working copy)
@@ -131,8 +131,12 @@ 
 --      The Boolean1 field is used to mark address clauses to optimize the
 --      performance of the Exp_Util.Following_Address_Clause function.
 
---      The Boolean2/Boolean3 fields are not used
+--      The Boolean2 field is used to mark simple names that appear in
+--      Restriction[_Warning]s pragmas for No_Use_Of_Entity. This avoids most
+--      unnecessary searches of the No_Use_Of_Entity table.
 
+--      The Boolean3 field is not used
+
 --    In the binder, we have the following uses:
 
 --      The Int field is used in various ways depending on the name involved,
Index: snames.ads-tmpl
===================================================================
--- snames.ads-tmpl	(revision 219191)
+++ snames.ads-tmpl	(working copy)
@@ -751,6 +751,7 @@ 
    Name_No_Task_Attributes             : constant Name_Id := N + $;
    Name_No_Task_Attributes_Package     : constant Name_Id := N + $;
    Name_No_Use_Of_Attribute            : constant Name_Id := N + $;
+   Name_No_Use_Of_Entity               : constant Name_Id := N + $;
    Name_No_Use_Of_Pragma               : constant Name_Id := N + $;
    Name_No_Unroll                      : constant Name_Id := N + $;
    Name_No_Vector                      : constant Name_Id := N + $;