This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C] Fix PR37985
On Mon, 16 Jan 2012, Richard Guenther wrote:
> On Mon, 16 Jan 2012, Richard Guenther wrote:
>
> > On Fri, 13 Jan 2012, Joseph S. Myers wrote:
> >
> > > On Fri, 13 Jan 2012, Richard Guenther wrote:
> > >
> > > > This fixes PR37985 where since
> > > > http://gcc.gnu.org/ml/gcc-patches/2006-08/msg01041.html we
> > > > mark conversions produced by convert_to_integer with TREE_NO_WARNING.
> > > > This may shadow "real" stmts with no effects, thus we should
> > > > simply strip them again before checking for TREE_SIDE_EFFECTS.
> > > >
> > > > Bootstrap & regtest pending on x86_64-unknown-linux-gnu.
> > > >
> > > > Ok if that passes?
> > >
> > > OK.
> >
> > It FAILs gcc.dg/20040202-1.c (we warn about a folded memcpy). It
> > looks like wrapping things in TREE_NO_WARNING NOP_EXPRs is
> > fragile as soon as you consider multiple warning kinds (thus, of
> > course the patch causing this regression is at fault).
> >
> > OTOH for the regression warning on folded stmts I really wonder
> > why c_process_expr_stmt folds at all before emitting warnings - why
> > intentionally divert from the source AST here? I'm testing
> > the following before giving up on this regression (which solves
> > the gcc.dg/20040202-1.c FAIL at least).
>
> Which works besides now FAILing gcc.dg/strncpy-fix-1.c. We get
> a "value computed is not used" warning because we are still folding
> the strncpy to a memcpy because we fold all builtin calls at the very
> point they are created (build_function_call_vec):
>
> if (name != NULL_TREE
> && !strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10))
> {
> if (require_constant_value)
> result =
> fold_build_call_array_initializer_loc (loc, TREE_TYPE (fntype),
> function, nargs,
> argarray);
> else
> result = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
> function, nargs, argarray);
>
> "Fixed" by not doing that if !require_constant_value. We'll fold
> it during the c_fully_fold call anyway (and during gimplification again).
>
> Re-testing as follows.
Which does not work either - we seem to rely on that early folding
at least for the type-generic math stuff (gcc.dg/c99-tgmath-*.c).
I'm dropping all these patches. There doesn't seem to be a good
way to make everything well-behaved with the patch causing the
regression installed.
Richard.