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