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] Library_Level attribute now applies to an entity name


The prefix of the Library_Level must now be an entity name, and the
attribute indicates if the entity is declarated at the library level.
Note that within a generic instantition, the name of the generic unit
denotes the instance, which means that this attribute can be used to
test if a generic is instantiated at the library level, as in:

     1. generic
     2. package LLTestP is
     3.    pragma Compile_Time_Warning
     4.      (not LLTestP'Library_Level,
     5.       "LLTest should be instantiated at library level");
     6. end;

     1. with LLTestP;
     2. package LLTestP1 is
     3.    package P is new LLTestP;
     4.    XXX : Integer;
     5.    P1L : constant Boolean := XXX'Library_Level;
     6. end;

     1. with LLTestP;
     2. with LLTestP1; use LLTestP1;
     3. with Text_IO; use Text_IO;
     4. procedure LLTest is
     5.    package P1 is new LLTestP;
           |
        >>> warning: in instantiation at lltestp.ads:4
        >>> warning: LLTest should be instantiated at library level

     6.    X : Integer;
           |
        >>> warning: variable "X" is read but never assigned

     7. begin
     8.    Put_Line (Boolean'Image (LLTest'Library_Level));
     9.    Put_Line (Boolean'Image (P1L));
    10.    Put_Line (Boolean'Image (X'Library_Level));
    11. end;

When executed, the output is:

TRUE
TRUE
FALSE

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

2013-10-14  Robert Dewar  <dewar@adacore.com>

	* gnat_rm.texi: Library_Level attribute now applies to an
	entity name.
	* sem_attr.adb (Analyze_Attribute, case Library_Level): Prefix
	is now an entity name.

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]