Clang Project

clang_source_code/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
1// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
2
3namespace nodiag {
4
5template <typename T> requires bool(T())
6struct A;
7template <typename U> requires bool(U())
8struct A;
9
10} // end namespace nodiag
11
12namespace diag {
13
14template <typename T> requires true // expected-note{{previous template declaration is here}}
15struct A;
16template <typename T> struct A; // expected-error{{associated constraints differ in template redeclaration}}
17
18template <typename T> struct B; // expected-note{{previous template declaration is here}}
19template <typename T> requires true // expected-error{{associated constraints differ in template redeclaration}}
20struct B;
21
22template <typename T> requires true // expected-note{{previous template declaration is here}}
23struct C;
24template <typename T> requires !0 // expected-error{{associated constraints differ in template redeclaration}}
25struct C;
26
27} // end namespace diag
28
29namespace nodiag {
30
31struct AA {
32  template <typename T> requires someFunc(T())
33  struct A;
34};
35
36template <typename T> requires someFunc(T())
37struct AA::A { };
38
39struct AAF {
40  template <typename T> requires someFunc(T())
41  friend struct AA::A;
42};
43
44} // end namespace nodiag
45
46namespace diag {
47
48template <unsigned N>
49struct TA {
50  template <template <unsigned> class TT> requires TT<N>::happy // expected-note 2{{previous template declaration is here}}
51  struct A;
52
53  struct AF;
54};
55
56template <unsigned N>
57template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{associated constraints differ in template redeclaration}}
58
59template <unsigned N>
60struct TA<N>::AF {
61  template <template <unsigned> class TT> requires TT<N + 0>::happy // expected-error{{associated constraints differ in template redeclaration}}
62  friend struct TA::A;
63};
64
65} // end namespace diag
66