summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/complit12.C
blob: 29c9af1864f36fb05241123158a1a561dd45274b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// PR c++/40948
// { dg-do run }
// { dg-options "" }

int c;
struct M
{
  M () { ++c; }
  M (const M&) { ++c; }
  ~M () { --c; }
};

struct S
{
  S ();
  M m[1];
};

S::S () : m ((M[1]) { M () })
{
}

struct T
{
  T ();
  M m[4];
};

T::T () : m ((M[4]) { M (), M (), M (), M () })
{
}

typedef M MA[1];
MA &bar (MA, MA& r) { return r; }

M f(M m) { return m; }

int main ()
{
  {
    M m[1] = (M[1]) { M () };
    if (c != 1)
      return 1;
    M n = (M) { M () };
    if (c != 2)
      return 2;
    M o[4] = (M[4]) { M (), M (), M (), M () };
    if (c != 6)
      return 3;
    S s;
    if (c != 7)
      return 4;
    T t;
    if (c != 11)
      return 5;
    MA ma = bar ((M[2]) { M(), M() }, m);
    if (c != 12)
      return 7;
    M mm[2] = ((M[2]) { f(M()), f(M()) });
    if (c != 14)
      return 8;
  }
  if (c != 0)
    return 6;
}