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] Allow full range of static address values for To_Address


This patch allows the use of static expressions, including most
importantly literals that accomodate the full range of positive
values for the Address, up to 2**a-1, where a is the size of
address values (most typically 32 or 64).

The following is compiled on a 32-bit machine:

     1. with System; use System;
     2. package BadAddr is
     3.    Bar : Integer;
     4.    for Bar'Address use   -- OK on 64 bits, ERROR on 32 bits
     5.      System'To_Address (16#ffff_ffff_ffff_1000#);
                                |
        >>> address value out of range for "To_Address" attribute

     6.
     7.    Bar1 : Integer;
     8.    for Bar1'Address use  -- OK on 64 bits, OK on 32 bits
     9.      System'To_Address (16#FFFF_FFFF#);
    10.
    11.    Bar2 : Integer;
    12.    for Bar2'Address use  -- ERROR on 64 bits, ERROR on 32 bits
    13.      System'To_Address (16#1_0000_0000_0000_0000#);
                                |
        >>> address value out of range for "To_Address" attribute

    14.
    15.    Bar3_Addr : Integer := 22;
    16.    Bar3 : Integer;
    17.    for Bar3'Address use  -- OK on 64 bits, OK on 32 bits
    18.      System'To_Address (Bar3_Addr);
    19.
    20.    Bar4 : Integer;
    21.    for Bar4'Address use  -- OK on 64 bits, OK on 32 bits
    22.      System'To_Address (-1);
    23.
    24.    Bar5 : Integer;
    25.    for Bar5'Address use     -- OK on 64 bits, error on 32 bits
    26.      System'To_Address (-(2**32));
                                |
        >>> address value out of range for "To_Address" attribute

    27.
    28.    Bar6 : Integer;
    29.    for Bar5'Address use     -- OK on 64 bits, error on 32 bits
    30.      System'To_Address (-(2**64));
                                |
        >>> address value out of range for "To_Address" attribute

    31.
    32. end BadAddr;

On a 64-bit machine, the errors on line 5 and line 26 do not appear.

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

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

	* cstand.adb (Standard_Unsigned_64): New internal type.
	* gnat_rm.texi: Update documentation on To_Address.
	* sem_attr.adb (Analyze_Attribute, case To_Address): Fix
	problem with out of range static values given as literals or
	named numbers.
	* stand.ads (Standard_Unsigned_64): New internal type.
	* stand.adb: Minor reformatting.

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]