Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / temp / temp.decls / temp.variadic / sizeofpack.cpp
blob87c22a0d7e944f53a32b2a7b5e43e06eac3efb5c
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 // expected-no-diagnostics
4 namespace pr12262 {
6 template<typename T, typename... Ts>
7 void abc1(int (*xxx)[sizeof ... (Ts) + 1]);
9 void qq1 () {
10 abc1<int>(0);
11 abc1<int,double>(0);
15 template <unsigned N> class array {};
18 template<typename T, typename... Types>
19 array<sizeof...(Types)> make_array1(Types&&... args);
21 void qq2 () {
22 array<1> arr = make_array1<int>(1);
23 array<3> arr2 = make_array1<int>(1,array<5>(),0.1);
27 template<typename T, typename... Types>
28 int make_array(array<sizeof...(Types)>&, Types... args);
30 void qq3 () {
31 array<1> a1;
32 int aa1 = make_array<int>(a1,1);
33 array<2> a2;
34 int aa2 = make_array<int>(a2, 0L, "abc");
38 template<typename ... Ts>
39 struct AAA {
40 template<typename T, typename... Types>
41 static array<sizeof...(Types)> make_array(Types ... args);
44 void qq4 () {
45 array<2> arr2 = AAA<int, int>::make_array<int>(1,2);
51 namespace pr12439 {
53 template<class... Members>
54 struct X {
55 template<int Idx>
56 using get_t = decltype(sizeof...(Members));
58 template<int i>
59 get_t<i> get();
62 template<class... Members>
63 template<int i>
64 typename X<Members...>::template get_t<i> X<Members...>::get()
66 return 0;
72 namespace pr13272 {
74 template<bool B, class T = void>
75 struct enable_if { };
77 template<class T> struct enable_if<true, T> {
78 typedef T type;
81 class Exception {};
83 template<class Ex, typename... Args>
84 void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) {
85 return;
88 void test() {
89 cxx_throw<Exception>("Youpi",1);
95 namespace pr13817 {
97 template <unsigned>
98 struct zod;
100 template <>
101 struct zod<1> {};
103 template <typename T, typename ... Ts>
104 zod<sizeof...(Ts)> make_zod(Ts ...) {
105 return zod<sizeof...(Ts)>();
108 int main(int argc, char *argv[])
110 make_zod<int>(1);
111 return 0;
117 namespace pr14273 {
119 template<typename T, int i>
120 struct myType
121 { };
123 template<typename T, typename... Args>
124 struct Counter
126 static const int count = 1 + Counter<Args...>::count;
129 template<typename T>
130 struct Counter<T>
132 static const int count = 1;
135 template<typename Arg, typename... Args>
136 myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)
138 return 0;
141 void func(void)
143 make_array_with_type<char>(1,2,3);
149 namespace pr15112
151 template<bool, typename _Tp = void>
152 struct enable_if
153 { };
154 template<typename _Tp>
155 struct enable_if<true,_Tp>
156 { typedef _Tp type; };
158 typedef __typeof__(sizeof(int)) size_t;
160 template <size_t n, typename T, typename... Args>
161 struct is_array_of { static const bool value = true; };
163 struct cpu { using value_type = void; };
165 template <size_t Order, typename T>
166 struct coords_alias { typedef T type; };
168 template <size_t Order, typename MemoryTag>
169 using coords = typename coords_alias<Order, MemoryTag>::type;
171 template <typename MemTag, typename... Args>
172 typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value,
173 coords<sizeof...(Args), MemTag>>::type
174 mkcoords(Args... args);
176 auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul);
180 namespace pr12699 {
182 template<bool B>
183 struct bool_constant
185 static const bool value = B;
188 template<typename... A>
189 struct F
191 template<typename... B>
192 using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>;
194 template<typename... B, typename = SameSize<B...>>
195 F(B...) { }
198 void func()
200 F<int> f1(3);