Patch for `switch' warning (would like a review)
Geoff Keating
geoffk@geoffk.org
Thu Jan 16 23:20:00 GMT 2003
"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
> Here's one I don't feel is 100% obvious. I get one of those "long in
> switch not converted to int" warnings in this code.
>
> If we assume the host platforms is always 32-bit int, then the cast is
> okay. But I wasn't sure we could make that assumption.
We can assume that 'int' is at least 32 bits, but I believe that means
that this code would fail if any mode contains 32 or more bytes, which
I don't think is unlikely in the future, so it would be better to
convert it to if-else statements.
> If not then I could convert it to a series of if-else statements.
>
> Tested on sparc-solaris2.7, no regressions. Ok to install?
>
> Thanks,
> --Kaveh
>
>
> 2003-01-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
>
> * ra-build.c (undef_to_size_word): Avoid `switch' warning.
>
> diff -rup orig/egcc-CVS20030114/gcc/ra-build.c egcc-CVS20030114/gcc/ra-build.c
> --- orig/egcc-CVS20030114/gcc/ra-build.c 2003-01-13 23:04:51.000000000 -0500
> +++ egcc-CVS20030114/gcc/ra-build.c 2003-01-15 20:12:20.582578000 -0500
> @@ -398,7 +398,7 @@ undef_to_size_word (reg, undefined)
> }
>
> /* Otherwise we handle certain cases directly. */
> - switch (*undefined)
> + switch ((int) *undefined)
> {
> case 0x00f0 : *undefined = 0; return BL_TO_WORD (4, 4);
> case 0x00ff : *undefined = 0; return BL_TO_WORD (0, 8);
>
--
- Geoffrey Keating <geoffk@geoffk.org>
More information about the Gcc-patches
mailing list