2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / copy2.C
blob261e4f50a1c616d7df9aae66d212a946f17f715d
1 // { dg-do run  }
2 // GROUPS passed copy-ctors
3 /*
4 The old g++ output is
6 Item()
7 Compound()
8 Pre foo
9 foo
10 ~Compound()
11 ~Item()
12 Post foo
13 ~Compound()
14 ~Item()
16 The output should be something like (produced from ATT 2.1)
18 Item()
19 Compound()
20 Pre foo
21 Item(const Item& i)    <------ missing above
22 foo
23 ~Compound()
24 ~Item()
25 Post foo
26 ~Compound()
27 ~Item()
31 extern "C" int printf (const char *, ...);
32 extern "C" void exit (int);
34 int count = 0;
36 void
37 die (int x)
39   if (x != ++count)
40     {
41       printf ("FAIL\n");
42       exit (1);
43     }
45   
47 class Item {
48  public:
49   Item() { die (1); }
50   Item(const Item& i) { die (4); }
51   ~Item() { count++; if (count != 7 && count != 10) die (-1); }
55 class Compound {
56   Item i;
57  public:
58   Compound() { die (2); }
59   ~Compound() { count++; if (count != 6 && count != 9) die (-1); }
63 void foo(Compound a)
65   die (5);
68 int
69 main()
71   Compound a;
73   die (3);
74   foo(a);
76   die (8);
78   printf ("PASS\n");