1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fdump-ipa-cp-details" } */
3 
4 #define N 4
5 
6 typedef int (* const A[N])(int);
7 
8 extern const A *ga;
9 
10 static int  __attribute__((noinline))
bar(const A * f,int x)11 bar (const A *f, int x)
12 {
13   x = (*f)[2](x);
14   x = (*f)[2](x);
15   x = (*f)[2](x);
16   ga = f;
17   return x;
18 }
19 
20 static int
zero(int x)21 zero (int x)
22 {
23   return 0;
24 }
25 
26 static int
addone(int x)27 addone (int x)
28 {
29   return x + 1;
30 }
31 
32 static int
sq(int x)33 sq (int x)
34 {
35   return x * x;
36 }
37 
38 static int
cube(int x)39 cube (int x)
40 {
41   return x * x * x;
42 }
43 
44 static const A a = {zero, addone, sq, cube};
45 
46 int
g(int x)47 g (int x)
48 {
49   return bar (&a, x);
50 }
51 
52 int
obfuscate(int x)53 obfuscate (int x)
54 {
55   return bar ((A *) 0, x);
56 }
57 
58 /* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" } } */
59