This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Implement new Restriction No_Use_Of_Entity


A new restriction No_Use_Of_Entity is implemented. The form of this is
pragma Restriction[_Warning]s (No_Use_Of_Entity => NAME), where NAME is
a fully qualified entity name. The effect is to forbid references to
this entity in the main unit, its spec, and any subunits.

The following is compiled with -gnatl -gnatj55

     1. pragma Restrictions
     2.   (No_Use_Of_Entity => Ada.Text_IO.Put_Line);
     3. with Ada.Text_IO; use Ada.Text_IO;
     4. procedure NUOE is
     5. begin
     6.    Put ("Hello");
     7.    Put_Line ("Hello_World!");
           |
        >>> reference to "Put_Line" violates
            restriction No_Use_Of_Entity at line 2

     8. end;

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

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

	* restrict.adb (Check_Restriction_No_Use_Of_Attribute):
	New procedure.
	(OK_No_Use_Of_Entity_Name): New function.
	(Set_Restriction_No_Use_Of_Entity): New procedure.
	* restrict.ads (Check_Restriction_No_Use_Of_Attribute):
	New procedure.
	(OK_No_Use_Of_Entity_Name): New function.
	(Set_Restriction_No_Use_Of_Entity): New procedure.
	* sem_ch8.adb (Find_Direct_Name): Add check for violation of
	No_Use_Of_Entity.
	* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
	Add processing for new restriction No_Use_Of_Entity.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]