Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr81128.c
blob90a567ad690dc4d670fa3347404495e8f5f5b013
1 /* PR ipa/81128 */
2 /* { dg-do run } */
3 /* { dg-options "-O3" } */
4 /* { dg-require-ifunc "" } */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <time.h>
11 int resolver_fn = 0;
12 int resolved_fn = 0;
14 static inline void
15 do_it_right_at_runtime_A ()
17 resolved_fn++;
20 static inline void
21 do_it_right_at_runtime_B ()
23 resolved_fn++;
26 static inline void do_it_right_at_runtime (void);
28 void do_it_right_at_runtime (void)
29 __attribute__ ((ifunc ("resolve_do_it_right_at_runtime")));
31 static void (*resolve_do_it_right_at_runtime (void)) (void)
33 srand (time (NULL));
34 int r = rand ();
35 resolver_fn++;
37 /* Use intermediate variable to get a warning for non-matching
38 * prototype. */
39 typeof(do_it_right_at_runtime) *func;
40 if (r & 1)
41 func = do_it_right_at_runtime_A;
42 else
43 func = do_it_right_at_runtime_B;
45 return (void *) func;
48 int
49 main (void)
51 const unsigned int ITERS = 10;
53 for (int i = ITERS; i > 0; i--)
55 do_it_right_at_runtime ();
58 if (resolver_fn != 1)
59 __builtin_abort ();
61 if (resolved_fn != 10)
62 __builtin_abort ();
64 return 0;