On Mon, May 23, 2011 at 6:56 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > This is something I didn't notice in my testing because my ld doesn't > support plugins and thus -flto didn't act as -fwhole-file. > The bug got fixed on the trunk by changing build_int_cst, which is > too risky to backport, so this patch instead just > adjusts the single place relevant to this patch to use build_int_cst_type > instead. Although it is very likely type is always non-NULL, I haven't > proved it and I'm trying to play safe on the release branch and thus kept > build_int_cst in the case type would be NULL. The testcase doesn't use > -flto, instead if makes the vars static which results in the same thing > as -fwhole-file or -flto with linker plugin. > > Bootstrapped/regtested on the 4.6 branch on x86_64-linux and i686-linux, > ok for 4.6 and the testcase also for trunk?
Ok. Thanks, Richard. > 2011-05-23 Jakub Jelinek <ja...@redhat.com> > > PR lto/49123 > * fold-const.c (constant_boolean_node): If type is non-NULL, > use build_int_cst_type instead of build_int_cst. > > * gcc.c-torture/execute/pr49123.c: New test. > > --- gcc/fold-const.c.jj 2011-05-04 10:46:52.000000000 +0200 > +++ gcc/fold-const.c 2011-05-23 16:19:13.000000000 +0200 > @@ -5953,8 +5953,10 @@ constant_boolean_node (int value, tree t > return value ? integer_one_node : integer_zero_node; > else if (type == boolean_type_node) > return value ? boolean_true_node : boolean_false_node; > + else if (type) > + return build_int_cst_type (type, value); > else > - return build_int_cst (type, value); > + return build_int_cst (NULL_TREE, value); > } > > > --- gcc/testsuite/gcc.c-torture/execute/pr49123.c.jj 2011-05-23 > 16:15:25.000000000 +0200 > +++ gcc/testsuite/gcc.c-torture/execute/pr49123.c 2011-05-23 > 16:12:59.000000000 +0200 > @@ -0,0 +1,14 @@ > +/* PR lto/49123 */ > + > +extern void abort (void); > +static struct S { int f : 1; } s; > +static int v = -1; > + > +int > +main () > +{ > + s.f = v < 0; > + if ((unsigned int) s.f != -1U) > + abort (); > + return 0; > +} > > Jakub >