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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [ipa/] [devirt-c-5.C] - Blame information for rev 715

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

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that ipa-cp correctly detects the dynamic type of an object
2
   under construction when doing devirtualization.  */
3
/* { dg-do run } */
4
/* { dg-options "-O3 -fno-early-inlining -fno-inline"  } */
5
 
6
extern "C" void abort (void);
7
 
8
class B;
9
 
10
class A
11
{
12
public:
13
  int data;
14
  A();
15
  A(B *b);
16
  virtual int foo (int i);
17
};
18
 
19
class B : public A
20
{
21
public:
22
  virtual int foo (int i);
23
};
24
 
25
class C : public A
26
{
27
public:
28
  virtual int foo (int i);
29
};
30
 
31
int A::foo (int i)
32
{
33
  return i + 1;
34
}
35
 
36
int B::foo (int i)
37
{
38
  return i + 2;
39
}
40
 
41
int C::foo (int i)
42
{
43
  return i + 3;
44
}
45
 
46
static int middleman (class A *obj, int i)
47
{
48
  return obj->foo (i);
49
}
50
 
51
int __attribute__ ((noinline,noclone)) get_input(void)
52
{
53
  return 1;
54
}
55
 
56
A::A ()
57
{
58
}
59
 
60
A::A (B *b)
61
{
62
  if (middleman (b, get_input ()) != 3)
63
    abort ();
64
}
65
 
66
static void bah ()
67
{
68
  B b;
69
  A a(&b);
70
}
71
 
72
int main (int argc, char *argv[])
73
{
74
  int i;
75
 
76
  for (i = 0; i < 10; i++)
77
    bah ();
78
  return 0;
79
}

powered by: WebSVN 2.1.0

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