parse: handle __cleanup__ attribute
[smatch.git] / validation / parsing / attr-cleanup.c
blobac64649c2ac11ed991074fdfa36825f7d4e1da27
1 #define __cleanup(F) __attribute__((__cleanup__(F)))
3 void fun(int *ptr);
5 int test(int n);
6 int test(int n)
8 int var __attribute__((cleanup(fun))) = 1;
9 int alt __cleanup(fun) = 2;
10 int mis __cleanup(0) = 3;
11 int non __attribute__((cleanup));
12 int mis __attribute__((cleanup()));
13 int two __attribute__((cleanup(fun, fun)));
15 for (int i __cleanup(fun) = 0; i < n; i++)
18 var = 5;
19 return 0;
23 * check-name: attr-cleanup
24 * check-command: sparse -Wunknown-attribute $file
26 * check-error-start
27 parsing/attr-cleanup.c:10:17: error: argument is not an identifier
28 parsing/attr-cleanup.c:11:39: error: an argument is expected for attribute 'cleanup'
29 parsing/attr-cleanup.c:12:40: error: an argument is expected for attribute 'cleanup'
30 parsing/attr-cleanup.c:13:43: error: Expected ) after attribute's argument'
31 parsing/attr-cleanup.c:13:43: error: got ,
32 * check-error-end