1 typedef int  (*binop_t)(int, int);
   2 typedef int  (*unop_t)(int);
   3 typedef int  (*idef_t)(void);
   4 typedef long (*ldef_t)(void);
   5 typedef void (*use_t)(int);
   6 
   7 // We want to 'fn' have several different types.
   8 // The goal is for the ->priv member to be used
   9 // with a type different from what it was first stored.
  10 
  11 int foo(void *fn, int arg1, int arg2);
  12 int foo(void *fn, int arg1, int arg2)
  13 {
  14         int res = 0;
  15 
  16         res += ((binop_t)fn)(arg1, arg2);
  17         res += ((unop_t)fn)(arg1);
  18         res += ((ldef_t)fn)();
  19         res += ((idef_t)fn)();
  20         ((use_t)fn)(res);
  21         return res;
  22 }
  23 
  24 int bar(int (*fn)(int), int arg1, int arg2);
  25 int bar(int (*fn)(int), int arg1, int arg2)
  26 {
  27         int res = 0;
  28 
  29         res += ((binop_t)fn)(arg1, arg2);
  30         res += fn(arg1);
  31         return res;
  32 }
  33 
  34 /*
  35  * check-name: mutate function pointer's type
  36  * check-command: sparsec -c $file -o tmp.o
  37  */