2014-11-21 02:48:47 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern int foo(void);
|
|
|
|
extern int bar(void);
|
|
|
|
|
2014-11-21 03:29:45 +08:00
|
|
|
typedef int (*func_p) (void);
|
|
|
|
|
|
|
|
func_p foo_ptr = foo;
|
|
|
|
|
|
|
|
func_p
|
|
|
|
__attribute__((noinline))
|
|
|
|
get_bar (void)
|
|
|
|
{
|
|
|
|
return bar;
|
|
|
|
}
|
2014-11-21 02:48:47 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
2014-11-21 03:29:45 +08:00
|
|
|
func_p bar_ptr = get_bar ();
|
2014-11-21 02:48:47 +08: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;
|
|
|
|
}
|