xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/warn-unused-variables.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -fblocks -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct s0 {
4*f4a2713aSLionel Sambuc 	unsigned int	i;
5*f4a2713aSLionel Sambuc };
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc int proto(int a, int b);
8*f4a2713aSLionel Sambuc 
f0(void)9*f4a2713aSLionel Sambuc void f0(void) {
10*f4a2713aSLionel Sambuc 	int	a __attribute__((unused)),
11*f4a2713aSLionel Sambuc 		b; // expected-warning{{unused}}
12*f4a2713aSLionel Sambuc 	return;
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
f1(void)15*f4a2713aSLionel Sambuc void f1(void) {
16*f4a2713aSLionel Sambuc 	int	i;
17*f4a2713aSLionel Sambuc 	(void)sizeof(i);
18*f4a2713aSLionel Sambuc 	return;
19*f4a2713aSLionel Sambuc }
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc // PR5933
f2()22*f4a2713aSLionel Sambuc int f2() {
23*f4a2713aSLionel Sambuc   int X = 4;  // Shouldn't have a bogus 'unused variable X' warning.
24*f4a2713aSLionel Sambuc   return Y + X; // expected-error {{use of undeclared identifier 'Y'}}
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
f3()27*f4a2713aSLionel Sambuc int f3() {
28*f4a2713aSLionel Sambuc   int X1 = 4;
29*f4a2713aSLionel Sambuc   (void)(Y1 + X1); // expected-error {{use of undeclared identifier 'Y1'}}
30*f4a2713aSLionel Sambuc   (void)(^() { int X = 4; }); // expected-warning{{unused}}
31*f4a2713aSLionel Sambuc   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
32*f4a2713aSLionel Sambuc }
33