OSDN Git Service

* g++.old-deja/g++.brendan/err-msg8.C: Adjust error line.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.brendan / copy4.C
1 // GROUPS passed copy-ctors
2 // Using Cfront 3.0.1 the programm below prints
3 // 
4 //        A()
5 //        A(const A& a)
6 //        ~A()
7 //        A(A& a)        <---- !!!
8 //        ~A()
9 //        ~A()
10 // 
11 // the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints
12 // 
13 //        A()
14 //        A(const A& a)
15 //        ~A()
16 //        A(const A& a)  <---- !!!
17 //        ~A()
18 //        ~A()
19
20 extern "C" int printf (const char *, ...);
21 extern "C" void exit (int);
22
23 int count = 0;
24
25 void
26 die (int x)
27 {
28   if (x != ++count)
29     {
30       printf ("FAIL\n");
31       exit (1);
32     }
33 }
34
35 class A {
36 public:
37   A() { die (1); }
38   A(const A& a) { die (2); }
39   A(A& a) { die (4); }
40   ~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); }
41 };
42
43 void foo1(const A& a) {
44   A b = a;
45 }
46
47 void foo2( A& a) {
48   A b = a;
49 }
50
51 int main() {
52   A a;
53
54   foo1(a);
55   foo2(a);
56
57   printf ("PASS\n");
58 }