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 change moves the rest of the warning machinery for address clauses to Validate_Address_Clauses, ensuring that all the variants are issued from it. This affects only absolute address clauses in practice, i.e. address clauses of the form for I'Address use To_Address (16#XXXX_XXXX#) and variants thereof. This automatically brings a couple of improvements: warnings are more accurate because they take into account the final alignment set by the back-end and they catch more cases because the back-end sets the alignment of every single type and object in the program. The warning also prints the alignment value now. The following code gives an example of the warnings: pragma Unsuppress (Alignment_Check); 1. with System.Storage_Elements; use System.Storage_Elements; 2. 3. package P is 4. 5. I : Integer; 6. for I'Address use To_Address (16#7FFF_0001#); -- warning | >>> warning: specified address for "I" is inconsistent with alignment >>> warning: program execution may be erroneous (RM 13.3(27)) >>> warning: alignment of "I" is 4 7. 8. type Rec is record 9. I : Integer; 10. end record; 11. 12. R1 : Rec; 13. for R1'Address use To_Address (16#7FFF_0001#); -- warning | >>> warning: specified address for "R1" is inconsistent with alignment >>> warning: program execution may be erroneous (RM 13.3(27)) >>> warning: alignment of "R1" is 4 14. 15. C : constant System.Address := To_Address (16#7FFF_0001#); -- warning 16. 17. R2 : Rec; 18. for R2'Address use C; | >>> warning: specified address for "R2" is inconsistent with alignment >>> warning: program execution may be erroneous (RM 13.3(27)) >>> warning: alignment of "R2" is 4 19. 20. R3 : Rec; 21. for R3'Address use To_Address (16#7FFF_0004#); -- no warning 22. 23. end P; 23 lines: No errors, 9 warnings Tested on x86_64-pc-linux-gnu, committed on trunk 2016-06-22 Eric Botcazou <ebotcazou@adacore.com> * sem_util.ads (Address_Value): Declare new function. * sem_util.adb (Address_Value): New function extracted unmodified from Apply_Address_Clause_Check, which returns the underlying value of the expression of an address clause. * checks.adb (Compile_Time_Bad_Alignment): Delete. (Apply_Address_Clause_Check): Call Address_Value on the expression. Do not issue the main warning here and issue the secondary warning only when the value of the expression is not known at compile time. * sem_ch13.adb (Address_Clause_Check_Record): Add A component and adjust the description. (Analyze_Attribute_Definition_Clause): In the case of an address, move up the code creating an entry in the table of address clauses. Also create an entry for an absolute address. (Validate_Address_Clauses): Issue the warning for absolute addresses here too. Tweak condition associated with overlays for consistency.
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] |