diff options
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/builtin-arith.c | 31 | ||||
| -rw-r--r-- | validation/builtin-atomic-clear.c | 15 | ||||
| -rw-r--r-- | validation/builtin-sync-fetch.c | 24 | ||||
| -rw-r--r-- | validation/crash-undef-in-parens.c | 9 | ||||
| -rw-r--r-- | validation/flex-array-align.c | 18 | ||||
| -rw-r--r-- | validation/flex-array-array.c | 15 | ||||
| -rw-r--r-- | validation/flex-array-error.c | 26 | ||||
| -rw-r--r-- | validation/flex-array-nested.c | 29 | ||||
| -rw-r--r-- | validation/flex-array-sizeof.c | 18 | ||||
| -rw-r--r-- | validation/flex-array-union-array-no.c | 9 | ||||
| -rw-r--r-- | validation/flex-array-union-array-yes.c | 11 | ||||
| -rw-r--r-- | validation/flex-array-union-array.h | 11 | ||||
| -rw-r--r-- | validation/linear/bool-cast-lp32.c | 1 | ||||
| -rw-r--r-- | validation/optim/canonical-mul.c | 2 | ||||
| -rw-r--r-- | validation/usual-conv-lp32.c | 11 |
15 files changed, 215 insertions, 15 deletions
diff --git a/validation/builtin-arith.c b/validation/builtin-arith.c index d08c93da..3ce59304 100644 --- a/validation/builtin-arith.c +++ b/validation/builtin-arith.c @@ -31,22 +31,27 @@ void test(void (*fun)(void)) /* * check-name: builtin arithmetic * check-command: sparse -Wno-decl $file - * check-known-to-fail * * check-error-start -builtin-arith.c:10:xx: error: ... -builtin-arith.c:11:xx: error: ... -builtin-arith.c:13:xx: error: arithmetics on pointers to functions -builtin-arith.c:14:xx: error: arithmetics on pointers to functions -builtin-arith.c:15:xx: error: arithmetics on pointers to functions -builtin-arith.c:18:xx: error: ... -builtin-arith.c:19:xx: error: ... -builtin-arith.c:21:xx: error: ... -builtin-arith.c:22:xx: error: ... -builtin-arith.c:23:xx: error: ... -builtin-arith.c:24:xx: error: ... -builtin-arith.c:25:xx: error: ... +builtin-arith.c:10:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:11:13: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:12:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:13:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:13:29: error: arithmetics on pointers to functions +builtin-arith.c:14:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:14:29: error: arithmetics on pointers to functions +builtin-arith.c:15:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:15:29: error: arithmetics on pointers to functions +builtin-arith.c:18:21: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:19:29: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:21:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:22:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:23:14: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:24:21: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:25:21: error: taking the address of built-in function '__builtin_trap' +builtin-arith.c:27:9: error: taking the address of built-in function '__builtin_trap' builtin-arith.c:27:24: error: subtraction of functions? Share your drugs +builtin-arith.c:28:15: error: taking the address of built-in function '__builtin_trap' builtin-arith.c:28:13: error: subtraction of functions? Share your drugs * check-error-end */ diff --git a/validation/builtin-atomic-clear.c b/validation/builtin-atomic-clear.c new file mode 100644 index 00000000..ef430c64 --- /dev/null +++ b/validation/builtin-atomic-clear.c @@ -0,0 +1,15 @@ +void foo(void *ptr, _Bool *bptr, volatile void *vptr, volatile _Bool *vbptr, int mo) +{ + __atomic_clear(ptr, mo); + __atomic_clear(bptr, mo); + __atomic_clear(vptr, mo); + __atomic_clear(vbptr, mo); +} + +/* + * check-name: builtin-atomic-clear + * + * check-error-start +builtin-atomic-clear.c:1:6: warning: symbol 'foo' was not declared. Should it be static? + * check-error-end + */ diff --git a/validation/builtin-sync-fetch.c b/validation/builtin-sync-fetch.c new file mode 100644 index 00000000..45139a3c --- /dev/null +++ b/validation/builtin-sync-fetch.c @@ -0,0 +1,24 @@ +static int ok_int(int *ptr, int val) +{ + return __sync_add_and_fetch(ptr, val); +} + +static long* ok_ptr(long **ptr, long *val) +{ + return __sync_add_and_fetch(ptr, val); +} + +static void chk_ret_ok(long *ptr, long val) +{ + _Static_assert([typeof(__sync_add_and_fetch(ptr, val))] == [long], ""); +} + +static int chk_val(int *ptr, long val) +{ + // OK: val is converted to an int + return __sync_add_and_fetch(ptr, val); +} + +/* + * check-name: builtin-sync-fetch + */ diff --git a/validation/crash-undef-in-parens.c b/validation/crash-undef-in-parens.c new file mode 100644 index 00000000..5f05f88a --- /dev/null +++ b/validation/crash-undef-in-parens.c @@ -0,0 +1,9 @@ +void foo(void) { return (UNDEF_STUFF_IN_PARENS); } + +/* + * check-name: crash-undef-in-parens + * + * check-error-start +crash-undef-in-parens.c:1:26: error: undefined identifier 'UNDEF_STUFF_IN_PARENS' + * check-error-end + */ diff --git a/validation/flex-array-align.c b/validation/flex-array-align.c new file mode 100644 index 00000000..9f28942a --- /dev/null +++ b/validation/flex-array-align.c @@ -0,0 +1,18 @@ +struct s { + __INT32_TYPE__ x; + __INT16_TYPE__ y; + unsigned char f[]; +}; + +static int foo(struct s *s) +{ + return (sizeof(*s) << 16) | __builtin_offsetof(typeof(*s), f); +} + +/* + * check-name: flex-array-align + * check-command: test-linearize -Wno-flexible-array-sizeof $file + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0x80006 + */ diff --git a/validation/flex-array-array.c b/validation/flex-array-array.c new file mode 100644 index 00000000..921a0698 --- /dev/null +++ b/validation/flex-array-array.c @@ -0,0 +1,15 @@ +struct s { + int i; + long f[]; +}; + +static struct s a[2]; + +/* + * check-name: flex-array-array + * check-command: sparse -Wflexible-array-array $file + * + * check-error-start +flex-array-array.c:6:18: warning: array of flexible structures + * check-error-end + */ diff --git a/validation/flex-array-error.c b/validation/flex-array-error.c new file mode 100644 index 00000000..2b7e6953 --- /dev/null +++ b/validation/flex-array-error.c @@ -0,0 +1,26 @@ +struct s { + int i; + long f[]; + int j; +}; + +union u { + int i; + long f[]; +}; + +// trigger the examination of the offending types +static int foo(struct s *s, union u *u) +{ + return __builtin_offsetof(typeof(*s), i) + + __builtin_offsetof(typeof(*u), i); +} + +/* + * check-name: flex-array-error + * + * check-error-start +flex-array-error.c:3:14: error: flexible array member 'f' is not last +flex-array-error.c:9:14: error: flexible array member 'f' in a union + * check-error-end + */ diff --git a/validation/flex-array-nested.c b/validation/flex-array-nested.c new file mode 100644 index 00000000..094de2fb --- /dev/null +++ b/validation/flex-array-nested.c @@ -0,0 +1,29 @@ +struct f { + int i; + long f[]; +}; + +struct s { + struct f f; +}; + +union u { + struct f f; +}; + +// trigger the examination of the offending types +static int foo(struct s *s, union u *u) +{ + return __builtin_offsetof(typeof(*s), f) + + __builtin_offsetof(typeof(*u), f); +} + +/* + * check-name: flex-array-nested + * check-command: sparse -Wflexible-array-nested $file + * + * check-error-start +flex-array-nested.c:7:18: warning: nested flexible array +flex-array-nested.c:11:18: warning: nested flexible array + * check-error-end + */ diff --git a/validation/flex-array-sizeof.c b/validation/flex-array-sizeof.c new file mode 100644 index 00000000..05394e19 --- /dev/null +++ b/validation/flex-array-sizeof.c @@ -0,0 +1,18 @@ +struct s { + int i; + long f[]; +}; + +static int foo(struct s *s) +{ + return sizeof(*s); +} + +/* + * check-name: flex-array-sizeof + * check-command: sparse -Wflexible-array-sizeof $file + * + * check-error-start +flex-array-sizeof.c:8:16: warning: using sizeof on a flexible structure + * check-error-end + */ diff --git a/validation/flex-array-union-array-no.c b/validation/flex-array-union-array-no.c new file mode 100644 index 00000000..5a1de787 --- /dev/null +++ b/validation/flex-array-union-array-no.c @@ -0,0 +1,9 @@ +#include "flex-array-union-array.h" + +/* + * check-name: flex-array-union-no + * check-command: sparse -Wflexible-array-array -Wno-flexible-array-union $file + * + * check-error-start + * check-error-end + */ diff --git a/validation/flex-array-union-array-yes.c b/validation/flex-array-union-array-yes.c new file mode 100644 index 00000000..c2b71d65 --- /dev/null +++ b/validation/flex-array-union-array-yes.c @@ -0,0 +1,11 @@ +#include "flex-array-union-array.h" + +/* + * check-name: flex-array-union-yes + * check-command: sparse -Wflexible-array-array -Wflexible-array-union $file + * + * check-error-start +flex-array-union-array-yes.c: note: in included file: +flex-array-union-array.h:11:17: warning: array of flexible structures + * check-error-end + */ diff --git a/validation/flex-array-union-array.h b/validation/flex-array-union-array.h new file mode 100644 index 00000000..b2a74d1a --- /dev/null +++ b/validation/flex-array-union-array.h @@ -0,0 +1,11 @@ +struct s_flex { + int i; + long f[]; +}; + +union s { + struct s_flex flex; + char buf[200]; +}; + +static union s a[2]; diff --git a/validation/linear/bool-cast-lp32.c b/validation/linear/bool-cast-lp32.c index 44a650f4..7aab31dd 100644 --- a/validation/linear/bool-cast-lp32.c +++ b/validation/linear/bool-cast-lp32.c @@ -12,7 +12,6 @@ static _Bool ffun_e(void) { return (_Bool)ffun; } /* * check-name: bool-cast-pointer * check-command: test-linearize -m32 -fdump-ir $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: ptrtu\\. diff --git a/validation/optim/canonical-mul.c b/validation/optim/canonical-mul.c index 3ae9e3a6..0c14226f 100644 --- a/validation/optim/canonical-mul.c +++ b/validation/optim/canonical-mul.c @@ -7,7 +7,7 @@ uint xtc_umul_ytc(uint x, uint y) { return (x * 3) * (y * 2); } * check-description: * 1) verify that constants in mul chains are * pushed at the right of the whole chain. - * For example '(a * 3) * b' must be canonicalized into '(a * b) * 1' + * For example '(a * 3) * b' must be canonicalized into '(a * b) * 3' * This is needed in general for constant simplification; * for example, for: * '(a * 3) * (b * 2)' diff --git a/validation/usual-conv-lp32.c b/validation/usual-conv-lp32.c new file mode 100644 index 00000000..7f91288e --- /dev/null +++ b/validation/usual-conv-lp32.c @@ -0,0 +1,11 @@ +extern long l; +extern unsigned int u; + +#if __SIZEOF_LONG__ == __SIZEOF_INT__ +_Static_assert([typeof(l + u)] == [unsigned long], "ulong"); +#endif + +/* + * check-name: usual-conversions + * check-command: sparse -m32 $file + */ |
