[clang] [Clang] support storage-class specifiers in C23 compound literals (PR #212559)
Oleksandr Tarasiuk via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 03:26:15 PDT 2026
================
@@ -789,9 +789,10 @@ void AggExprEmitter::VisitOpaqueValueExpr(OpaqueValueExpr *e) {
}
void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
- if (Dest.isPotentiallyAliased()) {
- // Just emit a load of the lvalue + a copy, because our compound literal
- // might alias the destination.
+ if (E->hasGlobalStorage() || E->getType()->isAtomicType() ||
+ (E->getStorageClass() == SC_Register &&
+ E->getType().isVolatileQualified()) ||
----------------
a-tarasyuk wrote:
I revised the condition to:
```cpp
Dest.isPotentiallyAliased() || E->hasGlobalStorage() ||
Ty->isAtomicType() || Ty.isVolatileQualified()
```
I don’t think there is a single spec paragraph that lists these conditions 😄. My reading of `6.5.3.6` `p5`, `p7`, and `p8` is
`6.5.3.6` `p5` and `p7` require a `static`/`thread` compound literal to use its unnamed object., emitting the initializer directly into Dest would bypass that object.
`6.5.3.6` `p8` makes the expression an `lvalue`, and together with `6.3.2.1`, it appears to imply that obtaining the value of an `atomic` or `volatile` aggregate literal should preserve the access semantics, which directly initializing `Dest` would bypass - or am I mistaken here?
https://github.com/llvm/llvm-project/pull/212559
More information about the cfe-commits
mailing list