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] |
Previously, the check for record component overlap was done at the time of analyzing the record representation clause. But that's too early since non-standard bit order affects the results. This patch defers overlap checking till freeze time. The following test program shows an overlap which was not previously detected: 1. pragma Ada_05; 2. with System; use System; 3. package NS_Bit_Order_Overlap is 4. type Rec is record 5. I1, I2, I3, I4: Integer range 0 .. 2**15 - 1; 6. end record; 7. 8. for Rec use record -- LOF HOF ~ LOF 9. I1 at 0 range 0 .. 15; -- 0 0 15 6 0 15 ~ 48 .. 63 | >>> info: reverse bit order in machine scalar of length 64 >>> info: little-endian range for component "I1" is 48 .. 63 10. I2 at 0 range 16 .. 31; -- 2 0 15 4 0 15 ~ 32 .. 47 | >>> info: reverse bit order in machine scalar of length 64 >>> info: little-endian range for component "I2" is 32 .. 47 11. I3 at 0 range 32 .. 47; -- 4 0 15 2 0 15 ~ 16 .. 31 | >>> info: reverse bit order in machine scalar of length 64 >>> info: little-endian range for component "I3" is 16 .. 31 12. I4 at 4 range 16 .. 31; -- 6 0 15 4 0 15 ~ 0 .. 15 1 2 >>> component "I4" overlaps "I2" at line 10 >>> info: reverse bit order in machine scalar of length 32 >>> info: little-endian range for component "I4" is 0 .. 15 13. end record; 14. for Rec'Bit_Order use 15. Bit_Order'Val (1 - Bit_Order'Pos (Default_Bit_Order)); 16. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Robert Dewar <dewar@adacore.com> * einfo.ads, einfo.adb (Get_Record_Representation_Clause): New function. * freeze.adb (Freeze_Record_Type): Add call to Check_Record_Representation_Clause. * sem_ch13.adb (Check_Record_Representation_Clause): New function (Analyze_Record_Representation_Clause): Split out overlap code into this new function. (Check_Component_Overlap): Moved inside Check_Record_Representation_Clause. * sem_ch13.ads (Check_Record_Representation_Clause): New function.
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] |