From 2994fb91b7df8f8a0c0f83024c240f25f78f25a0 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 15 Dec 2015 15:13:49 +0000 Subject: [PATCH] re PR c/68907 (bogus warning: right-hand operand of comma expression has no effect on an atomic_int preincrement) PR c/68907 * c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an artificial decl. * gcc.dg/pr68907.c: New test. From-SVN: r231656 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-typeck.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr68907.c | 14 ++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr68907.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2ba94646e64..e61a2edd2b3 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-12-15 Marek Polacek + + PR c/68907 + * c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an + artificial decl. + 2015-12-08 David Malcolm * c-parser.c (c_parser_alignof_expression): Capture location of diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index b691072caa9..9d6c604ed90 100644 --- a/gcc/c/c-typeck.c +++ b/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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 633f8b2afe5..17c1b661e19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-15 Marek Polacek + + PR c/68907 + * gcc.dg/pr68907.c: New test. + 2015-12-15 Alessandro Fanfarillo * gfortran.dg/coarray_critical_1.f90: New. diff --git a/gcc/testsuite/gcc.dg/pr68907.c b/gcc/testsuite/gcc.dg/pr68907.c new file mode 100644 index 00000000000..de1c237b826 --- /dev/null +++ b/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--; +} -- 2.30.2