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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [inherit/] [covariant17.C] - Blame information for rev 750

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

Line No. Rev Author Line
1 693 jeremybenn
// PR c++/43120
2
// { dg-do run }
3
 
4
extern "C" void abort ();
5
 
6
struct A {
7
  int a;
8
 
9
  A(int a_) : a(a_) {}
10
 
11
  A(const A &other) { }
12
 
13
  virtual void dummy() {}
14
};
15
 
16
struct B {
17
  virtual B *clone() const = 0;
18
};
19
 
20
struct C : public virtual B {
21
  virtual C *clone() const = 0;
22
};
23
 
24
struct E* ep;
25
struct E : public A, public C {
26
  E(int a_) : A(a_) { ep = this; }
27
 
28
  virtual E *clone() const {
29
    if (this != ep)
30
      abort();
31
    return 0;
32
  }
33
};
34
 
35
int main() {
36
  E *a = new E(123);
37
  C *c = a;
38
  B *b = a;
39
  c->clone();
40
  b->clone();
41
  delete a;
42
  return 0;
43
}

powered by: WebSVN 2.1.0

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