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/] [covariant2.C] - Blame information for rev 338

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 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
struct B2
18
{
19
  virtual B2 *baz1 () {return this;}
20
  virtual B1 *baz2 (D *);
21
};
22
 
23
struct D : B1, B2
24
{
25
  virtual D *foo1 () {return this;}
26
  virtual D *foo2 (D *d) {return d;}
27
  virtual D *baz1 () {return this;}
28
  virtual D *baz2 (D *d) {return d;}
29
};
30
 
31
B2 *B1::foo2 (D *d) {return d;}
32
B1 *B2::baz2 (D *d) {return d;}
33
 
34
int test (B1 *b1, B2 *b2, D *d)
35
{
36
  if (b1->foo1 () != b1)
37
    return 1;
38
  if (b2->baz1 () != b2)
39
    return 2;
40
  if (b1->foo2 (d) != b2)
41
    return 3;
42
  if (b2->baz2 (d) != b1)
43
    return 4;
44
  return 0;
45
}
46
 
47
int test (D *d)
48
{
49
  if (d->foo2 (d) != d)
50
    return 11;
51
  if (d->baz2 (d) != d)
52
    return 12;
53
  if (d->foo1 () != d)
54
    return 13;
55
  if (d->baz1 () != d)
56
    return 14;
57
  return 0;
58
}
59
 
60
int main ()
61
{
62
  D d;
63
  int r;
64
 
65
  if ((r = test (&d, &d, &d)))
66
    return r;
67
  if ((r = test (&d)))
68
    return r;
69
  return 0;
70
}

powered by: WebSVN 2.1.0

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