Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/pr119563.C

raw
1 // PR c++/119563
2 // { dg-do run { target c++11 } }
3 // { dg-options "-O2" }
4
5 namespace std {
6 template <typename T>
7 struct initializer_list {
8 private:
9 T *_M_array;
10 decltype (sizeof 0) _M_len;
11 public:
12 constexpr decltype (sizeof 0)
13 size () const noexcept { return _M_len; }
14 constexpr const T *
15 begin () const noexcept { return _M_array; }
16 constexpr const T *
17 end () const noexcept { return begin () + size (); }
18 };
19 }
20
21 struct A {} a;
22
23 struct B {
24 constexpr B (int x) : B (a, x) {}
25 template <typename... T>
26 constexpr B (A, T... x) : b(x...) {}
27 int b;
28 };
29
30 struct C {
31 C (std::initializer_list<B> x)
32 {
33 if (x.size () != 130 + 1024 + 130)
34 __builtin_abort ();
35 unsigned int i = 1, j = 0;
36 for (auto a = x.begin (); a < x.end (); ++a)
37 if (a->b != i)
38 __builtin_abort ();
39 else
40 {
41 if (j == 129 || j == 129 + 1024)
42 i = 0;
43 i = (i & 15) + 1;
44 ++j;
45 }
46 c = true;
47 }
48 bool c;
49 };
50
51 #define D 1 + 0, 2 + 0, 3 + 0, 4 + 0, 5 + 0, 6 + 0, 7 + 0, 8 + 0, \
52 9 + 0, 10 + 0, 11 + 0, 12 + 0, 13 + 0, 14 + 0, 15 + 0, 16 + 0
53 #define E D, D, D, D, D, D, D, D
54
55 C c { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
56 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
57 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
58 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
59 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
60 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
61 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
62 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
63 1, 2, E, E, E, E, E, E, E, E,
64 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
65 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
66 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
67 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
68 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
69 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
70 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
71 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
72 1, 2 };
73
74 int
75 main ()
76 {
77 if (!c.c)
78 __builtin_abort ();
79 }