diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2023-12-16 12:12:28 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2023-12-16 12:12:28 +0100 |
| commit | eac793a4ec5e4647e8301ddeb7c13ac78cb54fe1 (patch) | |
| tree | 5cf657f7b256d5a05aaee7cf0a62125455915c48 /validation | |
| parent | ce1a6720f69e6233ec9abd4e9aae5945e05fda41 (diff) | |
| parent | 25e96501f249b27cb930a09aba5aeb33a047d14c (diff) | |
| download | sparse-dev-eac793a4ec5e4647e8301ddeb7c13ac78cb54fe1.tar.gz | |
Merge branch 'handle-cleanup-attr'
* teach Sparse about 'cleanup' attribute so that Smatch can handle it
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/parsing/attr-cleanup.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/validation/parsing/attr-cleanup.c b/validation/parsing/attr-cleanup.c new file mode 100644 index 00000000..ac64649c --- /dev/null +++ b/validation/parsing/attr-cleanup.c @@ -0,0 +1,33 @@ +#define __cleanup(F) __attribute__((__cleanup__(F))) + +void fun(int *ptr); + +int test(int n); +int test(int n) +{ + int var __attribute__((cleanup(fun))) = 1; + int alt __cleanup(fun) = 2; + int mis __cleanup(0) = 3; + int non __attribute__((cleanup)); + int mis __attribute__((cleanup())); + int two __attribute__((cleanup(fun, fun))); + + for (int i __cleanup(fun) = 0; i < n; i++) + ; + + var = 5; + return 0; +} + +/* + * check-name: attr-cleanup + * check-command: sparse -Wunknown-attribute $file + * + * check-error-start +parsing/attr-cleanup.c:10:17: error: argument is not an identifier +parsing/attr-cleanup.c:11:39: error: an argument is expected for attribute 'cleanup' +parsing/attr-cleanup.c:12:40: error: an argument is expected for attribute 'cleanup' +parsing/attr-cleanup.c:13:43: error: Expected ) after attribute's argument' +parsing/attr-cleanup.c:13:43: error: got , + * check-error-end + */ |
