2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr40323.C
blobc7ffcb5d3f1b8bc7921300f66a40a8e951ea2952
1 /* Testcase for PR 40323.  */
2 /* { dg-do compile } */
3 /* { dg-options "-fno-early-inlining"  } */
4 /* { dg-add-options bind_pic_locally } */
6 extern void do_something (const char *, int);
8 class Parent
10 private:
11   const char *data;
13 public:
14   Parent (const char *d) : data(d)
15   {}
17   int funcOne (int delim) const;
20 class AnotherParent
22 private:
23   double d;
24 public:
25   AnotherParent (void) : d(0)
26   {}
30 class Child : public AnotherParent, Parent
32 private:
33   int zzz;
34 public:
35   Child (const char *d) : Parent(d)
36   {}
40 int Parent::funcOne (int delim) const
42   int i;
43   for (i = 0; i < delim; i++)
44     do_something(data, i);
46   return 1;
49 int docalling (int (Child::* f)(int delim) const)
51   Child S ("muhehehe");
53   return (S.*f)(4);
56 typedef int (Parent::* my_mp_type)(int delim);
58 int main (int argc, char *argv[])
60   int i;
61   int (Parent::* f)(int ) const;
62   int (Child::* g)(int ) const;
63   
64   f = &Parent::funcOne;
65   g = (int (Child::* )(int) const) f;
66   i = docalling (g);
67   return i;