diff options
| -rw-r--r-- | validation/parsing/attr-cleanup.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/validation/parsing/attr-cleanup.c b/validation/parsing/attr-cleanup.c new file mode 100644 index 00000000..76234276 --- /dev/null +++ b/validation/parsing/attr-cleanup.c @@ -0,0 +1,34 @@ +#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-known-to-fail + * + * 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 + */ |
