[patch] Don't change the types for switch statements

Jeffrey A Law law@redhat.com
Thu Mar 10 15:01:00 GMT 2005


On Thu, 2005-03-10 at 00:50 -0500, James A. Morrison wrote:
> > > 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.
> 
>  I take that back.  The n->{low,high} are assigned index_type in add_case_node.
OK.  I was just hunting for code which set the type of the nodes, you
saved me the trouble of finding it :-)   So we know that INDEX_TYPE will
have the same type as each of the nodes.  Excellent.

> It would probably be good to use minval = fold_convert (index_type, i_z_n) at
> line 2427 as I did in the patch at line 2512, but that'll have to wait for
> another round of testing.
Agreed.  I've got time today, so I'll give that a spin.

Jeff



More information about the Gcc-patches mailing list