Debian Codegraph @

gcc/testsuite/g++.dg/ext/complit12.C

raw
1 // PR c++/40948
2 // { dg-do run }
3 // { dg-options "" }
4
5 int c;
6 struct M
7 {
8 M () { ++c; }
9 M (const M&) { ++c; }
10 ~M () { --c; }
11 };
12
13 struct S
14 {
15 S ();
16 M m[1];
17 };
18
19 S::S () : m ((M[1]) { M () })
20 {
21 }
22
23 struct T
24 {
25 T ();
26 M m[4];
27 };
28
29 T::T () : m ((M[4]) { M (), M (), M (), M () })
30 {
31 }
32
33 typedef M MA[1];
34 MA &bar (MA, MA& r) { return r; }
35
36 M f(M m) { return m; }
37
38 int main ()
39 {
40 {
41 M m[1] = (M[1]) { M () };
42 if (c != 1)
43 return 1;
44 M n = (M) { M () };
45 if (c != 2)
46 return 2;
47 M o[4] = (M[4]) { M (), M (), M (), M () };
48 if (c != 6)
49 return 3;
50 S s;
51 if (c != 7)
52 return 4;
53 T t;
54 if (c != 11)
55 return 5;
56 M mm[2] = ((M[2]) { f(M()), f(M()) });
57 if (c != 13)
58 return 8;
59 #if 0
60 MA ma = bar ((M[2]) { M(), M() }, m);
61 if (c != 14)
62 return 7;
63 #endif
64 }
65 if (c != 0)
66 return 6;
67 }