| 1 |
// PR target/93187 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-O2" } |
| 4 |
// { dg-additional-options "-fstack-protector-strong" { target fstack_protector } } |
| 5 |
// { dg-additional-options "-fpie" { target pie } } |
| 6 |
|
| 7 |
struct A; |
| 8 |
struct B; |
| 9 |
struct C { int operator () (B, const B &); }; |
| 10 |
struct D { typedef int *d; }; |
| 11 |
struct E { C g; }; |
| 12 |
struct F { F (D::d); friend bool operator==(F &, const int &); }; |
| 13 |
template <typename T, typename> struct H { |
| 14 |
typedef D *I; |
| 15 |
E l; |
| 16 |
I foo (); |
| 17 |
T t; |
| 18 |
F bar (I, const T &); |
| 19 |
F baz (const T &); |
| 20 |
}; |
| 21 |
template <typename T, typename U> |
| 22 |
F |
| 23 |
H<T, U>::bar (I n, const T &o) |
| 24 |
{ |
| 25 |
while (n) |
| 26 |
if (l.g (t, o)) |
| 27 |
n = 0; |
| 28 |
return 0; |
| 29 |
} |
| 30 |
template <typename T, typename U> |
| 31 |
F |
| 32 |
H<T, U>::baz (const T &n) |
| 33 |
{ |
| 34 |
D *r = foo (); |
| 35 |
F p = bar (r, n); |
| 36 |
return p == 0 ? 0 : p; |
| 37 |
} |
| 38 |
template <typename, typename U> struct J { |
| 39 |
H<B, U> h; |
| 40 |
B &q; |
| 41 |
void baz () { h.baz (q); } |
| 42 |
}; |
| 43 |
enum K { L }; |
| 44 |
template <typename, K = L> struct M; |
| 45 |
template <int> struct G { |
| 46 |
using N = J<int, A>; |
| 47 |
N *operator->(); |
| 48 |
}; |
| 49 |
template <typename, K T> struct M : public G<T> { |
| 50 |
using N = J<int, A>; |
| 51 |
N *foo () { return n; } |
| 52 |
N *n; |
| 53 |
int o; |
| 54 |
}; |
| 55 |
template <int N> |
| 56 |
inline typename G<N>::N * |
| 57 |
G<N>::operator-> () |
| 58 |
{ |
| 59 |
N *n = static_cast<M<J<int, A>> *>(this)->foo (); |
| 60 |
return n; |
| 61 |
} |
| 62 |
struct B { bool qux (); }; |
| 63 |
struct O { |
| 64 |
struct P { M<int> p; }; |
| 65 |
static thread_local P o; |
| 66 |
int baz () const; |
| 67 |
}; |
| 68 |
thread_local O::P O::o; |
| 69 |
B be; |
| 70 |
int |
| 71 |
O::baz () const |
| 72 |
{ |
| 73 |
do |
| 74 |
o.p->baz (); |
| 75 |
while (be.qux ()); |
| 76 |
__builtin_unreachable (); |
| 77 |
} |