-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang] Correctly handle allocations in the condition of a if constexpr
#146890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1931,15 +1931,13 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc, | |
| return ParseCXXCondition(nullptr, Loc, CK, MissingOK); | ||
| } | ||
|
|
||
| ExprResult Expr = [&] { | ||
| EnterExpressionEvaluationContext Eval( | ||
| Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated, | ||
| /*LambdaContextDecl=*/nullptr, | ||
| /*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other, | ||
| /*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf); | ||
| // Parse the expression. | ||
| return ParseExpression(); // expression | ||
| }(); | ||
| EnterExpressionEvaluationContext Eval( | ||
| Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated, | ||
| /*LambdaContextDecl=*/nullptr, | ||
| /*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other, | ||
| /*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to make an equivalent change to TreeTransform? I came up with the following testcase:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, thanks for thinking about that |
||
|
|
||
| ExprResult Expr = ParseExpression(); | ||
|
|
||
| if (Expr.isInvalid()) | ||
| return Sema::ConditionError(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20628,6 +20628,7 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc, | |||||
| break; | ||||||
|
|
||||||
| case ConditionKind::ConstexprIf: | ||||||
| // Note: this might produce a FullExpr | ||||||
| Cond = CheckBooleanCondition(Loc, SubExpr, true); | ||||||
| break; | ||||||
|
|
||||||
|
|
@@ -20640,13 +20641,13 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc, | |||||
| {SubExpr}, PreferredConditionType(CK)); | ||||||
| if (!Cond.get()) | ||||||
| return ConditionError(); | ||||||
| } | ||||||
| // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead. | ||||||
| FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc); | ||||||
| if (!FullExpr.get()) | ||||||
| } else if (Cond.isUsable() && !isa<FullExpr>(Cond.get())) | ||||||
| Cond = ActOnFinishFullExpr(Cond.get(), Loc, /*DiscardedValue*/ false); | ||||||
|
|
||||||
| if (Cond.isInvalid()) | ||||||
|
||||||
| if (Cond.isInvalid()) | |
| if (!Cond.isUsable()) |
Unless there is a reason that ConditionResult would be ok with a 'null' expr?
Uh oh!
There was an error while loading. Please reload this page.