xref: /illumos-gate/usr/src/tools/smatch/src/validation/linear/call-casted-pointer.c (revision d2f7972d81337947df76c36b8c2a5f290829fa7a)
1 typedef int (*fun_t)(void*);
2 
3 int foo(void *a, void *fun)
4 {
5 	return ((fun_t)fun)(a);
6 }
7 
8 int bar(void *a, void *fun)
9 {
10 	return ((int (*)(void *))fun)(a);
11 }
12 
13 int qux(void *a, void *fun)
14 {
15 	return (*(fun_t)fun)(a);
16 }
17 
18 int quz(void *a, void *fun)
19 {
20 	return (*(int (*)(void *))fun)(a);
21 }
22 
23 /*
24  * check-name: call via casted function pointer
25  * check-command: test-linearize -Wno-decl $file
26  *
27  * check-output-ignore
28  * check-output-excludes: load
29  * check-output-pattern(4): ptrcast\\..* %arg2
30  * check-output-pattern(4): call\\..* %arg1
31  */
32