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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [rtti/] [dyncast3.C] - Blame information for rev 318

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

Line No. Rev Author Line
1 301 jeremybenn
// This testcase used to crash while looking in A for my_module.  I'm still
2
// not sure it's well-formed, but it works now because of the optimization
3
// to look at the expected address first.
4
 
5
// { dg-do run }
6
 
7
extern "C" int puts (const char *);
8
extern "C" void abort ();
9
 
10
struct my_object
11
{
12
  my_object() { puts ("in my_object ctor");}
13
  virtual ~my_object() { puts ("in my_object dtor"); }
14
};
15
 
16
my_object* my_module_ptr = 0;
17
 
18
struct my_module : my_object
19
{
20
  my_module()
21
  {
22
    puts ("in my_module ctor, setting up ptr");
23
    my_module_ptr = this;
24
  }
25
  ~my_module() { puts ("in my_module dtor");}
26
};
27
 
28
struct D
29
{
30
  D() { puts ("in D ctor"); }
31
  virtual ~D();
32
};
33
 
34
D::~D()
35
{
36
  puts ("in D dtor");
37
  puts ("before DCASTing to my_module*");
38
  my_module* m = dynamic_cast(my_module_ptr);
39
  if (m != my_module_ptr)
40
    abort ();
41
  puts ("after DCASTing to my_module*");
42
}
43
 
44
struct my_interface
45
{
46
  my_interface() { puts ("in my_interface ctor");}
47
  ~my_interface() { puts ("in my_interface dtor");}
48
};
49
 
50
struct myif : virtual my_interface
51
{
52
  myif() { puts ("in myif ctor");}
53
  ~myif() { puts ("in myif dtor");}
54
};
55
 
56
struct A: virtual myif
57
{
58
  A() { puts ("in A ctor"); }
59
  ~A() { puts ("in A dtor"); }
60
 
61
  D d;
62
};
63
 
64
struct B: virtual myif
65
{
66
  B() { puts ("in B ctor"); }
67
  ~B() { puts ("in B dtor"); }
68
 
69
  D d;
70
};
71
 
72
struct C : my_module, A, B
73
{
74
  C() { puts ("in C ctor");}
75
  ~C() { puts ("in C dtor"); }
76
};
77
 
78
int main(int, char**)
79
{
80
  C t;
81
}

powered by: WebSVN 2.1.0

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