Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / variadic-init.C
blob34ade85e0f992c8e3d733cf28da6fe50bd2b0930
1 // { dg-do run }
2 // { dg-options "-std=gnu++0x" }
4 // PR c++/33510
5 #define SIZE_FROM_CTOR
6 extern "C" void abort ();
8 template<int M, int N> struct pair
10   int i, j;
11   pair () : i (M), j (N) {}
14 template<int... M> struct S
16   template<int... N> static int *foo ()
17   {
18 #ifdef SIZE_FROM_CTOR
19     static int x[] = { (M + N)..., -1 };
20 #else
21     static int x[1 + sizeof... N] = { (M + N)..., -1 };
22 #endif
23     return x;
24   }
27 template<typename... M> struct R
29   template<typename... N> static int *foo ()
30   {
31 #ifdef SIZE_FROM_CTOR
32     static int x[] = { (sizeof(M) + sizeof(N))..., -1 };
33 #else
34     static int x[1 + sizeof... N] = { (sizeof(M) + sizeof(N))..., -1 };
35 #endif
36     return x;
37   }
40 int *bar ()
42   return S<0, 1, 2>::foo<0, 1, 2> ();
45 int *baz ()
47   return R<char, short, int>::foo<float, double, long> ();
51 int main ()
53   int *p = bar ();
54   if (p[0] != 0 || p[1] != 2 || p[2] != 4 || p[3] != -1)
55     abort ();