[middle-end PATCH] PR c/106264: Silence warnings from __builtin_modf et al.

Richard Biener richard.guenther@gmail.com
Mon Jul 18 06:33:40 GMT 2022

On Sat, Jul 16, 2022 at 2:54 PM Roger Sayle <roger@nextmovesoftware.com> wrote:
> This middle-end patch resolves PR c/106264 which is a spurious warning
> regression caused by the tree-level expansion of modf, frexp and remquo
> producing "expression has no-effect" when the built-in function's result
> is ignored.  When these built-ins were first expanded at tree-level,
> fold_builtin_n would blindly set TREE_NO_WARNING for all built-ins.
> Now that we're more discerning, we should precisely set TREE_NO_WARNING
> selectively on those COMPOUND_EXPRs that need them.
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check with no new failures.  Ok for mainline?

I think you should use

suppress_warning  (res);

I can't think of a specific OPT_Wxyz to use so the end result should
be the same.

OK with that change.


> 2022-07-16  Roger Sayle  <roger@nextmovesoftware.com>
> gcc/ChangeLog
>         PR c/106264
>         * builtins.cc (fold_builtin_frexp): Set TREE_NO_WARNING on
>         COMPOUND_EXPR to silence spurious warning if result isn't used.
>         (fold_builtin_modf): Likewise.
>         (do_mpfr_remquo): Likewise.
> gcc/testsuite/ChangeLog
>         PR c/106264
>         * gcc.dg/pr106264.c: New test case.
> Thanks in advance,
> Roger
> --

More information about the Gcc-patches mailing list