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 patch implements the new Valid_Scalars attribute (that tests all scalar parts of an object including discriminabnts and subcomponents, to ensure they are valid. All cases are handled (including multi- dimensional arrays) except for variant records which will be implemented in a separate step. The following shows warnings that are generated (compiled with -gnatc, -gnatld7 -gnatj60) 1. package ValidScalarsW is 2. type Ptr is access Integer; 3. 4. type Rec is tagged record 5. A, B : Ptr; 6. end record; 7. 8. type RecN is new Rec with record 9. X : Integer; 10. end record; 11. 12. type Arr is array (1 .. 10) of Ptr; 13. 14. V1 : Ptr; 15. V2 : Rec; 16. V3 : Rec'Class := V2; 17. V4 : Arr; 18. 19. M1 : Boolean := V1'Valid_Scalars; | >>> warning: attribute "Valid_Scalars" always True, no scalars to check 20. M2 : Boolean := V2'Valid_Scalars; | >>> warning: attribute "Valid_Scalars" always True, no scalars to check 21. M3 : Boolean := V3'Valid_Scalars; | >>> warning: attribute "Valid_Scalars" always True, no scalars to check 22. M4 : Boolean := V4'Valid_Scalars; | >>> warning: attribute "Valid_Scalars" always True, no scalars to check 23. end ValidScalarsW; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-04-02 Robert Dewar <dewar@adacore.com> * einfo.adb (First_Component_Or_Discriminant) Now applies to all types with discriminants, not just records. * exp_attr.adb (Expand_N_Attribute): Add Scalar_Values handling for arrays, scalars and non-variant records. * sem_attr.adb (Analyze_Attribute): Handle Valid_Scalars * sem_attr.ads (Valid_Scalars): Update description * sem_util.ads, sem_util.adb (No_Scalar_Parts): 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] |