This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] Prevent -Wunused-value warning with __atomic_fetch_* (PR c/69407)


On Fri, Mar 04, 2016 at 06:30:40PM +0100, Marek Polacek wrote:
> This is not a regression but I thought I'd post this anyway.  Martin reported
> that we generate -Wunused-value warnings on the attached testcase, which
> arguable doesn't make sense.  Setting TREE_USED suppresses the warning.  Since
> we already compute 'fetch_op' I used that.  (This warning doesn't trigger e.g.
> for __atomic_load/store/compare.)
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk or gcc7?

I'm ok with it for gcc6.

> diff --git gcc/testsuite/gcc.dg/atomic-op-6.c gcc/testsuite/gcc.dg/atomic-op-6.c
> index e69de29..c8d93a4 100644
> --- gcc/testsuite/gcc.dg/atomic-op-6.c
> +++ gcc/testsuite/gcc.dg/atomic-op-6.c
> @@ -0,0 +1,11 @@
> +/* Test we don't generate bogus warnings.  */
> +/* PR c/69407 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wall -Wextra" } */
> +
> +void
> +foo (int *p, int a)
> +{
> +  __atomic_fetch_add (&p, a, 0);
> +  __atomic_add_fetch (&p, a, 0);
> +}

But IMHO you should add dg-bogus directives here.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]