[clang] [clang] Compound Literal Statement Constant Expression Assertion Fix (PR #139479)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Mon May 12 01:41:32 PDT 2025


================
@@ -7220,6 +7220,17 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
     if (auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
       for (unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
         Expr *Init = ILE->getInit(i);
+        // 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 (!Init->isTypeDependent() && !Init->isValueDependent() &&
+            !Init->getType()->isDependentType())
----------------
Fznamznon wrote:

There is a `if (IsFileScope)` 4 lines above.

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


More information about the cfe-commits mailing list