Debian Codegraph @

gcc/testsuite/g++.dg/cpp/embed-26.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 unsigned char buf[] = {
34 #embed __FILE__
35 };
36 if (x.size () != 2 * sizeof (buf) + 1024)
37 __builtin_abort ();
38 unsigned int i = 0;
39 for (auto a = x.begin (); a < x.end (); ++a, ++i)
40 if (a->b != (i < sizeof (buf) ? buf[i]
41 : i < sizeof (buf) + 1024 ? ((i - sizeof (buf)) & 7) + 1
42 : buf[i - sizeof (buf) - 1024]))
43 __builtin_abort ();
44 c = true;
45 }
46 bool c;
47 };
48
49 #define D 1 + 0, 2 + 0, 3 + 0, 4 + 0, 5 + 0, 6 + 0, 7 + 0, 8 + 0
50 #define E D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D
51
52 C c {
53 #embed __FILE__ suffix (,)
54 E, E, E, E, E, E, E, E,
55 #embed __FILE__
56 };
57
58 int
59 main ()
60 {
61 if (!c.c)
62 __builtin_abort ();
63 }