------- Comment #6 from hjl dot tools at gmail dot com  2009-06-24 19:31 -------
(In reply to comment #5)
> What do you do if the function has arguments, because ifunc shouldn't have
> arguments?  While C++ has unnamed arguments and you could perhaps enforce 
> them,

For unnamed arguments, see ifunc-1.c in

http://gcc.gnu.org/bugzilla/attachment.cgi?id=18060


> C does not.  How do you handle option 3 with:
> __attribute__((ifunc)) int
> foo (int a, int b)
> {
>   if (a) return foo_1;
>   if (b) return foo_2;
>   return foo_3;
> }
> ?
> 

[...@gnu-6 examples]$ cat x.c
int foo_1 (int, int);
int foo_2 (int, int);
int foo_3 (int, int);

__attribute__((ifunc)) int
foo (int a, int b)
{
  if (a) return foo_1;
  if (b) return foo_2;
  return foo_3;
}
[...@gnu-6 examples]$ make x.s
/export/build/gnu/gcc-work/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-work/build-x86_64-linux/gcc/ -S -o x.s -O2 -Wall
-Wextra x.c
x.c: In function ‘foo’:
x.c:6:1: error: parameter ‘a’ used in indirect function ‘foo’
x.c:6:1: error: parameter ‘b’ used in indirect function ‘foo’
make: *** [x.s] Error 1
[...@gnu-6 examples]$ 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40528

Reply via email to