| 1 |
// Check that indirect calls to thunks do not lead to errors. |
| 2 |
// { dg-do run } |
| 3 |
// { dg-options "-O -finline -finline-small-functions -finline-functions" } |
| 4 |
|
| 5 |
|
| 6 |
extern "C" void abort (); |
| 7 |
|
| 8 |
class A |
| 9 |
{ |
| 10 |
public: |
| 11 |
virtual void foo () {abort();} |
| 12 |
}; |
| 13 |
|
| 14 |
class B : public A |
| 15 |
{ |
| 16 |
public: |
| 17 |
int z; |
| 18 |
virtual void foo () {abort();} |
| 19 |
}; |
| 20 |
|
| 21 |
class C : public A |
| 22 |
{ |
| 23 |
public: |
| 24 |
void *a[32]; |
| 25 |
unsigned long b; |
| 26 |
long c[32]; |
| 27 |
|
| 28 |
virtual void foo () {abort();} |
| 29 |
}; |
| 30 |
|
| 31 |
class D : public C, public B |
| 32 |
{ |
| 33 |
public: |
| 34 |
D () : C(), B() |
| 35 |
{ |
| 36 |
int i; |
| 37 |
for (i = 0; i < 32; i++) |
| 38 |
{ |
| 39 |
a[i] = (void *) 0; |
| 40 |
c[i] = 0; |
| 41 |
} |
| 42 |
b = 0xaaaa; |
| 43 |
} |
| 44 |
|
| 45 |
virtual void foo (); |
| 46 |
}; |
| 47 |
|
| 48 |
void D::foo() |
| 49 |
{ |
| 50 |
if (b != 0xaaaa) |
| 51 |
abort(); |
| 52 |
} |
| 53 |
|
| 54 |
static inline void bar (B &b) |
| 55 |
{ |
| 56 |
|
| 57 |
b.foo (); |
| 58 |
} |
| 59 |
|
| 60 |
int main() |
| 61 |
{ |
| 62 |
int i; |
| 63 |
D d; |
| 64 |
|
| 65 |
for (i = 0; i < 5000; i++) |
| 66 |
bar (d); |
| 67 |
return 0; |
| 68 |
} |