1/* Verify that we do not indirect-inline using member pointer
2   parameters which have been modified.  */
3/* { dg-do run } */
4/* { dg-options "-O3 -fno-early-inlining"  } */
5/* { dg-add-options bind_pic_locally } */
6
7extern "C" void abort (void);
8
9class String
10{
11private:
12  const char *data;
13
14public:
15  String (const char *d) : data(d)
16  {}
17
18  int funcOne (int stuff) const;
19  int funcTwo (int stuff) const;
20};
21
22
23int String::funcOne (int stuff) const
24{
25  return stuff + 1;
26}
27
28int String::funcTwo (int stuff) const
29{
30  return stuff + 100;
31}
32
33int (String::* gmp)(int stuff) const = &String::funcTwo;
34
35int docalling_1 (int (String::* f)(int stuff) const)
36{
37  String S ("muhehehe");
38
39  return (S.*f)(4);
40}
41
42int docalling (int a, int (String::* f)(int stuff) const)
43{
44  if (a < 200)
45    f = gmp;
46
47  return docalling_1 (f);
48}
49
50int __attribute__ ((noinline,noclone)) get_input (void)
51{
52  return 1;
53}
54
55int main (int argc, char *argv[])
56{
57  int i = 0;
58  while (i < 10)
59    i += docalling (get_input (), &String::funcOne);
60
61  if (i != 104)
62    abort();
63  return 0;
64}
65