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