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] |
This implements a new warning (on by default, controlled by -gnatw.z/-gnatw.Z, included in -gnatwa), that warns if a record type has a specified size and alignment where the size is not a multiple of the alignment resulting in an object size greater than the specified size. The warning is suppressed if an explicit value is given for the object size. THe following test: 1. package SizeAlign is 2. type R1 is record 3. A,B,C,D,E : Integer; 4. end record; 5. for R1'Size use 5*32; 6. for R1'Alignment use 8; | >>> warning: size is not a multiple of alignment for "R1" >>> warning: size of 160 specified at line 5 >>> warning: Object_Size will be increased to 192 7. 8. type R2 is record 9. A,B,C,D,E : Integer; 10. end record; 11. for R2'Alignment use 8; 12. for R2'Size use 5*32; | >>> warning: size is not a multiple of alignment for "R2" >>> warning: alignment of 8 specified at line 11 >>> warning: Object_Size will be increased to 192 13. 14. type R3 is record 15. A,B,C,D,E : Integer; 16. end record; 17. for R3'Alignment use 8; 18. for R3'Size use 5*32; 19. for R3'Object_Size use 192; 20. end; generates the given warnings, with the -gnatR2 output of: Representation information for unit Sizealign (spec) for R1'Object_Size use 192; for R1'Value_Size use 160; for R1'Alignment use 8; for R1 use record A at 0 range 0 .. 31; B at 4 range 0 .. 31; C at 8 range 0 .. 31; D at 12 range 0 .. 31; E at 16 range 0 .. 31; end record; for R2'Object_Size use 192; for R2'Value_Size use 160; for R2'Alignment use 8; for R2 use record A at 0 range 0 .. 31; B at 4 range 0 .. 31; C at 8 range 0 .. 31; D at 12 range 0 .. 31; E at 16 range 0 .. 31; end record; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-07-16 Robert Dewar <dewar@adacore.com> * freeze.adb (Freeze_Entity): Warn on incompatible size/alignment. * gnat_ugn.texi: Document -gnatw.z and -gnatw.Z. * ug_words: VMS synonyms (WARNINGS=[NO]SIZE_ALIGN) for -gnatw.z/-gnatw.Z * usage.adb: Add lines for -gnatw.z/-gnatw.Z. * vms_data.ads: VMS synonyms (WARNINGS=[NO]SIZE_ALIGN) for -gnatw.z/-gnatw.Z * warnsw.adb: Set Warn_On_Size_Alignment appropriately. * warnsw.ads (Warn_On_Size_Alignment): New flag 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] |