This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Prevent -Wunused-value warning with __atomic_fetch_* (PR c/69407)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Fri, 4 Mar 2016 19:19:56 +0100
- Subject: Re: [C PATCH] Prevent -Wunused-value warning with __atomic_fetch_* (PR c/69407)
- Authentication-results: sourceware.org; auth=none
- References: <20160304173040 dot GM10006 at redhat dot com> <20160304174126 dot GG3017 at tucnak dot redhat dot com> <20160304180309 dot GN10006 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Mar 04, 2016 at 07:03:09PM +0100, Marek Polacek wrote:
> Ok, version with dg-bogus:
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2016-03-04 Marek Polacek <polacek@redhat.com>
>
> PR c/69407
> * c-common.c (resolve_overloaded_builtin): Set TREE_USED for the fetch
> operations.
>
> * gcc.dg/atomic-op-6.c: New test.
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index 965cf49..25afa9c 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -11443,6 +11443,10 @@ resolve_overloaded_builtin (location_t loc, tree function,
> && orig_code != BUILT_IN_ATOMIC_STORE_N)
> result = sync_resolve_return (first_param, result, orig_format);
>
> + if (fetch_op)
> + /* Prevent -Wunused-value warning. */
> + TREE_USED (result) = true;
> +
Can't sync_resolve_return return error_mark_node?
If it could, perhaps it would be saver to move this a few lines above the
sync_resolve_return call, where we've already checked that result is not
error_mark_node.
Otherwise LGTM.
Jakub