1 // RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
2 
3 struct S {
4   int i;
5 };
6 
7 struct __attribute__((warn_unused)) SWarnUnused {
8   int j;
9 };
10 
11 int f0() {
12   int y; // expected-warning{{variable 'y' set but not used}}
13   y = 0;
14 
15   int z __attribute__((unused));
16   z = 0;
17 
18   // In C++, don't warn for structs. (following gcc's behavior)
19   struct S s;
20   struct S t;
21   s = t;
22 
23   // Unless it's marked with the warn_unused attribute.
24   struct SWarnUnused swu; // expected-warning{{variable 'swu' set but not used}}
25   struct SWarnUnused swu2;
26   swu = swu2;
27 
28   int x;
29   x = 0;
30   return x + 5;
31 }
32 
33 void f1(void) {
34   (void)^() {
35     int y; // expected-warning{{variable 'y' set but not used}}
36     y = 0;
37 
38     int x;
39     x = 0;
40     return x;
41   };
42 }
43 
44 void f2() {
45   // Don't warn for either of these cases.
46   constexpr int x = 2;
47   const int y = 1;
48   char a[x];
49   char b[y];
50 }
51