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)11bar (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)21zero (int x) 22 { 23 return 0; 24 } 25 26 static int addone(int x)27addone (int x) 28 { 29 return x + 1; 30 } 31 32 static int sq(int x)33sq (int x) 34 { 35 return x * x; 36 } 37 38 static int cube(int x)39cube (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)47g (int x) 48 { 49 return bar (&a, x); 50 } 51 52 int obfuscate(int x)53obfuscate (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