llvm-project/clang/test/SemaTemplate/explicit-instantiation-cxx20.cpp
cor3ntin 6bb5a0b171
[Clang] Check constraints for an explicit instantiation of a member function (#104438)
Because there may be multiple constrained function of the same type, we
need to perform overload resolution to find the best viable function to
specialize.


Fixes #46029
2024-08-19 19:03:21 +02:00

41 lines
1.2 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
template<class T>
concept C = true;
template<class T>
concept D = C<T> && true;
template<typename T>
struct a {
void no_candidate() requires(false) {}
// expected-note@-1 {{candidate function not viable: constraints not satisfied}} \
// expected-note@-1 {{because 'false' evaluated to false}}
void no_candidate() requires(false && false) {}
// expected-note@-1 {{candidate function not viable: constraints not satisfied}} \
// expected-note@-1 {{because 'false' evaluated to false}}
void subsumes();
void subsumes() requires C<T>;
void subsumes() requires D<T> {};
void ok() requires false;
void ok() requires true {};
void ok2() requires false;
void ok2(){};
void ambiguous() requires true;
// expected-note@-1 {{candidate function}}
void ambiguous() requires C<T>;
// expected-note@-1 {{candidate function}}
};
template void a<int>::no_candidate();
// expected-error@-1 {{no viable candidate for explicit instantiation of 'no_candidate'}}
template void a<int>::ambiguous();
// expected-error@-1 {{partial ordering for explicit instantiation of 'ambiguous' is ambiguous}}
template void a<int>::ok();
template void a<int>::ok2();