Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / temp / temp.constr / temp.constr.decl / class-template-decl.cpp
blobabda86983820ba18963f0ae6de5beb45f4e29708
1 // RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
3 namespace nodiag {
5 template <typename T> requires (bool(T()))
6 struct A;
7 template <typename U> requires (bool(U()))
8 struct A;
10 template<typename T>
11 concept C1 = true;
13 template <C1 T> requires (bool(T()))
14 struct B;
15 template <C1 U> requires (bool(U()))
16 struct B;
18 } // end namespace nodiag
20 namespace diag {
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}}
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;
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;
35 template<typename T>
36 concept C1 = true;
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;
43 } // end namespace diag
45 namespace nodiag {
47 struct AA {
48 template <typename T> requires (someFunc(T()))
49 struct A;
52 template <typename U> requires (someFunc(U()))
53 struct AA::A { };
55 struct AAF {
56 template <typename T> requires (someFunc(T()))
57 friend struct AA::A;
60 } // end namespace nodiag
62 namespace diag {
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;
69 template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}}
70 struct B;
72 struct AF;
75 template <unsigned N>
76 template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{requires clause differs in template redeclaration}}
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}}
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;
89 } // end namespace diag