Jakub Jelinek <ja...@redhat.com> wrote: >On Fri, Jan 04, 2013 at 02:21:43PM +0100, Richard Biener wrote: >> The other way would be >> >> Index: gcc/fold-const.c >> =================================================================== >> --- gcc/fold-const.c (revision 194900) >> +++ gcc/fold-const.c (working copy) >> @@ -900,9 +900,9 @@ associate_trees (location_t loc, tree t1 >> static bool >> int_binop_types_match_p (enum tree_code code, const_tree type1, >> const_tree type2) >> { >> - if (TREE_CODE (type1) != INTEGER_TYPE && !POINTER_TYPE_P (type1)) >> + if (!INTEGRAL_TYPE_P (type1) && !POINTER_TYPE_P (type1)) >> return false; >> - if (TREE_CODE (type2) != INTEGER_TYPE && !POINTER_TYPE_P (type2)) >> + if (!INTEGRAL_TYPE_P (type2) && !POINTER_TYPE_P (type2)) >> return false; >> >> switch (code) > >Ok, as discussed on IRC, here is your version, ok for trunk? >Bootstrapped/regtested on x86_64-linux and i686-linux.
Ok. Thanks, Richard. >2013-01-06 Jakub Jelinek <ja...@redhat.com> > Richard Biener <rguent...@suse.de> > > PR middle-end/55851 > * fold-const.c (int_binop_types_match_p): Allow all INTEGRAL_TYPE_P > types instead of just INTEGER_TYPE types. > > * gcc.c-torture/compile/pr55851.c: New test. > >--- gcc/fold-const.c (revision 194900) >+++ gcc/fold-const.c (working copy) >@@ -900,9 +900,9 @@ associate_trees (location_t loc, tree t1 > static bool >int_binop_types_match_p (enum tree_code code, const_tree type1, >const_tree type2) > { >- if (TREE_CODE (type1) != INTEGER_TYPE && !POINTER_TYPE_P (type1)) >+ if (!INTEGRAL_TYPE_P (type1) && !POINTER_TYPE_P (type1)) > return false; >- if (TREE_CODE (type2) != INTEGER_TYPE && !POINTER_TYPE_P (type2)) >+ if (!INTEGRAL_TYPE_P (type2) && !POINTER_TYPE_P (type2)) > return false; > > switch (code) >--- gcc/testsuite/gcc.c-torture/compile/pr55851.c.jj 2013-01-03 >16:20:19.085284806 +0100 >+++ gcc/testsuite/gcc.c-torture/compile/pr55851.c 2013-01-03 >16:19:27.698571718 +0100 >@@ -0,0 +1,12 @@ >+/* PR middle-end/55851 */ >+ >+enum { A = 1UL, B = -1UL } var = A; >+void foo (char *); >+ >+void >+test (void) >+{ >+ char vla[1][var]; >+ vla[0][0] = 1; >+ foo (&vla[0][0]); >+} > > Jakub