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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [p2846.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 305 jeremybenn
// { dg-do run  }
2
// prms-id: 2846
3
 
4
extern "C" int printf(const char *, ...);
5
extern "C" void exit(int);
6
 
7
class A;
8
class B;
9
 
10
int c;
11
 
12
class A {
13
public:
14
 
15
  A(void){}
16
  A(const A&){}
17
  A(const B&);
18
 
19
  virtual ~A(void){}
20
 
21
  virtual void print(void) const {
22
    printf("A::print\n");
23
    printf("FAIL\n");
24
    exit(1);
25
  }
26
  B compute(void) const;
27
};
28
 
29
class B : private A {
30
friend class A;
31
public:
32
 
33
  virtual ~B(void){}
34
 
35
  void print(void) const {
36
    ++c;
37
    printf("B::print\n");
38
  }
39
 
40
private:
41
  B(const A& x, int){}
42
};
43
 
44
A::A(const B& s) {
45
  s.print();
46
}
47
 
48
B A::compute(void) const {
49
  B sub(*this, 1);
50
  return sub;
51
}
52
 
53
int main ()
54
{
55
  A titi;
56
  A toto = titi.compute();
57
  if (c != 1)
58
    {
59
      printf ("FAIL\n");
60
      return 1;
61
    }
62
  else
63
    {
64
      printf("PASS\n");
65
      return 0;
66
    }
67
}

powered by: WebSVN 2.1.0

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