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++.dg/] [inherit/] [covariant4.C] - Blame information for rev 779

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

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do run }
2
 
3
// Copyright (C) 2002 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 27 Nov 2002 
5
 
6
// covariant returns. Fixed & virtual offset.
7
 
8
struct B1;
9
struct B2;
10
struct D;
11
 
12
struct B1
13
{
14
  virtual B1 *foo1 () {return this;}
15
  virtual B2 *foo2 (D *);
16
};
17
 
18
struct B2
19
{
20
  virtual B2 *baz1 () {return this;}
21
  virtual B1 *baz2 (D *);
22
};
23
 
24
struct Pad1 { virtual ~Pad1 (){}};
25
struct Pad2 { virtual ~Pad2 (){}};
26
struct Proxy1 : Pad1, B1 {};
27
struct Proxy2 : Pad2, B2 {};
28
 
29
struct D : virtual Proxy1, virtual Proxy2
30
{
31
  virtual D *foo1 () {return this;}
32
  virtual D *foo2 (D *d) {return d;}
33
  virtual D *baz1 () {return this;}
34
  virtual D *baz2 (D *d) {return d;}
35
};
36
 
37
B2 *B1::foo2 (D *d) {return d;}
38
B1 *B2::baz2 (D *d) {return d;}
39
 
40
int test (B1 *b1, B2 *b2, D *d)
41
{
42
  if (b1->foo1 () != b1)
43
    return 1;
44
  if (b2->baz1 () != b2)
45
    return 2;
46
  if (b1->foo2 (d) != b2)
47
    return 3;
48
  if (b2->baz2 (d) != b1)
49
    return 4;
50
  return 0;
51
}
52
 
53
int test (D *d)
54
{
55
  if (d->foo2 (d) != d)
56
    return 11;
57
  if (d->baz2 (d) != d)
58
    return 12;
59
  if (d->foo1 () != d)
60
    return 13;
61
  if (d->baz1 () != d)
62
    return 14;
63
  return 0;
64
}
65
 
66
int main ()
67
{
68
  D d;
69
  int r;
70
 
71
  if ((r = test (&d, &d, &d)))
72
    return r;
73
  if ((r = test (&d)))
74
    return r;
75
  return 0;
76
}

powered by: WebSVN 2.1.0

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