serge-sans-paille added a comment. Alternatively, the following also works, but it splits the logic into anotherplace, while current patch is at least consistent with existing state
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 498f0d4..233307f 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3352,6 +3352,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, NoteLValueLocation(Info, Base); } + // In the particular case of CompoundLiteralExpr initialization, check that it is itself + // constant. + if (Info.InConstantContext) + if (const CompoundLiteralExpr *CLE = dyn_cast_or_null<CompoundLiteralExpr>( + VD->getAnyInitializer()->IgnoreCasts())) { + QualType CLET = CLE->getType().getCanonicalType(); + if (!CLET.isConstant(Info.Ctx)) { + Info.FFDiag(E); + } + } + Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124038/new/ https://reviews.llvm.org/D124038 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits