1f08c3bdfSopenharmony_ciextern int fun(void); 2f08c3bdfSopenharmony_ciextern int arr[]; 3f08c3bdfSopenharmony_ciextern int var; 4f08c3bdfSopenharmony_ci 5f08c3bdfSopenharmony_ciint test_address(int arg, int ptr[]) 6f08c3bdfSopenharmony_ci{ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci if (fun()) return -1; 9f08c3bdfSopenharmony_ci if (var) return -1; 10f08c3bdfSopenharmony_ci if (arg) return -1; 11f08c3bdfSopenharmony_ci if (ptr) return -1; 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_cilab: 14f08c3bdfSopenharmony_ci if (arr) return 1; 15f08c3bdfSopenharmony_ci if (&arr) return 1; 16f08c3bdfSopenharmony_ci if (fun) return 1; 17f08c3bdfSopenharmony_ci if (&fun) return 1; 18f08c3bdfSopenharmony_ci if (*fun) return 1; 19f08c3bdfSopenharmony_ci if (&var) return 1; 20f08c3bdfSopenharmony_ci if (&arg) return 1; 21f08c3bdfSopenharmony_ci if (&&lab) return 1; 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci return -1; 24f08c3bdfSopenharmony_ci} 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ciint test_address_not(int arg, int ptr[]) 27f08c3bdfSopenharmony_ci{ 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci if (!fun()) return -1; 30f08c3bdfSopenharmony_ci if (!var) return -1; 31f08c3bdfSopenharmony_ci if (!arg) return -1; 32f08c3bdfSopenharmony_ci if (!ptr) return -1; 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_cilab: 35f08c3bdfSopenharmony_ci if (!arr) return 0; 36f08c3bdfSopenharmony_ci if (!&arr) return 0; 37f08c3bdfSopenharmony_ci if (!fun) return 0; 38f08c3bdfSopenharmony_ci if (!&fun) return 0; 39f08c3bdfSopenharmony_ci if (!*fun) return 0; 40f08c3bdfSopenharmony_ci if (!&var) return 0; 41f08c3bdfSopenharmony_ci if (!&arg) return 0; 42f08c3bdfSopenharmony_ci if (!&&lab) return 0; 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci return -1; 45f08c3bdfSopenharmony_ci} 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ciint test_address_cmp(int arg, int ptr[]) 48f08c3bdfSopenharmony_ci{ 49f08c3bdfSopenharmony_ci if (fun() == 0) return -1; 50f08c3bdfSopenharmony_ci if (0 == fun()) return -1; 51f08c3bdfSopenharmony_ci if (var == 0) return -1; 52f08c3bdfSopenharmony_ci if (0 == var) return -1; 53f08c3bdfSopenharmony_ci if (arg == 0) return -1; 54f08c3bdfSopenharmony_ci if (0 == arg) return -1; 55f08c3bdfSopenharmony_ci if (ptr == 0) return -1; 56f08c3bdfSopenharmony_ci if (0 == ptr) return -1; 57f08c3bdfSopenharmony_ci 58f08c3bdfSopenharmony_cilab: 59f08c3bdfSopenharmony_ci if (arr == 0) return 0; 60f08c3bdfSopenharmony_ci if (0 == arr) return 0; 61f08c3bdfSopenharmony_ci if (&arr == 0) return 0; 62f08c3bdfSopenharmony_ci if (0 == &arr) return 0; 63f08c3bdfSopenharmony_ci if (fun == 0) return 0; 64f08c3bdfSopenharmony_ci if (0 == fun) return 0; 65f08c3bdfSopenharmony_ci if (&fun == 0) return 0; 66f08c3bdfSopenharmony_ci if (0 == &fun) return 0; 67f08c3bdfSopenharmony_ci if (*fun == 0) return 0; 68f08c3bdfSopenharmony_ci if (0 == *fun) return 0; 69f08c3bdfSopenharmony_ci if (&var == 0) return 0; 70f08c3bdfSopenharmony_ci if (0 == &var) return 0; 71f08c3bdfSopenharmony_ci if (&arg == 0) return 0; 72f08c3bdfSopenharmony_ci if (0 == &arg) return 0; 73f08c3bdfSopenharmony_ci if (&&lab == 0) return 0; 74f08c3bdfSopenharmony_ci if (0 == &&lab) return 0; 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_ci return -1; 77f08c3bdfSopenharmony_ci} 78f08c3bdfSopenharmony_ci 79f08c3bdfSopenharmony_ci/* 80f08c3bdfSopenharmony_ci * check-name: Waddress 81f08c3bdfSopenharmony_ci * check-command: sparse -Wno-decl -Wno-non-pointer-null -Waddress $file 82f08c3bdfSopenharmony_ci * check-known-to-fail 83f08c3bdfSopenharmony_ci * 84f08c3bdfSopenharmony_ci * check-error-start 85f08c3bdfSopenharmony_ciWaddress.c:14:13: warning: the address of an array will always evaluate as true 86f08c3bdfSopenharmony_ciWaddress.c:15:14: warning: the address of an array will always evaluate as true 87f08c3bdfSopenharmony_ciWaddress.c:16:13: warning: the address of a function will always evaluate as true 88f08c3bdfSopenharmony_ciWaddress.c:17:14: warning: the address of a function will always evaluate as true 89f08c3bdfSopenharmony_ciWaddress.c:18:13: warning: the address of a variable will always evaluate as true 90f08c3bdfSopenharmony_ciWaddress.c:19:13: warning: the address of a variable will always evaluate as true 91f08c3bdfSopenharmony_ciWaddress.c:20:13: warning: the address of a label will always evaluate as true 92f08c3bdfSopenharmony_ciWaddress.c:34:13: warning: the address of an array will always evaluate as true 93f08c3bdfSopenharmony_ciWaddress.c:35:13: warning: the address of an array will always evaluate as true 94f08c3bdfSopenharmony_ciWaddress.c:36:13: warning: the address of a function will always evaluate as true 95f08c3bdfSopenharmony_ciWaddress.c:37:13: warning: the address of a function will always evaluate as true 96f08c3bdfSopenharmony_ciWaddress.c:38:13: warning: the address of a variable will always evaluate as true 97f08c3bdfSopenharmony_ciWaddress.c:39:13: warning: the address of a variable will always evaluate as true 98f08c3bdfSopenharmony_ciWaddress.c:40:13: warning: the address of a label will always evaluate as true 99f08c3bdfSopenharmony_ciWaddress.c:57:13: warning: the address of an array will always evaluate as true 100f08c3bdfSopenharmony_ciWaddress.c:58:13: warning: the address of an array will always evaluate as true 101f08c3bdfSopenharmony_ciWaddress.c:59:13: warning: the address of an array will always evaluate as true 102f08c3bdfSopenharmony_ciWaddress.c:60:13: warning: the address of an array will always evaluate as true 103f08c3bdfSopenharmony_ciWaddress.c:61:13: warning: the address of a function will always evaluate as true 104f08c3bdfSopenharmony_ciWaddress.c:62:13: warning: the address of a function will always evaluate as true 105f08c3bdfSopenharmony_ciWaddress.c:63:13: warning: the address of a function will always evaluate as true 106f08c3bdfSopenharmony_ciWaddress.c:64:13: warning: the address of a function will always evaluate as true 107f08c3bdfSopenharmony_ciWaddress.c:65:13: warning: the address of a variable will always evaluate as true 108f08c3bdfSopenharmony_ciWaddress.c:66:13: warning: the address of a variable will always evaluate as true 109f08c3bdfSopenharmony_ciWaddress.c:67:13: warning: the address of a variable will always evaluate as true 110f08c3bdfSopenharmony_ciWaddress.c:68:13: warning: the address of a variable will always evaluate as true 111f08c3bdfSopenharmony_ciWaddress.c:69:13: warning: the address of a label will always evaluate as true 112f08c3bdfSopenharmony_ciWaddress.c:70:13: warning: the address of a label will always evaluate as true 113f08c3bdfSopenharmony_ci * check-error-end 114f08c3bdfSopenharmony_ci */ 115