mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-15 10:26:23 +00:00

As fallout of the Deferred Concept Instantiation patch (babdef27c5), we got a number of reports of a regression, where we asserted when instantiating a constraint on a generic lambda inside of a variable template. See: https://github.com/llvm/llvm-project/issues/57958 The problem was that getTemplateInstantiationArgs function only walked up declaration contexts, and missed that this is not necessarily the case with a lambda (which can ALSO be in a separate context). This patch refactors the getTemplateInstantiationArgs function in a way that is hopefully more readable, and fixes the problem with the concepts on a generic lambda. Differential Revision: https://reviews.llvm.org/D134874
58 lines
1015 B
C++
58 lines
1015 B
C++
// RUN: %clang_cc1 -std=c++20 -verify %s
|
|
// expected-no-diagnostics
|
|
|
|
namespace GH57945 {
|
|
template<typename T>
|
|
concept c = true;
|
|
|
|
template<typename>
|
|
auto f = []() requires c<void> {
|
|
};
|
|
|
|
void g() {
|
|
f<int>();
|
|
};
|
|
}
|
|
|
|
namespace GH57945_2 {
|
|
template<typename>
|
|
concept c = true;
|
|
|
|
template<typename T>
|
|
auto f = [](auto... args) requires c<T> {
|
|
};
|
|
|
|
template <typename T>
|
|
auto f2 = [](auto... args)
|
|
requires (sizeof...(args) > 0)
|
|
{};
|
|
|
|
void g() {
|
|
f<void>();
|
|
f2<void>(5.0);
|
|
}
|
|
}
|
|
|
|
namespace GH57958 {
|
|
template<class> concept C = true;
|
|
template<int> constexpr bool v = [](C auto) { return true; }(0);
|
|
int _ = v<0>;
|
|
}
|
|
namespace GH57958_2 {
|
|
template<class> concept C = true;
|
|
template<int> constexpr bool v = [](C auto...) { return true; }(0);
|
|
int _ = v<0>;
|
|
}
|
|
|
|
namespace GH57971 {
|
|
template<typename>
|
|
concept any = true;
|
|
|
|
template<typename>
|
|
auto f = [](any auto) {
|
|
};
|
|
|
|
using function_ptr = void(*)(int);
|
|
function_ptr ptr = f<void>;
|
|
}
|