aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/Waddress-weak.c
blob: ad2cb13abbcec1e4ce91a15a9804b0a18156a1c5 (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
extern int var       __attribute__((weak));
extern int arr[]     __attribute__((weak));
extern int fun(void) __attribute__((weak));

int test_addr_weak_fun(void)
{
	if ( &var) return 1;
	if (  arr) return 1;
	if ( &arr) return 1;
	if (  fun) return 1;
	if ( &fun) return 1;
	if ( *fun) return 1;
	if (!&var) return 0;
	if (! arr) return 0;
	if (!&arr) return 0;
	if (! fun) return 0;
	if (!&fun) return 0;
	if (!*fun) return 0;
	return -1;
}

/*
 * check-name: Waddress-weak
 * check-note: Undefined weak symbols (can) have a null address.
 * check-command: sparse -Wno-decl -Waddress $file
 * check-known-to-fail
 */