re PR c/69407 (-Wunused-value on __atomic_fetch_OP and __atomic_OP_fetch)

PR c/69407
	* c-common.c (resolve_overloaded_builtin): Set TREE_USED for the fetch
	operations.

	* gcc.dg/atomic-op-6.c: New test.

From-SVN: r234304
This commit is contained in:
Marek Polacek 2016-03-17 18:43:08 +00:00 committed by Marek Polacek
parent ded6091379
commit 14ba7b28a8
4 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2016-03-17 Marek Polacek <polacek@redhat.com>
PR c/69407
* c-common.c (resolve_overloaded_builtin): Set TREE_USED for the fetch
operations.
2016-03-14 Jason Merrill <jason@redhat.com>
* c-cppbuiltin.c (c_cpp_builtins): Set __cpp_hex_float.

View File

@ -11445,6 +11445,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;
/* If new_return is set, assign function to that expr and cast the
result to void since the generic interface returned void. */
if (new_return)

View File

@ -1,3 +1,8 @@
2016-03-17 Marek Polacek <polacek@redhat.com>
PR c/69407
* gcc.dg/atomic-op-6.c: New test.
2016-03-17 David Malcolm <dmalcolm@redhat.com>
PR c/70264

View File

@ -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); /* { dg-bogus "value computed is not used" } */
__atomic_add_fetch (&p, a, 0); /* { dg-bogus "value computed is not used" } */
}