OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [copy4.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { 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()
20
 
21
extern "C" int printf (const char *, ...);
22
extern "C" void exit (int);
23
 
24
int count = 0;
25
 
26
void
27
die (int x)
28
{
29
  if (x != ++count)
30
    {
31
      printf ("FAIL\n");
32
      exit (1);
33
    }
34
}
35
 
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); }
42
};
43
 
44
void foo1(const A& a) {
45
  A b = a;
46
}
47
 
48
void foo2( A& a) {
49
  A b = a;
50
}
51
 
52
int main() {
53
  A a;
54
 
55
  foo1(a);
56
  foo2(a);
57
 
58
  printf ("PASS\n");
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.