1 // RUN: %clang_cc1 -std=c++20 -verify %s 2 3 template <class T> 4 struct A { 5 void primary(); 6 }; 7 8 template <class T> 9 requires requires(T &t) { requires sizeof(t) > 4; } 10 struct A<T> { 11 void specialization1(); 12 }; 13 14 template <class T> 15 requires requires(T &t) { requires sizeof(t) > 8; } 16 struct A<T> { 17 void specialization2(); 18 }; 19 20 int main() { 21 A<char>().primary(); 22 A<char[5]>().specialization1(); 23 A<char[16]>(); // expected-error {{ambiguous partial specialization}} 24 // expected-note@10 {{partial specialization matches [with T = char[16]}} 25 // expected-note@16 {{partial specialization matches [with T = char[16]}} 26 } 27 28 // Check error messages when no overload with constraints matches. 29 template <class T> 30 void foo() 31 requires requires(T &t) { requires sizeof(t) < 4; } 32 {} 33 34 template <class T> 35 void foo() 36 requires requires(T &t) { requires sizeof(t) > 4; } 37 {} 38 39 template <class T> 40 void foo() 41 requires requires(T &t) { requires sizeof(t) > 8; } 42 {} 43 44 void test() { 45 foo<char[4]>(); 46 // expected-error@-1 {{no matching function for call to 'foo'}} 47 // expected-note@30 {{candidate template ignored: constraints not satisfied}} 48 // expected-note@31 {{because 'sizeof (t) < 4' (4 < 4) evaluated to false}} 49 // expected-note@35 {{candidate template ignored: constraints not satisfied}} 50 // expected-note@36 {{because 'sizeof (t) > 4' (4 > 4) evaluated to false}} 51 // expected-note@40 {{candidate template ignored: constraints not satisfied}} 52 // expected-note@41 {{because 'sizeof (t) > 8' (4 > 8) evaluated to false}} 53 54 foo<char[16]>(); 55 // expected-error@-1 {{call to 'foo' is ambiguous}} 56 // expected-note@35 {{candidate function}} 57 // expected-note@40 {{candidate function}} 58 } 59