Here, missing TREE_NO_WARNING on an artificial variable caused bogus
-Wunused-value warning.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-12-15  Marek Polacek  <pola...@redhat.com>

        PR c/68907
        * c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an
        artificial decl.

        * gcc.dg/pr68907.c: New test.

diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index b691072..9d6c604 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -3814,6 +3814,7 @@ build_atomic_assign (location_t loc, tree lhs, enum 
tree_code modifycode,
   newval = create_tmp_var_raw (nonatomic_lhs_type);
   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, 0);
   TREE_ADDRESSABLE (newval) = 1;
+  TREE_NO_WARNING (newval) = 1;
 
   loop_decl = create_artificial_label (loc);
   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
diff --git gcc/testsuite/gcc.dg/pr68907.c gcc/testsuite/gcc.dg/pr68907.c
index e69de29..de1c237 100644
--- gcc/testsuite/gcc.dg/pr68907.c
+++ gcc/testsuite/gcc.dg/pr68907.c
@@ -0,0 +1,14 @@
+/* PR c/60195 */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -Wpedantic -Wall" } */
+
+_Atomic int a;
+
+void
+fn (void)
+{
+  ++a;
+  a++;
+  --a;
+  a--;
+}

        Marek

Reply via email to