diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-10-30 13:02:11 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-10-30 13:02:11 +0100 |
commit | 4b2d2c13d81f1b243838850fe98bbc6ccdfd77f2 (patch) | |
tree | 2deafb429054f3515e7f503d8ca6d1e15cf17dc6 /gcc/ada/sem_res.adb | |
parent | 110fcc77755c84bbc3d6472928da4bdf7a330238 (diff) | |
download | gcc-4b2d2c13d81f1b243838850fe98bbc6ccdfd77f2.tar.gz |
[multiple changes]
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.
2009-10-30 Ed Schonberg <schonberg@adacore.com>
* usage.adb: Add -gnatw.i switch.
2009-10-30 Vincent Celier <celier@adacore.com>
* xsnamest.adb: Update comments with regards to the template files
snames.*.tmpl
From-SVN: r153741
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 75e98c08bc4..96a295cd218 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8254,8 +8254,8 @@ package body Sem_Res is ----------------------------- procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id) is - Conv_OK : constant Boolean := Conversion_OK (N); - Operand : constant Node_Id := Expression (N); + Conv_OK : constant Boolean := Conversion_OK (N); + Operand : constant Node_Id := Expression (N); Operand_Typ : constant Entity_Id := Etype (Operand); Target_Typ : constant Entity_Id := Etype (N); Rop : Node_Id; @@ -8400,9 +8400,25 @@ package body Sem_Res is (Ekind (Entity (Orig_N)) = E_Loop_Parameter and then Covers (Orig_T, Etype (Entity (Orig_N))))) then - Error_Msg_Node_2 := Orig_T; - Error_Msg_NE -- CODEFIX - ("?redundant conversion, & is of type &!", N, Entity (Orig_N)); + -- One more check, do not give warning if the analyzed conversion + -- has an expression with non-static bounds, and the bounds of the + -- target are static. This avoids junk warnings in cases where the + -- conversion is necessary to establish staticness, for example in + -- a case statement. + + if not Is_OK_Static_Subtype (Operand_Typ) + and then Is_OK_Static_Subtype (Target_Typ) + then + null; + + -- Here we give the redundant conversion warning + + else + Error_Msg_Node_2 := Orig_T; + Error_Msg_NE -- CODEFIX + ("?redundant conversion, & is of type &!", + N, Entity (Orig_N)); + end if; end if; end if; |