2014-11-20 18:48:47 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern int foo(void);
|
|
|
|
extern int bar(void);
|
|
|
|
|
2014-11-20 19:29:45 +00:00
|
|
|
typedef int (*func_p) (void);
|
|
|
|
|
|
|
|
func_p foo_ptr = foo;
|
|
|
|
|
|
|
|
func_p
|
|
|
|
__attribute__((noinline))
|
|
|
|
get_bar (void)
|
|
|
|
{
|
|
|
|
return bar;
|
|
|
|
}
|
2014-11-20 18:48:47 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
2014-11-20 19:29:45 +00:00
|
|
|
func_p bar_ptr = get_bar ();
|
2014-11-20 18:48:47 +00:00
|
|
|
if (bar_ptr != bar)
|
|
|
|
__builtin_abort ();
|
|
|
|
if (bar_ptr() != -1)
|
|
|
|
__builtin_abort ();
|
|
|
|
if (bar() != -1)
|
|
|
|
__builtin_abort ();
|
|
|
|
|
|
|
|
if (foo_ptr != foo)
|
|
|
|
__builtin_abort ();
|
|
|
|
if (foo_ptr() != 1)
|
|
|
|
__builtin_abort ();
|
|
|
|
if (foo() != 1)
|
|
|
|
__builtin_abort ();
|
|
|
|
|
|
|
|
printf ("OK\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|