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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that ipa-cp can convert simple virtual calls to a direct
2
   ones even when a typecast to an ancestor is involved along the way
3
   and that ancestor is not the first one with virtual functions.  */
4
/* { dg-do run } */
5
/* { dg-options "-O3 -fno-early-inlining -fno-inline -fdump-ipa-cp -fdump-tree-optimized"  } */
6
 
7
extern "C" void abort (void);
8
 
9
class Distraction
10
{
11
public:
12
  float f;
13
  double d;
14
  Distraction ()
15
  {
16
    f = 8.3;
17
    d = 10.2;
18
  }
19
  virtual float bar (float z);
20
};
21
 
22
class A
23
{
24
public:
25
  int data;
26
  virtual int foo (int i);
27
};
28
 
29
 
30
class B : public Distraction, public A
31
{
32
public:
33
  virtual int foo (int i);
34
};
35
 
36
float Distraction::bar (float z)
37
{
38
  f += z;
39
  return f/2;
40
}
41
 
42
int A::foo (int i)
43
{
44
  return i + 1;
45
}
46
 
47
int B::foo (int i)
48
{
49
  return i + 2;
50
}
51
 
52
int __attribute__ ((noinline,noclone)) get_input(void)
53
{
54
  return 1;
55
}
56
 
57
static int middleman_1 (class A *obj, int i)
58
{
59
  return obj->foo (i);
60
}
61
 
62
static int middleman_2 (class B *obj, int i)
63
{
64
  return middleman_1 (obj, i);
65
}
66
 
67
int main (int argc, char *argv[])
68
{
69
  class B b;
70
 
71
  if (middleman_2 (&b, get_input ()) != 3)
72
    abort ();
73
  return 0;
74
}
75
 
76
/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */
77
/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
78
/* { dg-final { cleanup-ipa-dump "cp" } } */
79
/* { dg-final { cleanup-tree-dump "optimized" } } */

powered by: WebSVN 2.1.0

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