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-2.C] - Blame information for rev 693

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 -fdump-ipa-cp -fdump-tree-optimized"  } */
5
 
6
extern "C" void abort (void);
7
 
8
class Distraction
9
{
10
public:
11
  float f;
12
  double d;
13
  Distraction ()
14
  {
15
    f = 8.3;
16
    d = 10.2;
17
  }
18
  virtual float bar (float z);
19
};
20
 
21
class A
22
{
23
public:
24
  int data;
25
  A();
26
  virtual int foo (int i);
27
};
28
 
29
class B : public Distraction, public A
30
{
31
public:
32
  virtual int foo (int i);
33
};
34
 
35
float Distraction::bar (float z)
36
{
37
  f += z;
38
  return f/2;
39
}
40
 
41
int A::foo (int i)
42
{
43
  return i + 1;
44
}
45
 
46
int B::foo (int i)
47
{
48
  return i + 2;
49
}
50
 
51
int __attribute__ ((noinline,noclone)) get_input(void)
52
{
53
  return 1;
54
}
55
 
56
static int middleman (class A *obj, int i)
57
{
58
  return obj->foo (i);
59
}
60
 
61
A::A()
62
{
63
  if (middleman (this, get_input ()) != 2)
64
    abort ();
65
}
66
 
67
static void bah ()
68
{
69
  class B 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
}
80
 
81
/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*A::foo"  "cp"  } } */
82
/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
83
/* { dg-final { cleanup-ipa-dump "cp" } } */
84
/* { 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.