Skip to content

Commit 5427c74

Browse files
committed
[Clang] SubstituteConstraintExpressionWithoutSatisfaction needs an unevaluated context
It turns out that the substitution for expression comparing also needs an unevaluated context, otherwise any reference to immediate functions might not be properly handled.
1 parent 13c6abf commit 5427c74

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ Bug Fixes to C++ Support
966966
constraints are applied. (#GH122134)
967967
- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033)
968968
- Fixed a nested lambda substitution issue for constraint evaluation. (#GH123441)
969-
969+
- Fixed various false diagnostics related to the use of immediate functions. (#GH123472)
970970

971971
Bug Fixes to AST Handling
972972
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaConcept.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
10271027
ContextScope.emplace(S, const_cast<DeclContext *>(cast<DeclContext>(RD)),
10281028
/*NewThisContext=*/false);
10291029
}
1030+
EnterExpressionEvaluationContext UnevaluatedContext(
1031+
S, Sema::ExpressionEvaluationContext::Unevaluated,
1032+
Sema::ReuseLambdaContextDecl);
10301033
ExprResult SubstConstr = S.SubstConstraintExprWithoutSatisfaction(
10311034
const_cast<clang::Expr *>(ConstrExpr), MLTAL);
10321035
if (SFINAE.hasErrorOccurred() || !SubstConstr.isUsable())

clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,17 @@ ptr<U> make_item(auto &&args)
737737
ptr<char> p;
738738

739739
} // namespace GH114685
740+
741+
namespace GH123472 {
742+
743+
consteval bool fn() { return true; }
744+
745+
struct S {
746+
template <typename T>
747+
static consteval void mfn() requires (bool(&fn));
748+
};
749+
750+
template <typename T>
751+
consteval void S::mfn() requires (bool(&fn)) {}
752+
753+
}

0 commit comments

Comments
 (0)