| 1 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
template<typename T> |
| 4 |
struct A { |
| 5 |
template<typename U> |
| 6 |
struct B { |
| 7 |
static constexpr int y = 0; |
| 8 |
}; |
| 9 |
|
| 10 |
template<typename U> |
| 11 |
struct B<U*> { |
| 12 |
static constexpr int y = 1; |
| 13 |
}; |
| 14 |
|
| 15 |
template<typename U> |
| 16 |
static constexpr int x = 0; |
| 17 |
|
| 18 |
template<typename U> |
| 19 |
static constexpr int x<U*> = 1; |
| 20 |
}; |
| 21 |
|
| 22 |
template<typename T> |
| 23 |
template<typename U> |
| 24 |
struct A<T>::B<U[]> { |
| 25 |
static constexpr int y = 2; |
| 26 |
}; |
| 27 |
|
| 28 |
template<typename T> |
| 29 |
template<typename U> |
| 30 |
constexpr int A<T>::x<U[]> = 2; |
| 31 |
|
| 32 |
static_assert(A<short>::B<int>::y == 0); |
| 33 |
static_assert(A<short>::B<int*>::y == 1); |
| 34 |
static_assert(A<short>::B<int[]>::y == 2); |
| 35 |
static_assert(A<short>::x<int> == 0); |
| 36 |
static_assert(A<short>::x<int*> == 1); |
| 37 |
static_assert(A<short>::x<int[]> == 2); |
| 38 |
|
| 39 |
template<> |
| 40 |
template<typename U> |
| 41 |
struct A<int>::B { |
| 42 |
static constexpr int y = 3; |
| 43 |
}; |
| 44 |
|
| 45 |
template<> |
| 46 |
template<typename U> |
| 47 |
struct A<int>::B<U&> { |
| 48 |
static constexpr int y = 4; |
| 49 |
}; |
| 50 |
|
| 51 |
template<> |
| 52 |
template<typename U> |
| 53 |
struct A<long>::B<U&> { |
| 54 |
static constexpr int y = 5; |
| 55 |
}; |
| 56 |
|
| 57 |
template<> |
| 58 |
template<typename U> |
| 59 |
constexpr int A<int>::x = 3; |
| 60 |
|
| 61 |
template<> |
| 62 |
template<typename U> |
| 63 |
constexpr int A<int>::x<U&> = 4; |
| 64 |
|
| 65 |
template<> |
| 66 |
template<typename U> |
| 67 |
constexpr int A<long>::x<U&> = 5; |
| 68 |
|
| 69 |
static_assert(A<int>::B<int>::y == 3); |
| 70 |
static_assert(A<int>::B<int*>::y == 3); |
| 71 |
static_assert(A<int>::B<int[]>::y == 3); |
| 72 |
|
| 73 |
// FIXME: This should pass! |
| 74 |
static_assert(A<int>::B<int&>::y == 4); // expected-error {{static assertion failed due to requirement 'A<int>::B<int &>::y == 4'}} |
| 75 |
// expected-note@-1 {{expression evaluates to '3 == 4'}} |
| 76 |
static_assert(A<int>::x<int> == 3); |
| 77 |
static_assert(A<int>::x<int*> == 3); |
| 78 |
static_assert(A<int>::x<int[]> == 3); |
| 79 |
|
| 80 |
// FIXME: This should pass! |
| 81 |
static_assert(A<int>::x<int&> == 4); // expected-error {{static assertion failed due to requirement 'A<int>::x<int &> == 4'}} |
| 82 |
// expected-note@-1 {{expression evaluates to '3 == 4'}} |
| 83 |
static_assert(A<long>::B<int>::y == 0); |
| 84 |
static_assert(A<long>::B<int*>::y == 1); |
| 85 |
static_assert(A<long>::B<int[]>::y == 2); |
| 86 |
static_assert(A<long>::B<int&>::y == 5); |
| 87 |
static_assert(A<long>::x<int> == 0); |
| 88 |
static_assert(A<long>::x<int*> == 1); |
| 89 |
static_assert(A<long>::x<int[]> == 2); |
| 90 |
static_assert(A<long>::x<int&> == 5); |