// RUN: %clang_cc1 -std=c++20 -verify %s namespace N0 { template concept C = I >= 4; template concept D = I < 8; template struct A { // #defined-here constexpr static int f() { return 0; } constexpr static int f() requires C && D { return 1; } constexpr static int f() requires C { return 2; } constexpr static int g() requires C { return 0; } // #candidate-0 constexpr static int g() requires D { return 1; } // #candidate-1 constexpr static int h() requires C { return 0; } // expected-note {{member declaration nearly matches}} }; template<> constexpr int A<2>::f() { return 3; } template<> constexpr int A<4>::f() { return 4; } template<> constexpr int A<8>::f() { return 5; } static_assert(A<3>::f() == 0); static_assert(A<5>::f() == 1); static_assert(A<9>::f() == 2); static_assert(A<2>::f() == 3); static_assert(A<4>::f() == 4); static_assert(A<8>::f() == 5); template<> constexpr int A<0>::g() { return 2; } template<> constexpr int A<8>::g() { return 3; } template<> constexpr int A<6>::g() { return 4; } // expected-error {{ambiguous member function specialization 'N0::A<6>::g' of 'N0::A::g'}} // expected-note@#candidate-0 {{member function specialization matches 'g'}} // expected-note@#candidate-1 {{member function specialization matches 'g'}} static_assert(A<9>::g() == 0); static_assert(A<1>::g() == 1); static_assert(A<0>::g() == 2); static_assert(A<8>::g() == 3); template<> constexpr int A<4>::h() { return 1; } template<> constexpr int A<0>::h() { return 2; } // expected-error {{out-of-line definition of 'h' does not match any declaration in 'N0::A<0>'}} // expected-note@#defined-here {{defined here}} static_assert(A<5>::h() == 0); static_assert(A<4>::h() == 1); } // namespace N0 namespace N1 { template concept C = I > 0; template concept D = I > 1; template concept E = I > 2; template struct A { void f() requires C && D; // expected-note {{member function specialization matches 'f'}} void f() requires C && E; // expected-note {{member function specialization matches 'f'}} void f() requires C && D && true; // expected-note {{member function specialization matches 'f'}} void g() requires C && E; // expected-note {{member function specialization matches 'g'}} void g() requires C && D; // expected-note {{member function specialization matches 'g'}} void g() requires C && D && true; // expected-note {{member function specialization matches 'g'}} }; template<> void A<3>::f(); // expected-error {{ambiguous member function specialization 'N1::A<3>::f' of 'N1::A::f'}} template<> void A<3>::g(); // expected-error {{ambiguous member function specialization 'N1::A<3>::g' of 'N1::A::g'}} } // namespace N1