Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -991,6 +991,7 @@ Bug Fixes to C++ Support
- 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 rejects declaring an alias template with the same name as its template parameter. (#GH123423)
- Correctly determine the implicit constexprness of lambdas in dependent contexts. (#GH97958) (#GH114234)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/Sema/SemaLambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,18 +2239,18 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,

Cleanup.mergeFrom(LambdaCleanup);

LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange,
CaptureDefault, CaptureDefaultLoc,
ExplicitParams, ExplicitResultType,
CaptureInits, EndLoc,
ContainsUnexpandedParameterPack);
LambdaExpr *Lambda =
LambdaExpr::Create(Context, Class, IntroducerRange, CaptureDefault,
CaptureDefaultLoc, ExplicitParams, ExplicitResultType,
CaptureInits, EndLoc, ContainsUnexpandedParameterPack);

// If the lambda expression's call operator is not explicitly marked constexpr
// and we are not in a dependent context, analyze the call operator to infer
// and is not dependent, analyze the call operator to infer
// its constexpr-ness, suppressing diagnostics while doing so.
if (getLangOpts().CPlusPlus17 && !CallOperator->isInvalidDecl() &&
!CallOperator->isConstexpr() &&
!isa<CoroutineBodyStmt>(CallOperator->getBody()) &&
!Class->getDeclContext()->isDependentContext()) {
!Class->isDependentContext()) {
CallOperator->setConstexprKind(
CheckConstexprFunctionDefinition(CallOperator,
CheckConstexprKind::CheckValid)
Expand Down
24 changes: 24 additions & 0 deletions clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,27 @@ static_assert(OtherCaptures(), "");
} // namespace PR36054

#endif // ndef CPP14_AND_EARLIER


#if __cpp_constexpr >= 201907L
namespace GH114234 {
template <auto Arg>
auto g() { return Arg; }

template <typename>
auto f() {
[]<typename>() {
g<[] { return 123; }()>();
}.template operator()<int>();
}

void test() { f<int>(); }
}

namespace GH97958 {
static_assert(
[]<int I=0>() -> decltype([]{ return true; })
{ return {}; }()());
}

#endif
Loading