| 1 |
// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s |
| 2 |
|
| 3 |
namespace nodiag { |
| 4 |
|
| 5 |
template <typename T> requires (bool(T())) |
| 6 |
struct A; |
| 7 |
template <typename U> requires (bool(U())) |
| 8 |
struct A; |
| 9 |
|
| 10 |
template<typename T> |
| 11 |
concept C1 = true; |
| 12 |
|
| 13 |
template <C1 T> requires (bool(T())) |
| 14 |
struct B; |
| 15 |
template <C1 U> requires (bool(U())) |
| 16 |
struct B; |
| 17 |
|
| 18 |
} // end namespace nodiag |
| 19 |
|
| 20 |
namespace diag { |
| 21 |
|
| 22 |
template <typename T> requires true // expected-note{{previous template declaration is here}} |
| 23 |
struct A; |
| 24 |
template <typename T> struct A; // expected-error{{requires clause differs in template redeclaration}} |
| 25 |
|
| 26 |
template <typename T> struct B; // expected-note{{previous template declaration is here}} |
| 27 |
template <typename T> requires true // expected-error{{requires clause differs in template redeclaration}} |
| 28 |
struct B; |
| 29 |
|
| 30 |
template <typename T> requires true // expected-note{{previous template declaration is here}} |
| 31 |
struct C; |
| 32 |
template <typename T> requires (!0) // expected-error{{requires clause differs in template redeclaration}} |
| 33 |
struct C; |
| 34 |
|
| 35 |
template<typename T> |
| 36 |
concept C1 = true; |
| 37 |
|
| 38 |
template <C1 T> // expected-note{{previous template declaration is here}} |
| 39 |
struct D; |
| 40 |
template <typename T> requires C1<T> // expected-error{{type constraint differs in template redeclaration}} |
| 41 |
struct D; |
| 42 |
|
| 43 |
} // end namespace diag |
| 44 |
|
| 45 |
namespace nodiag { |
| 46 |
|
| 47 |
struct AA { |
| 48 |
template <typename T> requires (someFunc(T())) |
| 49 |
struct A; |
| 50 |
}; |
| 51 |
|
| 52 |
template <typename U> requires (someFunc(U())) |
| 53 |
struct AA::A { }; |
| 54 |
|
| 55 |
struct AAF { |
| 56 |
template <typename T> requires (someFunc(T())) |
| 57 |
friend struct AA::A; |
| 58 |
}; |
| 59 |
|
| 60 |
} // end namespace nodiag |
| 61 |
|
| 62 |
namespace diag { |
| 63 |
|
| 64 |
template <unsigned N> |
| 65 |
struct TA { |
| 66 |
template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}} |
| 67 |
struct A; |
| 68 |
|
| 69 |
template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}} |
| 70 |
struct B; |
| 71 |
|
| 72 |
struct AF; |
| 73 |
}; |
| 74 |
|
| 75 |
template <unsigned N> |
| 76 |
template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{requires clause differs in template redeclaration}} |
| 77 |
|
| 78 |
|
| 79 |
template <unsigned N> |
| 80 |
template <template <unsigned> class TT> requires TT<N + 1>::happy struct TA<N>::B { }; // expected-error{{requires clause differs in template redeclaration}} |
| 81 |
|
| 82 |
template <unsigned N> |
| 83 |
struct TA<N>::AF { |
| 84 |
// we do not expect a diagnostic here because the template parameter list is dependent. |
| 85 |
template <template <unsigned> class TT> requires TT<N + 0>::happy |
| 86 |
friend struct TA::A; |
| 87 |
}; |
| 88 |
|
| 89 |
} // end namespace diag |