2 // { dg-do run { target c++20 } }
3 // { dg-options "-Wall -Wextra" }
4 // Initializing arrays in a member init list using ()-init, valid cases.
6 #define assert(X) do { if (!(X)) __builtin_abort(); } while(0)
8 struct S { int x, y; };
9 struct N { int x, y; N(int, int); };
23 s2(1), // { dg-warning "missing initializer for member" }
24 a1({1}), // { dg-warning "missing initializer for member" }
49 // Not an aggregate, should work pre-C++20 too.
67 F::F () : m(__extension__(S[1]) { 1, 2 })
82 // Variation of c++/93790.
84 struct Empty_refwrap {
86 Empty_refwrap(Empty &e) : r(e) { }
87 operator Empty&() { return r; }
91 Empty_refwrap empty_refwrap(empty);
95 // Turning this into {empty_refwrap} would break things.
96 H() : e(empty_refwrap) { }
103 assert (a.s1.x == 1 && a.s1.y == 2);
104 assert (a.s2.x == 1 && a.s2.y == 0);
105 assert (a.a1[0].x == 1 && a.a1[0].y == 0
106 && a.a1[1].x == 0 && a.a1[1].y == 0);
107 assert (a.a2[0].x == 1 && a.a2[0].y == 2
108 && a.a2[1].x == 0 && a.a2[1].y == 0);
109 assert (a.a3[0].x == 0 && a.a3[0].y == 0
110 && a.a3[1].x == 0 && a.a3[1].y == 0);
111 assert (a.a4[0].x == 0 && a.a4[0].y == 0
112 && a.a4[1].x == 0 && a.a4[1].y == 0);
113 assert (a.a5[0].x == 10 && a.a5[0].y == 11
114 && a.a5[1].x == 0 && a.a5[1].y == 0);
115 assert (a.a6[0].x == 10 && a.a6[0].y == 11
116 && a.a6[1].x == 10 && a.a6[1].y == 11);
119 assert (c.a1[0] == 1 && c.a1[1] == 0);
120 assert (c.a2[0] == 1 && c.a2[1] == 2);
121 assert (c.a3[0] == 1 && c.a3[1] == 0);
122 assert (c.a4[0] == 0 && c.a4[1] == 0);
123 assert (c.a5[0] == 0 && c.a5[1] == 0);
126 assert (__builtin_strcmp (e.a1, "ab") == 0
127 && __builtin_strcmp (e.a2, "abc") == 0);