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