llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) <details> <summary>Changes</summary> Fixes #<!-- -->123524 --- Full diff: https://github.com/llvm/llvm-project/pull/123667.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1-1) - (modified) clang/lib/Parse/ParseExprCXX.cpp (+6) - (added) clang/test/SemaCXX/constexpr-if.cpp (+10) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f6d5c346021d60..cd16ce13a4e6b6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -963,7 +963,7 @@ Bug Fixes to C++ Support - Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type constraints are applied. (#GH122134) - Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033) - +- Clang now permits the use of immediate-escalating expressions in ``constexpr`` if conditions. (#GH123524) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 33a90e0cb8a42a..e174d9a24e7440 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -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()) diff --git a/clang/test/SemaCXX/constexpr-if.cpp b/clang/test/SemaCXX/constexpr-if.cpp new file mode 100644 index 00000000000000..1832086fee42d4 --- /dev/null +++ b/clang/test/SemaCXX/constexpr-if.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++26 -verify %s + +// expected-no-diagnostics + +namespace GH123524 { +consteval void fn1() {} +void fn2() { + if constexpr (&fn1 != nullptr) { } +} +} `````````` </details> https://github.com/llvm/llvm-project/pull/123667 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits