[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 25 12:06:41 PDT 2025


================
@@ -4522,6 +4523,38 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
 
         BaseVal = MTE->getOrCreateValue(false);
         assert(BaseVal && "got reference to unevaluated temporary");
+      } else if (const CompoundLiteralExpr *CLE =
+                     dyn_cast_or_null<CompoundLiteralExpr>(Base)) {
+        // In C99, a CompoundLiteralExpr is an lvalue, and we defer evaluating
+        // the initializer until now for such expressions. Such an expression
+        // can't be an ICE in C, so this only matters for fold.
+        if (LValType.isVolatileQualified()) {
----------------
efriedma-quic wrote:

Checking for volatile is redundant, I think?  I see there's earlier code in this function which checks for volatile.

https://github.com/llvm/llvm-project/pull/137163


More information about the cfe-commits mailing list