1// PR debug/48967
2// { dg-do compile }
3// { dg-options "-g -O2" }
4
5template <typename> struct A;
6template <typename T> struct A <T *>
7{
8  typedef T ref;
9};
10template <typename T, typename> struct B
11{
12  typedef A <T> t;
13  typedef typename t::ref ref;
14  ref operator * () { return ref (); }
15};
16template <typename T> struct I
17{
18  typedef T *cp;
19  template <typename T1> struct J
20  {
21    typedef I <T1> other;
22  };
23};
24template <typename T> struct S : public I <T>
25{
26};
27template <typename T, typename _A> struct E
28{
29  typedef typename _A::template J <T>::other at;
30};
31template <typename T, typename _A = S <T> > struct D
32{
33  typedef E <T, _A> _Base;
34  typedef typename _Base::at at;
35  typedef typename at::cp cp;
36  typedef B <cp, D> H;
37};
38template <class T> struct F
39{
40  T *operator -> () { return __null; }
41};
42template <typename T> long
43lfloor (T x)
44{
45  return static_cast <long>(x) - (x && x != static_cast <long>(x));
46}
47template <typename T> long
48lround (T x)
49{
50  return lfloor (x - 0.5) + 1;
51}
52class M;
53template <typename> class P;
54typedef P <M> Q;
55template <typename> struct P
56{
57  float x ();
58};
59struct CV
60{
61  Q c;
62};
63struct C
64{
65  void foo (const CV &) const;
66  class O;
67  typedef D <F <O> > R;
68  R n;
69};
70struct S3
71{
72  S3 (int, int);
73};
74struct S2
75{
76  S3 sx, sy;
77  S2 (int x = 0, int y = 0, int s = 0, int t = 0) : sx (x, y), sy (s, t) {}
78};
79template <typename> struct N
80{
81  int bar ();
82};
83struct C::O
84{
85  N <float> o;
86  void foo (CV r, int)
87  {
88    Q c = r.c;
89    float t = 0.5 * (o.bar ());
90    S2 (lround (c.x ()), t);
91  }
92};
93void
94C::foo (const CV &w) const
95{
96  R::H m;
97  (*m)->foo (w, 8);
98}
99