| 1 |
// { dg-do run { target i?86-*-* x86_64-*-* } } |
| 2 |
// { dg-require-effective-target ilp32 } |
| 3 |
// { dg-require-effective-target fpic } |
| 4 |
// { dg-options "-mtune=generic -O2 -fpic" } |
| 5 |
class G {}; |
| 6 |
|
| 7 |
struct N { |
| 8 |
N *a; |
| 9 |
}; |
| 10 |
|
| 11 |
struct V { |
| 12 |
typedef N *W; |
| 13 |
W *m, *n; |
| 14 |
int s() const { return int(n - m); } |
| 15 |
const W &operator[](int x) const { return *(m + x); } |
| 16 |
}; |
| 17 |
|
| 18 |
struct H; |
| 19 |
|
| 20 |
struct J { |
| 21 |
N *c; |
| 22 |
H *d; |
| 23 |
J(N *x, H *y) : c(x), d(y) {} |
| 24 |
}; |
| 25 |
|
| 26 |
struct K { |
| 27 |
const N *c; |
| 28 |
const H *d; |
| 29 |
K(const N *x, const H *y) : c(x), d(y) {} |
| 30 |
K(const J &x) : c(x.c), d(x.d) {} |
| 31 |
}; |
| 32 |
|
| 33 |
struct H { |
| 34 |
V e; |
| 35 |
int f; |
| 36 |
|
| 37 |
J u() |
| 38 |
{ |
| 39 |
for (int x = 0; x < e.s(); ++x) |
| 40 |
if (e[x]) |
| 41 |
return J(e[x], this); |
| 42 |
return v(); |
| 43 |
} |
| 44 |
J v() { return J((N*)64, this); } |
| 45 |
}; |
| 46 |
|
| 47 |
struct I { |
| 48 |
H d; |
| 49 |
J u() { return d.u(); } |
| 50 |
J v() { return d.v(); } |
| 51 |
}; |
| 52 |
|
| 53 |
struct bar { |
| 54 |
virtual ~bar() {} |
| 55 |
}; |
| 56 |
|
| 57 |
struct E { |
| 58 |
K g; |
| 59 |
E(K x) : g(x) {} |
| 60 |
}; |
| 61 |
|
| 62 |
struct foo : public bar { |
| 63 |
K h; |
| 64 |
E i; |
| 65 |
foo(const K x, const E &y) : h(x), i(y) {} |
| 66 |
}; |
| 67 |
|
| 68 |
struct A { |
| 69 |
I *l; |
| 70 |
foo *baz() const; |
| 71 |
}; |
| 72 |
|
| 73 |
foo *A::baz() const |
| 74 |
{ |
| 75 |
return new foo(l->u(), E(l->v())); |
| 76 |
} |
| 77 |
|
| 78 |
A x; |
| 79 |
I i; |
| 80 |
foo *f; |
| 81 |
|
| 82 |
int main () |
| 83 |
{ |
| 84 |
x.l = &i; |
| 85 |
f = x.baz(); |
| 86 |
if (f->h.c != f->i.g.c || f->h.d != f->i.g.d) |
| 87 |
return 1; |
| 88 |
return 0; |
| 89 |
} |