2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / copy3.C
blobc5675696b2d6935d84701f8d03fa13cbaf838e73
1 // { dg-do run  }
2 // GROUPS passed copy-ctors
3 /*
5 If I compile it with cfront (AT&T C++ Translator 2.00.02 08/25/89) and run it
6 I get:
8         A::A()
9         A::A(const A&)
10         B::Bar()
11         A::~A()
12         A::~A()
14 If I compile it with g++ (gcc version 2.2.2) and run it I get:
16         A::A()
17         B::Bar()
18         A::~A()
19         A::~A()
22 extern "C" int printf (const char *, ...);
23 extern "C" void exit (int);
25 int count = 0;
27 void
28 die (int x)
30   if (x != ++count)
31     {
32       printf ("FAIL\n");
33       exit (1);
34     }
36   
38 class A {
39 public:
40   A() { die (1); }
41   A(const A&) { die (2); }
42   ~A() { count++; if (count != 4 && count != 5) die (-1); }
45 class B : public A {
46 public:
47   void Bar() { die (3); }
50 void Foo(B b) { b.Bar(); }
52 int
53 main()
55   B b;
56   Foo(b);
58   printf ("PASS\n");