aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/parsing/attr-cleanup.c
blob: ac64649c2ac11ed991074fdfa36825f7d4e1da27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
 */