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 extended version of -gnatR for record sub-components


This adds a -gnatRe variant to the -gnatR switch, which displays extended
representation information for components of records that are themselves
records by recursing on the layout of sub-components.

This also makes the compiler accept -gnatR0, as documented in the User Guide.

For the following package:

pragma No_Component_Reordering;

package P is

  type Int7 is mod 2 ** 7;
  for Int7'Size use 7;

  type Rec1 is record
    I1 : Integer;
    I2 : Int7;
    B1 : Boolean;
    B2 : Boolean;
  end record;
  pragma Pack (Rec1);

  type Rec2 is record
    B  : Boolean;
    C  : Character;
    R1 : Rec1;
    I  : Integer;
  end record;
  pragma Pack (Rec2);

  type Rec3 is record
    B1 : Boolean;
    B2 : Boolean;
    R2 : Rec2;
    C  : Character;
  end record;
  pragma Pack (Rec3);

end P;

the compiler must give the following information with -gnatRe:

Representation information for unit P (spec)

for Rec1'Object_Size use 48;
for Rec1'Value_Size use 41;
for Rec1'Alignment use 1;
for Rec1 use record
   I1 at 0 range  0 .. 31;
   I2 at 4 range  0 ..  6;
   B1 at 4 range  7 ..  7;
   B2 at 5 range  0 ..  0;
end record;

for Rec2'Object_Size use 88;
for Rec2'Value_Size use 82;
for Rec2'Alignment use 1;
for Rec2 use record
   B     at 0 range  0 ..  0;
   C     at 0 range  1 ..  8;
   R1.I1 at 1 range  1 .. 32;
   R1.I2 at 5 range  1 ..  7;
   R1.B1 at 6 range  0 ..  0;
   R1.B2 at 6 range  1 ..  1;
   I     at 6 range  2 .. 33;
end record;

for Rec3'Object_Size use 96;
for Rec3'Value_Size use 92;
for Rec3'Alignment use 1;
for Rec3 use record
   B1       at  0 range  0 ..  0;
   B2       at  0 range  1 ..  1;
   R2.B     at  0 range  2 ..  2;
   R2.C     at  0 range  3 .. 10;
   R2.R1.I1 at  1 range  3 .. 34;
   R2.R1.I2 at  5 range  3 ..  9;
   R2.R1.B1 at  6 range  2 ..  2;
   R2.R1.B2 at  6 range  3 ..  3;
   R2.I     at  6 range  4 .. 35;
   C        at 10 range  4 .. 11;
end record;

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

2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>

	* debug.adb (dA): Adjust comment.
	* gnat1drv.adb (Gnat1drv): Likewise.
	* opt.ads (List_Representation_Info_Extended): New variable.
	* repinfo.adb (List_Record_Info): Split implementation into...
	(Compute_Max_Length): ...this.	Recurse on records if requested.
	(List_Record_Layout): Likewise.
	* switch-c.adb (Scan_Front_End_Switches) <'R'>: Use case
	statement, accept '0' and set List_Representation_Info_Extended
	on 'e'.
	* usage.adb (Usage): Document new -gnatRe variant.

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]