warn-shadow.c revision a369a95f756b6190b5611ff4118b4cabfc704dc0
1// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s
2
3int i;          // expected-note 3 {{previous declaration is here}}
4
5void foo() {
6  int pass1;
7  int i;        // expected-warning {{declaration shadows a variable in the global scope}} \
8                // expected-note {{previous declaration is here}}
9  {
10    int pass2;
11    int i;      // expected-warning {{declaration shadows a local variable}} \
12                // expected-note {{previous declaration is here}}
13    {
14      int pass3;
15      int i;    // expected-warning {{declaration shadows a local variable}}
16    }
17  }
18
19  int sin; // okay; 'sin' has not been declared, even though it's a builtin.
20}
21
22// <rdar://problem/7677531>
23void (^test1)(int) = ^(int i) { // expected-warning {{declaration shadows a variable in the global scope}} \
24                                 // expected-note{{previous declaration is here}}
25  {
26    int i; // expected-warning {{declaration shadows a local variable}} \
27           // expected-note{{previous declaration is here}}
28
29    (^(int i) { return i; })(i); //expected-warning {{declaration shadows a local variable}}
30  }
31};
32
33
34struct test2 {
35  int i;
36};
37
38void test3(void) {
39  struct test4 {
40    int i;
41  };
42}
43
44void test4(int i) { // expected-warning {{declaration shadows a variable in the global scope}}
45}
46