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] |
In some circumstances it is necessary to use a conversion which at first glance has the same source type and destination type, and therefore looks redundant. But in fact the expression's type has non-static bounds because of technical rules as to what is or is not static. So the conversion is not after all redundant. This patch avoids the false positive warning in this case. The following example shows the case in question: Compiling: badconversionwarn.adb 1. procedure badconversionwarn is 2. type INTRA_CHECK_T is RANGE 1..11; 3. 4. subtype TT is INTRA_CHECK_T range 1 .. 1; 5. type INTRA_CHECK_TO_DO_T is array (TT) of BOOLEAN; 6. 7. type R is record 8. X : INTRA_CHECK_TO_DO_T; 9. end record; 10. 11. A : constant R := R'(X => (1 => False)); 12. begin 13. for I in A.X'range loop 14. case TT (I) is 15. when 1 => null; 16. end case; 17. 18. case I is 1 3 >>> missing case values: -128 .. 0 >>> missing case values: 2 .. 127 >>> bounds of "I" are not static, alternatives must cover base type 19. when 1 => null; 20. end case; 21. 22. case TT'(I) is 23. when 1 => null; 24. end case; 25. end loop; 26. end; This is compiled with -gnatwa -gnatld7 -gnatj60. Before the patch, the apparently redundant conversion on line 14 was flagged with a warning. But as line 18 shows, this conversion si not redundant. Tested on x86_64-pc-linux-gnu, committed on trunk 2009-10-30 Robert Dewar <dewar@adacore.com> * sem_res.adb (Resolve_Type_Conversion): Avoid false positive when converting non-static subtype to "identical" static subtype.
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] |