[clang] [clang] Compound Literal Statement Constant Expression Assertion Fix (PR #139479)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed May 14 05:12:24 PDT 2025
================
@@ -7241,10 +7241,21 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
? VK_PRValue
: VK_LValue;
+ // C99 6.5.2.5
+ // "If the compound literal occurs outside the body of a function, the
+ // initializer list shall consist of constant expressions."
if (IsFileScope)
if (auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
for (unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
Expr *Init = ILE->getInit(i);
+ if (!Init->isTypeDependent() && !Init->isValueDependent() &&
+ !Init->getType()->isDependentType())
----------------
AaronBallman wrote:
I don't think you need the check for `!Init->getType()->isDependentType()` because `computeDependence()` on the expression should already account for that, shouldn't it?
https://github.com/llvm/llvm-project/pull/139479
More information about the cfe-commits
mailing list