This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Don't change the types for switch statements
Jeffrey A Law <law@redhat.com> writes:
> On Wed, 2005-03-09 at 23:46 -0500, James A. Morrison wrote:
> > Hi,
> >
> > This patch fixes the latent bug exposed by my fix to pr15784. index_type
> > was being unconditionally set to integer_type_node when try_casesi failed.
> > Unfortunatly, not all the tree's being used in the switch statements were
> > integer_type_nodes. This fixes the problem, by not changing index_type.
> > Not too long ago index_type was changed after try_casesi to a value stored
> > in a case specific datastructure, but that was removed last year. See
> > cvs diff -up -r1.377 -r1.378 stmt.c for more details on that change.
> >
> > I'm bootstrapping this patch on ia64-linux with the patch to pr15784 and
> > Ada. So far the bootstrap has got passed the ice in c-pragma.c or any of
> > the Ada code that triggered the problem. I'm also bootstrapping this patch
> > on sparc-linux. Ok for mainline and regtesting if bootstrap succeeds on
> > both ia64 (with pr15784 patch*) and sparc (without 15784) patch?
> Another approach is to fix the type of the MINUS_EXPR so that
> it has the same type as minval and n->{high,low}. I actually think
> that's safer since with your change we'll still be creating (and
> folding) MINUS_EXPR nodes where the type of the MINUS_EXPR does not
> match the types of both operands.
You'll have to fix the types in more than this one place. It seems to be
assumed that index_type is the same type of n->{low,high} and minval/maxval
in expand_case. However, when index_type is reassigned to integer_type_node,
this assumption is no longer true, so I think the problem is reassigning
index_type, not the call to build. Right now we create nodes that don't
match, but with my patch the type of the nodes does match.
On a similar note, there isn't any reason to use fold (build (MINUS_EXPR ..))
as int_const_binop (MINUS_EXPR ...) would do the right thing here. That
only works around the problem of index_type being the wrong type sometimes
though.
> I've actually got that change bootstrapping on my x86 and ppc
> boxes right now.
>
> Jeff
>
--
Thanks,
Jim
http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim