Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CXX / expr / expr.prim / expr.prim.req / equivalence.cpp
blob8a36d7a520a87be1134bcccc9e06c4feba4f071f
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 template<typename T, typename U> constexpr bool is_same_v = false;
4 template<typename T> constexpr bool is_same_v<T, T> = true;
6 template<typename T> struct identity { using type = T; };
7 template<typename T> using identity_t = T;
9 // Type requirements
10 template<typename T> requires requires { typename identity_t<T>; }
11 struct r1;
12 template<typename U> requires requires { typename identity_t<U>; } // expected-note{{previous template declaration is here}}
13 struct r1;
14 template<typename T> requires requires { typename identity_t<T*>; } // expected-error{{requires clause differs in template redeclaration}}
15 struct r1;
16 template<typename T> requires requires { typename ::identity_t<T>; }
17 struct r1;
19 template<typename Y> requires requires { typename identity<Y>::type; }
20 struct r2;
21 template<typename U> requires requires { typename identity<U>::type; }
22 struct r2;
23 template<typename T> requires requires { typename ::identity<T>::type; } // expected-note 2{{previous template declaration is here}}
24 struct r2;
25 template<typename T> requires requires { typename identity<T>::typr; } // expected-error{{requires clause differs in template redeclaration}}
26 struct r2;
27 namespace ns {
28 template<typename T> struct identity { using type = T; };
30 template<typename T> requires requires { typename ns::identity<T>::type; } // expected-error{{requires clause differs in template redeclaration}}
31 struct r2;
33 template<typename T> requires requires { typename T::template identity<T>::type; }
34 struct r3;
35 template<typename U> requires requires { typename U::template identity<U>::type; } // expected-note{{previous template declaration is here}}
36 struct r3;
37 template<typename T> requires requires { typename T::template identitr<T>::type; } // expected-error{{requires clause differs in template redeclaration}}
38 struct r3;
40 template<typename T> requires requires { typename T::template temp<>; }
41 struct r4;
42 template<typename U> requires requires { typename U::template temp<>; }
43 struct r4;
45 // Expr requirements
46 template<typename T> requires requires { 0; } // expected-note{{previous template declaration is here}}
47 struct r5;
48 template<typename T> requires requires { 1; } // expected-error{{requires clause differs in template redeclaration}}
49 struct r5;
51 template<typename T>
52 concept C1 = true;
54 template<typename T> requires requires { sizeof(T); }
55 struct r6;
56 template<typename U> requires requires { sizeof(U); } // expected-note{{previous template declaration is here}}
57 struct r6;
58 template<typename U> requires requires { sizeof(U) - 1; } // expected-error{{requires clause differs in template redeclaration}}
59 struct r6;
60 template<typename T> requires requires { { sizeof(T) }; } // expected-note 2{{previous template declaration is here}}
61 struct r6;
62 template<typename T> requires requires { { sizeof(T) } noexcept; } // expected-error{{requires clause differs in template redeclaration}}
63 struct r6;
64 template<typename T> requires requires { { sizeof(T) } -> C1; } // expected-error{{requires clause differs in template redeclaration}}
65 struct r6;
67 template<typename T> requires requires { { sizeof(T) } -> C1; }
68 struct r7;
69 template<typename U> requires requires { { sizeof(U) } -> C1; }
70 struct r7;
71 template<typename T> requires requires { { sizeof(T) } -> C1<>; } // expected-note {{previous template declaration is here}}
72 struct r7;
73 template<typename U> requires requires { { sizeof(U) }; } // expected-error{{requires clause differs in template redeclaration}}
74 struct r7;
76 template<typename T, typename U>
77 concept C2 = true;
79 template<typename T> requires requires { { sizeof(T) } -> C2<T>; }
80 struct r8;
81 template<typename U> requires requires { { sizeof(U) } -> C2<U>; } // expected-note{{previous template declaration is here}}
82 struct r8;
83 template<typename T> requires requires { { sizeof(T) } -> C2<T*>; } // expected-error{{requires clause differs in template redeclaration}}
84 struct r8;
86 // Nested requirements
87 template<typename T> requires requires { requires sizeof(T) == 0; }
88 struct r9;
89 template<typename U> requires requires { requires sizeof(U) == 0; } // expected-note{{previous template declaration is here}}
90 struct r9;
91 template<typename T> requires requires { requires sizeof(T) == 1; } // expected-error{{requires clause differs in template redeclaration}}
92 struct r9;
94 // Parameter list
95 template<typename T> requires requires { requires true; }
96 struct r10;
97 template<typename T> requires requires() { requires true; } // expected-note{{previous template declaration is here}}
98 struct r10;
99 template<typename T> requires requires(T i) { requires true; } // expected-error{{requires clause differs in template redeclaration}}
100 struct r10;
102 template<typename T> requires requires(T i, T *j) { requires true; } // expected-note 2{{previous template declaration is here}}
103 struct r11;
104 template<typename T> requires requires(T i) { requires true; } // expected-error{{requires clause differs in template redeclaration}}
105 struct r11;
106 template<typename T> requires requires(T i, T *j, T &k) { requires true; } // expected-error{{requires clause differs in template redeclaration}}
107 struct r11;
109 // Parameter names
110 template<typename T> requires requires(int i) { requires sizeof(i) == 1; }
111 struct r12;
112 template<typename T> requires requires(int j) { requires sizeof(j) == 1; } // expected-note 2{{previous template declaration is here}}
113 struct r12;
114 template<typename T> requires requires(int k) { requires sizeof(k) == 2; } // expected-error{{requires clause differs in template redeclaration}}
115 struct r12;
116 template<typename T> requires requires(const int k) { requires sizeof(k) == 1; } // expected-error{{requires clause differs in template redeclaration}}
117 struct r12;
119 // Order of requirements
120 template<typename T> requires requires { requires true; 0; }
121 struct r13;
122 template<typename T> requires requires { requires true; 0; } // expected-note{{previous template declaration is here}}
123 struct r13;
124 template<typename T> requires requires { 0; requires true; } // expected-error{{requires clause differs in template redeclaration}}
125 struct r13;