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 No_Implicit_Aliasing restriction


This restriction, which is not required to be partition-wide consistent,
requires an explicit aliased keyword for an object to which 'Access,
'Unchecked_Access, or 'Address is applied, and forbids entirely the
use of the 'Unrestricted_Access attribute for objects.

The following test program tests this restriction

     1. pragma Restrictions (No_Implicit_Aliasing);
     2. procedure NoImplicitAliasing is
     3.    OK : aliased Integer;
     4.    NOK : Integer;
     5.    type R is access all Integer;
     6.    RV  : R;
     7.    OK1 : Integer;
     8.    for OK1'Address use OK'Address;
     9.    NOK1 : Integer;
    10.    for NOK1'Address use NOK'Address;
                                |
        >>> violation of restriction "No_Implicit_Aliasing" at line 1

    11. begin
    12.    RV := OK'access;
    13.    RV := NOK'access;
                 |
        >>> violation of restriction "No_Implicit_Aliasing" at line 1
        >>> prefix of "Access" attribute must be explicitly aliased

    14.    RV := OK'unchecked_access;
    15.    RV := NOK'unchecked_access;
                 |
        >>> violation of restriction "No_Implicit_Aliasing" at line 1
        >>> prefix of "Unchecked_Access" attribute must be explicitly aliased

    16.    RV := OK'unrestricted_access;
                   |
        >>> violation of restriction "No_Implicit_Aliasing" at line 1

    17.    RV := NOK'unrestricted_access;
                    |
        >>> violation of restriction "No_Implicit_Aliasing" at line 1

    18. end;

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

2011-09-02  Robert Dewar  <dewar@adacore.com>

	* s-rident.ads: Add new restriction No_Implicit_Aliasing
	* sem_attr.adb: (Analyze_Access_Attribute): Deal with
	No_Implicit_Aliasing
	(Analyze_Attribute, case Address): ditto
	(Analyze_Attribute, case Unrestricted_Access): ditto
	* sem_util.ads, sem_util.adb: (Is_Aliased_View): Handle
	No_Implicit_Aliasing restriction.
	* gnat_rm.texi: Add documentation for No_Implicit_Aliasing

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]