1// PR c++/27894
2// { dg-do compile }
3// { dg-options "-O" }
4
5class A;
6struct B
7{
8  B (unsigned long);
9  int b2 () const;
10  A *b1 () const;
11};
12
13enum { P = 0 };
14enum O { Q = 75, };
15class C;
16struct D { A *d; };
17struct E
18{
19  B e1 (int) const;
20  A *e2 (const B &) const;
21  D e3[4096];
22};
23
24inline A *
25E::e2 (const B & x) const
26{
27  const D *w = &e3[x.b2 ()];
28  return (A *) w->d;
29}
30
31extern E *e;
32
33inline A *
34B::b1 () const
35{
36  extern E *e;
37  return e->e2 (*this);
38}
39
40template <class T> struct F : public B
41{
42  F (const B &);
43  T *b1 () const;
44};
45
46template < class T > inline T * F <T>::b1 () const
47{
48  return (T *) B::b1 ();
49};
50
51typedef F <C> N;
52
53class G {};
54class H : public G {};
55class I : public H {};
56class J {};
57class K {};
58struct L
59{
60  void l (J *, C *, int, const char *, O);
61};
62class M : public K, public I
63{
64  void m (J &, int, const char *);
65  void m (J &, int, int, const char *, float);
66};
67
68void
69M::m (J &x, int y, const char *z)
70{
71  L *w = new L;
72  N v = e->e1 (y);
73  w->l (&x, v.b1 (), P, z, Q);
74}
75
76void
77M::m (J &x, int y, int s, const char *z, float t)
78{
79  L *w = new L;
80  N v = e->e1 (y);
81  w->l (&x, v.b1 (), s, z, (O) (int) ((t) ? (50 + 20 / (float) t) : 0));
82}
83