Bug 68907

Summary: bogus warning: right-hand operand of comma expression has no effect on an atomic_int preincrement
Product: gcc Reporter: Martin Sebor <msebor>
Component: cAssignee: Marek Polacek <mpolacek>
Status: RESOLVED FIXED    
Severity: normal CC: mpolacek
Priority: P3    
Version: 6.0   
Target Milestone: 5.4   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2015-12-15 00:00:00

Description Martin Sebor 2015-12-15 03:39:20 UTC
GCC 5.1.0 and current trunk issue the following incorrect warning on the preincrement of an _Atomic variable.

$ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra -o/dev/null ~/tmp/t.c
$ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra -o/dev/null ~/tmp/t.c
typedef _Atomic int AI;

extern AI ai;

void increment (void)
{
    ++ai;
}
/home/remote/msebor/tmp/t.c: In function ‘increment’:
/home/remote/msebor/tmp/t.c:7:5: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     ++ai;
     ^~~~
Comment 1 Marek Polacek 2015-12-15 07:42:54 UTC
I thought I had fixed something similar some time ago...
Comment 2 Marek Polacek 2015-12-15 07:46:42 UTC
GCC 4.9 warns too.
Comment 3 Marek Polacek 2015-12-15 15:14:21 UTC
Author: mpolacek
Date: Tue Dec 15 15:13:49 2015
New Revision: 231656

URL: https://gcc.gnu.org/viewcvs?rev=231656&root=gcc&view=rev
Log:
	PR c/68907
	* c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an
	artificial decl.

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

Added:
    trunk/gcc/testsuite/gcc.dg/pr68907.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Marek Polacek 2015-12-15 15:14:38 UTC
Fixed.