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] Handle some warning situations with Address aspect


The Address attribute definition clause processing warns when overlaying
a small object with a large one, and also avoids giving a warning about
the entity not being referenced. This patch applies the same processing
to corresponding uses of the Address aspect. The following test program
shows the expected warnings being the same for the address aspect and
the address definition clause:

     1. function addrAP return Integer is
     2.    X : Integer := 123;
     3.    Y : Integer with Address => X'Address;
     4.    Z : Integer;
     5.    for Z'Address use X'Address;
     6.    P : Integer := 123;
     7.    Q : Long_Long_Integer;
     8.    for Q'Address use P'Address;
           |
        >>> warning: "Q" overlays smaller object
        >>> warning: program execution may be erroneous
        >>> warning: size of "Q" is 64
        >>> warning: size of "P" is 32

     9.    R : Long_Long_Integer with Address => P'Address;
                                      |
        >>> warning: "R" overlays smaller object
        >>> warning: program execution may be erroneous
        >>> warning: size of "R" is 64
        >>> warning: size of "P" is 32

    10. begin
    11.    return Y + Z;
    12. end addrAP;

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

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

	* sem_ch13.adb (Analyze_Aspect_Specifications): For Address
	attribute, consider it to be set in source, because of aliasing
	considerations.
	(Analyze_Attribute_Definition_Clause): For the
	purpose of warning on overlays, take into account the aspect case.

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]