1 // RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s
3 int i
; // expected-note 4 {{previous declaration is here}}
4 static int s
; // expected-note 2 {{previous declaration is here}}
8 int i
; // expected-warning {{declaration shadows a variable in the global scope}} \
9 // expected-note {{previous declaration is here}}
10 int s
; // expected-warning {{declaration shadows a variable in the global scope}} \
11 // expected-note {{previous declaration is here}}
14 int i
; // expected-warning {{declaration shadows a local variable}} \
15 // expected-note {{previous declaration is here}}
16 int s
; // expected-warning {{declaration shadows a local variable}} \
17 // expected-note {{previous declaration is here}}
20 int i
; // expected-warning {{declaration shadows a local variable}}
21 int s
; // expected-warning {{declaration shadows a local variable}}
25 int sin
; // okay; 'sin' has not been declared, even though it's a builtin.
28 void (^test1
)(int) = ^(int i
) { // expected-warning {{declaration shadows a variable in the global scope}} \
29 // expected-note{{previous declaration is here}}
31 int i
; // expected-warning {{declaration shadows a local variable}} \
32 // expected-note{{previous declaration is here}}
34 (^(int i
) { return i
; })(i
); //expected-warning {{declaration shadows a local variable}}
49 void test4(int i
) { // expected-warning {{declaration shadows a variable in the global scope}}
52 // Don't warn about shadowing for function declarations.
54 void test6(void (*f
)(int i
)) {}
55 void test7(void *context
, void (*callback
)(void *context
)) {}
57 extern int bob
; // expected-note {{previous declaration is here}}
59 void rdar8883302(void) {
60 extern int bob
; // don't warn for shadowing.
64 int bob
; // expected-warning {{declaration shadows a variable in the global scope}}
67 enum PR24718_1
{pr24718
}; // expected-note {{previous declaration is here}}
69 enum PR24718_2
{pr24718
}; // expected-warning {{declaration shadows a variable in the global scope}}
75 PR24718_3
// Does not shadow a type.
79 void static_locals() {
80 static int i
; // expected-warning {{declaration shadows a variable in the global scope}}
81 // expected-note@-1 {{previous definition is here}}
82 // expected-note@-2 {{previous declaration is here}}
83 int i
; // expected-error {{non-static declaration of 'i' follows static declaration}}
84 static int foo
; // expected-note {{previous declaration is here}}
85 static int hoge
; // expected-note {{previous declaration is here}}
86 int s
; // expected-warning {{declaration shadows a variable in the global scope}}
88 static int foo
; // expected-warning {{declaration shadows a local variable}}
89 // expected-note@-1 {{previous declaration is here}}
90 static int i
; // expected-warning {{declaration shadows a local variable}}
91 // expected-note@-1 {{previous declaration is here}}
92 int hoge
; // expected-warning {{declaration shadows a local variable}}
94 static int foo
; // expected-warning {{declaration shadows a local variable}}
95 int i
; // expected-warning {{declaration shadows a local variable}}