|
1 | 1 | // RUN: %clang_cc1 -std=c++20 -verify %s
|
2 | 2 |
|
3 |
| -template<int I> |
4 |
| -concept C = I >= 4; |
| 3 | +namespace N0 { |
| 4 | + template<int I> |
| 5 | + concept C = I >= 4; |
5 | 6 |
|
6 |
| -template<int I> |
7 |
| -concept D = I < 8; |
| 7 | + template<int I> |
| 8 | + concept D = I < 8; |
8 | 9 |
|
9 |
| -template<int I> |
10 |
| -struct A { |
11 |
| - constexpr static int f() { return 0; } |
12 |
| - constexpr static int f() requires C<I> && D<I> { return 1; } |
13 |
| - constexpr static int f() requires C<I> { return 2; } |
| 10 | + template<int I> |
| 11 | + struct A { |
| 12 | + constexpr static int f() { return 0; } |
| 13 | + constexpr static int f() requires C<I> && D<I> { return 1; } |
| 14 | + constexpr static int f() requires C<I> { return 2; } |
14 | 15 |
|
15 |
| - constexpr static int g() requires C<I> { return 0; } // #candidate-0 |
16 |
| - constexpr static int g() requires D<I> { return 1; } // #candidate-1 |
| 16 | + constexpr static int g() requires C<I> { return 0; } // #candidate-0 |
| 17 | + constexpr static int g() requires D<I> { return 1; } // #candidate-1 |
17 | 18 |
|
18 |
| - constexpr static int h() requires C<I> { return 0; } // expected-note {{member declaration nearly matches}} |
19 |
| -}; |
| 19 | + constexpr static int h() requires C<I> { return 0; } // expected-note {{member declaration nearly matches}} |
| 20 | + }; |
20 | 21 |
|
21 |
| -template<> |
22 |
| -constexpr int A<2>::f() { return 3; } |
| 22 | + template<> |
| 23 | + constexpr int A<2>::f() { return 3; } |
23 | 24 |
|
24 |
| -template<> |
25 |
| -constexpr int A<4>::f() { return 4; } |
| 25 | + template<> |
| 26 | + constexpr int A<4>::f() { return 4; } |
26 | 27 |
|
27 |
| -template<> |
28 |
| -constexpr int A<8>::f() { return 5; } |
| 28 | + template<> |
| 29 | + constexpr int A<8>::f() { return 5; } |
29 | 30 |
|
30 |
| -static_assert(A<3>::f() == 0); |
31 |
| -static_assert(A<5>::f() == 1); |
32 |
| -static_assert(A<9>::f() == 2); |
33 |
| -static_assert(A<2>::f() == 3); |
34 |
| -static_assert(A<4>::f() == 4); |
35 |
| -static_assert(A<8>::f() == 5); |
| 31 | + static_assert(A<3>::f() == 0); |
| 32 | + static_assert(A<5>::f() == 1); |
| 33 | + static_assert(A<9>::f() == 2); |
| 34 | + static_assert(A<2>::f() == 3); |
| 35 | + static_assert(A<4>::f() == 4); |
| 36 | + static_assert(A<8>::f() == 5); |
36 | 37 |
|
37 |
| -template<> |
38 |
| -constexpr int A<0>::g() { return 2; } |
| 38 | + template<> |
| 39 | + constexpr int A<0>::g() { return 2; } |
39 | 40 |
|
40 |
| -template<> |
41 |
| -constexpr int A<8>::g() { return 3; } |
| 41 | + template<> |
| 42 | + constexpr int A<8>::g() { return 3; } |
42 | 43 |
|
43 |
| -template<> |
44 |
| -constexpr int A<6>::g() { return 4; } // expected-error {{ambiguous member function specialization 'A<6>::g' of 'A::g'}} |
45 |
| - // expected-note@#candidate-0 {{member function specialization matches 'g'}} |
46 |
| - // expected-note@#candidate-1 {{member function specialization matches 'g'}} |
| 44 | + template<> |
| 45 | + constexpr int A<6>::g() { return 4; } // expected-error {{ambiguous member function specialization 'N0::A<6>::g' of 'N0::A::g'}} |
| 46 | + // expected-note@#candidate-0 {{member function specialization matches 'g'}} |
| 47 | + // expected-note@#candidate-1 {{member function specialization matches 'g'}} |
47 | 48 |
|
48 |
| -static_assert(A<9>::g() == 0); |
49 |
| -static_assert(A<1>::g() == 1); |
50 |
| -static_assert(A<0>::g() == 2); |
51 |
| -static_assert(A<8>::g() == 3); |
| 49 | + static_assert(A<9>::g() == 0); |
| 50 | + static_assert(A<1>::g() == 1); |
| 51 | + static_assert(A<0>::g() == 2); |
| 52 | + static_assert(A<8>::g() == 3); |
52 | 53 |
|
53 |
| -template<> |
54 |
| -constexpr int A<4>::h() { return 1; } |
| 54 | + template<> |
| 55 | + constexpr int A<4>::h() { return 1; } |
55 | 56 |
|
56 |
| -template<> |
57 |
| -constexpr int A<0>::h() { return 2; } // expected-error {{out-of-line definition of 'h' does not match any declaration in 'A<0>'}} |
| 57 | + template<> |
| 58 | + constexpr int A<0>::h() { return 2; } // expected-error {{out-of-line definition of 'h' does not match any declaration in 'N0::A<0>'}} |
58 | 59 |
|
59 |
| -static_assert(A<5>::h() == 0); |
60 |
| -static_assert(A<4>::h() == 1); |
| 60 | + static_assert(A<5>::h() == 0); |
| 61 | + static_assert(A<4>::h() == 1); |
| 62 | +} // namespace N0 |
| 63 | + |
| 64 | +namespace N1 { |
| 65 | + template<int I> |
| 66 | + concept C = I > 0; |
| 67 | + |
| 68 | + template<int I> |
| 69 | + concept D = I > 1; |
| 70 | + |
| 71 | + template<int I> |
| 72 | + concept E = I > 2; |
| 73 | + |
| 74 | + template<int I> |
| 75 | + struct A { |
| 76 | + void f() requires C<I> && D<I>; // expected-note {{member function specialization matches 'f'}} |
| 77 | + void f() requires C<I> && E<I>; // expected-note {{member function specialization matches 'f'}} |
| 78 | + void f() requires C<I> && D<I> && true; // expected-note {{member function specialization matches 'f'}} |
| 79 | + |
| 80 | + void g() requires C<I> && E<I>; // expected-note {{member function specialization matches 'g'}} |
| 81 | + void g() requires C<I> && D<I>; // expected-note {{member function specialization matches 'g'}} |
| 82 | + void g() requires C<I> && D<I> && true; // expected-note {{member function specialization matches 'g'}} |
| 83 | + }; |
| 84 | + |
| 85 | + template<> |
| 86 | + void A<3>::f(); // expected-error {{ambiguous member function specialization 'N1::A<3>::f' of 'N1::A::f'}} |
| 87 | + |
| 88 | + template<> |
| 89 | + void A<3>::g(); // expected-error {{ambiguous member function specialization 'N1::A<3>::g' of 'N1::A::g'}} |
| 90 | +} // namespace N1 |
0 commit comments