2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / copy4.C
blobbbb6c3e201aa240de2714fb6cd96096313fbaa4d
1 // { dg-do run  }
2 // GROUPS passed copy-ctors
3 // Using Cfront 3.0.1 the programm below prints
4 // 
5 //        A()
6 //        A(const A& a)
7 //        ~A()
8 //        A(A& a)        <---- !!!
9 //        ~A()
10 //        ~A()
11 // 
12 // the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints
13 // 
14 //        A()
15 //        A(const A& a)
16 //        ~A()
17 //        A(const A& a)  <---- !!!
18 //        ~A()
19 //        ~A()
21 extern "C" int printf (const char *, ...);
22 extern "C" void exit (int);
24 int count = 0;
26 void
27 die (int x)
29   if (x != ++count)
30     {
31       printf ("FAIL\n");
32       exit (1);
33     }
36 class A {
37 public:
38   A() { die (1); }
39   A(const A& a) { die (2); }
40   A(A& a) { die (4); }
41   ~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); }
44 void foo1(const A& a) {
45   A b = a;
48 void foo2( A& a) {
49   A b = a;
52 int main() {
53   A a;
55   foo1(a);
56   foo2(a);
58   printf ("PASS\n");