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] Ignore Optimize_Alignment (Space) for packed variable length record


Normally pragma Optimize_Alignment (Space) forces an alignment of 1
for any packed record, but we can't do that for a variable length
record, since we can't implement that case, so ignore the pragma
in this case with a warning.

The following test program shows the patch in action:

     1. pragma optimize_alignment (space);
     2. procedure testalign is
     3.    subtype Continuous_Values is float;
     4.    type Continuous_Values_Map is
     5.      array ( integer range <> ) of Continuous_Values;
     6.
     7.    type my_record (s : integer) is record
                |
        >>> Optimize_Alignment has no effect for "my_record"
        >>> pragma is ignored for variable length record

     8.       x : continuous_values_map (1 .. s);
     9.    end record;
    10.    pragma pack (my_record);
    11.
    12.    type my_record2 (s : integer) is record
    13.       x : continuous_values_map (1 .. 1000);
    14.    end record;
    15.    pragma pack (my_record2);
    16.
    17. begin
    18.     null;
    19. end;

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

2012-10-29  Robert Dewar  <dewar@adacore.com>

	* layout.adb (Set_Composite_Alignment): Ignore pragma
	Optimize_Alignment (Space) for packed variable length records.

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]