]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Fix handling of register atomic compound literals
authorJoseph Myers <josmyers@redhat.com>
Wed, 24 Sep 2025 19:53:01 +0000 (19:53 +0000)
committerJoseph Myers <josmyers@redhat.com>
Wed, 24 Sep 2025 19:53:01 +0000 (19:53 +0000)
commitdfbce1feae0a88dd94bdba1adc5040e4a86c6219
tree21ccb48ac512b328e0caacbd840e91583ce2e145
parent33862166186fcef86e94babded780bb3745f6525
c: Fix handling of register atomic compound literals

The logic for loads and stores of _Atomic objects in the C front end
involves taking the address of such objects, with really_atomic_lvalue
detecting cases where this cannot be done (and also no special
handling is needed for atomicity), in particular register _Atomic
objects.  This logic failed to deal with the case of register _Atomic
compound literals, so resulting in spurious errors "error: address of
register compound literal requested" followed by "error: argument 1 of
'__atomic_load' must be a non-void pointer type".  (This is a C23 bug
that I found while changing really_atomic_lvalue as part of previous
C2y changes.)  Add a use of COMPOUND_LITERAL_EXPR_DECL in that case.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-typeck.cc (really_atomic_lvalue): For a COMPOUND_LITERAL_EXPR,
check C_DECL_REGISTER on the COMPOUND_LITERAL_EXPR_DECL.

gcc/testsuite/
* gcc.dg/c23-complit-9.c: New test.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c23-complit-9.c [new file with mode: 0644]