Files
clang-p2996/clang/test/SemaCXX/pr64462.cpp
Sheng 548d67a039 [clang][Sema] Fix a bug when instantiating a lambda with requires clause (#65193)
Instantiating a lambda at a scope different from where it is defined
will paralyze clang if the trailing require clause refers to local
variables. This patch fixes this by re-adding the local variables to
`LocalInstantiationScope`.

Fixes #64462
2023-10-04 10:19:35 +08:00

22 lines
727 B
C++

// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
auto c1(auto f, auto ...fs) {
constexpr bool a = true;
return [](auto) requires a {
constexpr bool b = true;
return []() requires a && b {
constexpr bool c = true;
return [](auto) requires a && b && c {
constexpr bool d = true;
// expected-note@+2{{because substituted constraint expression is ill-formed: no matching function for call to 'c1'}}
// expected-note@+1{{candidate function not viable: constraints not satisfied}}
return []() requires a && b && c && d && (c1(fs...)) {};
};
}();
}(1);
}
void foo() {
c1(true)(1.0)(); // expected-error{{no matching function for call to object of type}}
}