================
@@ -7589,32 +7706,45 @@ Sema::BuildCompoundLiteralExpr(SourceLocation
LParenLoc, TypeSourceInfo *TInfo,
return ExprError();
}
} else if (!literalType->isDependentType() &&
- RequireCompleteType(LParenLoc, literalType,
- diag::err_typecheck_decl_incomplete_type,
- SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
+ RequireCompleteType(
+ LParenLoc, literalType,
+ diag::err_typecheck_decl_incomplete_type,
+ SourceRange(LParenLoc,
+ LiteralExpr->getSourceRange().getEnd())))
return ExprError();
- InitializedEntity Entity
- = InitializedEntity::InitializeCompoundLiteralInit(TInfo);
- InitializationKind Kind
- = InitializationKind::CreateCStyleCast(LParenLoc,
- SourceRange(LParenLoc, RParenLoc),
- /*InitList=*/true);
+ InitializedEntity Entity = InitializedEntity::InitializeCompoundLiteralInit(
+ TInfo, literalType, ConstexprKind);
+ InitializationKind Kind = InitializationKind::CreateCStyleCast(
+ LParenLoc, SourceRange(LParenLoc, RParenLoc),
+ /*InitList=*/true);
InitializationSequence InitSeq(*this, Entity, Kind, LiteralExpr);
- ExprResult Result = InitSeq.Perform(*this, Entity, Kind, LiteralExpr,
- &literalType);
+ ExprResult Result =
+ InitSeq.Perform(*this, Entity, Kind, LiteralExpr, &literalType);
if (Result.isInvalid())
return ExprError();
LiteralExpr = Result.get();
- // We treat the compound literal as being at file scope if it's not in a
- // function or method body, or within the function's prototype scope. This
- // means the following compound literal is not at file scope:
- // void func(char *para[(int [1]){ 0 }[0]);
- const Scope *S = getCurScope();
- bool IsFileScope = !CurContext->isFunctionOrMethod() &&
- !S->isInCFunctionScope() &&
- (!S || !S->isFunctionPrototypeScope());
+ if (HasConstexpr && !LiteralExpr->isTypeDependent() &&
+ !LiteralExpr->isValueDependent() && !literalType->isDependentType()) {
+ SmallVector<PartialDiagnosticAt, 4> Notes;
+ Expr::EvalResult Eval;
+ Eval.Diag = &Notes;
+ if (!LiteralExpr->EvaluateAsConstantExpr(Eval, Context) ||
+ Notes.size() > 0) {
----------------
nickdesaulniers wrote:
Right, typo, missed `!`. I think `empty` is clearer.
https://github.com/llvm/llvm-project/pull/212559
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits