| 1 |
// PR tree-optimization/98282 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-O2" } |
| 4 |
|
| 5 |
template <typename> struct g; |
| 6 |
template <typename b> struct g<b &> { typedef b c; }; |
| 7 |
template <typename b> typename g<b>::c &&d(b &&e) { |
| 8 |
return static_cast<typename g<b>::c &&>(e); |
| 9 |
} |
| 10 |
void *operator new(__SIZE_TYPE__, void *f) { return f; } |
| 11 |
struct h; |
| 12 |
struct k { |
| 13 |
using i = h *; |
| 14 |
}; |
| 15 |
struct D { |
| 16 |
k::i j; |
| 17 |
}; |
| 18 |
struct p : D { |
| 19 |
p(p &&) : D() {} |
| 20 |
}; |
| 21 |
struct r { |
| 22 |
using l = int; |
| 23 |
r(r &&) : ad() {} |
| 24 |
l *ad; |
| 25 |
}; |
| 26 |
struct s { |
| 27 |
static s m(); |
| 28 |
}; |
| 29 |
struct t { |
| 30 |
template <typename ah> void operator=(ah); |
| 31 |
}; |
| 32 |
struct I { |
| 33 |
template <typename o> void q(o ai) { |
| 34 |
*ai = aj(); |
| 35 |
s::m(); |
| 36 |
} |
| 37 |
h aj(); |
| 38 |
}; |
| 39 |
template <typename...> class as; |
| 40 |
struct J { |
| 41 |
int a; |
| 42 |
char av; |
| 43 |
}; |
| 44 |
template <typename...> struct aw : J { |
| 45 |
void ax(...) {} |
| 46 |
}; |
| 47 |
template <typename... ay, typename an, typename... n> |
| 48 |
struct aw<as<ay...>, an, n...> : aw<as<ay...>, n...> { |
| 49 |
using az = as<ay...>; |
| 50 |
using ba = aw<az, n...>; |
| 51 |
char bb; |
| 52 |
an &bc() { return *reinterpret_cast<an *>(this); } |
| 53 |
void ax(az *bd) { |
| 54 |
if (bb) |
| 55 |
new (bd) an(d(bc())); |
| 56 |
ba::ax(bd); |
| 57 |
} |
| 58 |
}; |
| 59 |
template <typename... n> struct as : aw<as<n...>, n...> { |
| 60 |
as(); |
| 61 |
as(as &&be) { be.ax(this); } |
| 62 |
void operator=(as be) { be.ax(this); } |
| 63 |
}; |
| 64 |
struct h { |
| 65 |
as<decltype(nullptr), r, p> bg; |
| 66 |
}; |
| 67 |
using bh = t; |
| 68 |
struct u { |
| 69 |
bh bj; |
| 70 |
}; |
| 71 |
I bk(); |
| 72 |
template <typename> void bl() { |
| 73 |
h a; |
| 74 |
bk().q(&a); |
| 75 |
} |
| 76 |
template <typename> void bn(int) { |
| 77 |
u b; |
| 78 |
b.bj = bl<int>; |
| 79 |
} |
| 80 |
void bp() { bn<int>(0); } |