• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 extern int fun(void);
2 extern int (*ptr)(void);
3 
inl(int * a)4 static inline int inl(int *a)
5 {
6 	return *a + 1;
7 }
8 
9 
10 int test(void);
test(void)11 int test(void)
12 {
13 	unsigned int s = 0;
14 
15 	// OK
16 	s += sizeof &fun;
17 	s += sizeof  ptr;
18 	s += sizeof &ptr;
19 	s += sizeof &inl;
20 
21 	// KO
22 	s += sizeof  fun;
23 	s += sizeof *fun;
24 
25 	s += sizeof *ptr;
26 
27 	s += sizeof  inl;
28 	s += sizeof *inl;
29 
30 	s += sizeof  __builtin_trap;
31 	s += sizeof *__builtin_trap;
32 
33 	return s;
34 }
35 
36 /*
37  * check-name: sizeof-function
38  * check-command: sparse -Wpointer-arith -Wno-decl $file
39  *
40  * check-error-start
41 sizeof-function.c:22:14: warning: expression using sizeof on a function
42 sizeof-function.c:23:14: warning: expression using sizeof on a function
43 sizeof-function.c:25:14: warning: expression using sizeof on a function
44 sizeof-function.c:27:14: warning: expression using sizeof on a function
45 sizeof-function.c:28:14: warning: expression using sizeof on a function
46 sizeof-function.c:30:14: warning: expression using sizeof on a function
47 sizeof-function.c:31:14: warning: expression using sizeof on a function
48  * check-error-end
49  */
50