sizeofpack.cpp revision 3cb443636fb3ca457994d91527a22c5b159e5169
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2// expected-no-diagnostics
3
4namespace pr12262 {
5
6template<typename T, typename... Ts>
7void abc1(int (*xxx)[sizeof ... (Ts) + 1]);
8
9void qq1 () {
10  abc1<int>(0);
11  abc1<int,double>(0);
12}
13
14
15template <unsigned N> class array {};
16
17
18template<typename T, typename... Types>
19array<sizeof...(Types)> make_array1(Types&&... args);
20
21void qq2 () {
22  array<1> arr = make_array1<int>(1);
23  array<3> arr2 = make_array1<int>(1,array<5>(),0.1);
24}
25
26
27template<typename T, typename... Types>
28int make_array(array<sizeof...(Types)>&, Types... args);
29
30void 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");
35}
36
37
38template<typename ... Ts>
39struct AAA {
40  template<typename T, typename... Types>
41  static array<sizeof...(Types)> make_array(Types ... args);
42};
43
44void qq4 () {
45  array<2> arr2 = AAA<int, int>::make_array<int>(1,2);
46}
47
48}
49
50
51namespace pr12439 {
52
53template<class... Members>
54struct X {
55  template<int Idx>
56  using get_t = decltype(sizeof...(Members));
57
58  template<int i>
59  get_t<i> get();
60};
61
62template<class... Members>
63template<int i>
64X<Members...>::get_t<i> X<Members...>::get()
65{
66  return 0;
67}
68
69}
70
71
72namespace pr13272 {
73
74template<bool B, class T = void>
75struct enable_if { };
76
77template<class T> struct enable_if<true, T> {
78  typedef T type;
79};
80
81class Exception {};
82
83template<class Ex, typename... Args>
84void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) {
85  return;
86}
87
88void test() {
89  cxx_throw<Exception>("Youpi",1);
90}
91
92}
93
94
95namespace pr13817 {
96
97template <unsigned>
98struct zod;
99
100template <>
101struct zod<1> {};
102
103template <typename T, typename ... Ts>
104zod<sizeof...(Ts)> make_zod(Ts ...) {
105  return zod<sizeof...(Ts)>();
106}
107
108int main(int argc, char *argv[])
109{
110  make_zod<int>(1);
111  return 0;
112}
113
114}
115
116
117namespace pr14273 {
118
119template<typename T, int i>
120struct myType
121{ };
122
123template<typename T, typename... Args>
124struct Counter
125{
126  static const int count = 1 + Counter<Args...>::count;
127};
128
129template<typename T>
130struct Counter<T>
131{
132  static const int count = 1;
133};
134
135template<typename Arg, typename... Args>
136myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)
137{
138  return 0;
139}
140
141void func(void)
142{
143  make_array_with_type<char>(1,2,3);
144}
145
146}
147
148
149namespace pr15112
150{
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; };
157
158  typedef __typeof__(sizeof(int)) size_t;
159
160  template <size_t n, typename T, typename... Args>
161  struct is_array_of { static const bool value = true; };
162
163  struct cpu { using value_type = void; };
164
165  template <size_t Order, typename T>
166  struct coords_alias { typedef T type; };
167
168  template <size_t Order, typename MemoryTag>
169  using coords = typename coords_alias<Order, MemoryTag>::type;
170
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);
175
176  auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul);
177}
178
179
180namespace pr12699 {
181
182template<bool B>
183struct bool_constant
184{
185  static const bool value = B;
186};
187
188template<typename... A>
189struct F
190{
191  template<typename... B>
192    using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>;
193
194  template<typename... B, typename = SameSize<B...>>
195  F(B...) { }
196};
197
198void func()
199{
200  F<int> f1(3);
201}
202
203}
204