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.
return false;
expr = TREE_OPERAND (expr, 0);
}
+ if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
+ expr = COMPOUND_LITERAL_EXPR_DECL (expr);
if (DECL_P (expr) && C_DECL_REGISTER (expr))
return false;
return true;
--- /dev/null
+/* Test register _Atomic compound literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+
+void
+f ()
+{
+ (register _Atomic int) { 1 };
+}