Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ Bug Fixes to C++ Support
- Fix immediate escalation not propagating through inherited constructors. (#GH112677)
- Fixed assertions or false compiler diagnostics in the case of C++ modules for
lambda functions or inline friend functions defined inside templates (#GH122493).
- Clang now permits the use of immediate-escalating expressions in ``constexpr`` if conditions. (#GH123524)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,12 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc,
return ParseCXXCondition(nullptr, Loc, CK, MissingOK);
}

EnterExpressionEvaluationContext Eval(
Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
/*LambdaContextDecl=*/nullptr,
/*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
/*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);

// Parse the expression.
ExprResult Expr = ParseExpression(); // expression
if (Expr.isInvalid())
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaCXX/constexpr-if.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_cc1 -std=c++20 -verify=cxx20,expected %s
// RUN: %clang_cc1 -std=c++23 -verify=cxx23,expected %s
// RUN: %clang_cc1 -std=c++26 -verify=cxx26,expected %s

// expected-no-diagnostics

namespace GH123524 {
consteval void fn1() {}
void fn2() {
if constexpr (&fn1 != nullptr) { }
}
}
Loading