Skip to content

Commit 69f16a6

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f5b378b0d6e5' from llvm.org/main into next
2 parents 0942749 + f5b378b commit 69f16a6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15687,12 +15687,14 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
1568715687
// this doesn't escape.
1568815688
MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr*>(this), true);
1568915689
APValue::LValueBase Base(&BaseMTE);
15690-
1569115690
Info.setEvaluatingDecl(Base, Result.Val);
15692-
LValue LVal;
15693-
LVal.set(Base);
1569415691

15695-
{
15692+
if (Info.EnableNewConstInterp) {
15693+
if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, this, Result.Val))
15694+
return false;
15695+
} else {
15696+
LValue LVal;
15697+
LVal.set(Base);
1569615698
// C++23 [intro.execution]/p5
1569715699
// A full-expression is [...] a constant-expression
1569815700
// So we need to make sure temporary objects are destroyed after having
@@ -15701,10 +15703,10 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
1570115703
if (!::EvaluateInPlace(Result.Val, Info, LVal, this) ||
1570215704
Result.HasSideEffects || !Scope.destroy())
1570315705
return false;
15704-
}
1570515706

15706-
if (!Info.discardCleanups())
15707-
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
15707+
if (!Info.discardCleanups())
15708+
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
15709+
}
1570815710

1570915711
if (!CheckConstantExpression(Info, getExprLoc(), getStorageType(Ctx, this),
1571015712
Result.Val, Kind))

clang/test/AST/Interp/literals.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,13 @@ namespace SizeOf {
276276
#if __cplusplus >= 202002L
277277
/// FIXME: The following code should be accepted.
278278
consteval int foo(int n) { // ref-error {{consteval function never produces a constant expression}}
279-
return sizeof(int[n]); // ref-note 3{{not valid in a constant expression}} \
280-
// expected-note {{not valid in a constant expression}}
279+
return sizeof(int[n]); // ref-note 3{{not valid in a constant expression}}
281280
}
282281
constinit int var = foo(5); // ref-error {{not a constant expression}} \
283282
// ref-note 2{{in call to}} \
284283
// ref-error {{does not have a constant initializer}} \
285284
// ref-note {{required by 'constinit' specifier}} \
286285
// expected-error {{is not a constant expression}} \
287-
// expected-note {{in call to}} \
288286
// expected-error {{does not have a constant initializer}} \
289287
// expected-note {{required by 'constinit' specifier}} \
290288

0 commit comments

Comments
 (0)