1*67e74705SXin Li // RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s 2*67e74705SXin Li 3*67e74705SXin Li int i; // expected-note 3 {{previous declaration is here}} 4*67e74705SXin Li foo()5*67e74705SXin Livoid foo() { 6*67e74705SXin Li int pass1; 7*67e74705SXin Li int i; // expected-warning {{declaration shadows a variable in the global scope}} \ 8*67e74705SXin Li // expected-note {{previous declaration is here}} 9*67e74705SXin Li { 10*67e74705SXin Li int pass2; 11*67e74705SXin Li int i; // expected-warning {{declaration shadows a local variable}} \ 12*67e74705SXin Li // expected-note {{previous declaration is here}} 13*67e74705SXin Li { 14*67e74705SXin Li int pass3; 15*67e74705SXin Li int i; // expected-warning {{declaration shadows a local variable}} 16*67e74705SXin Li } 17*67e74705SXin Li } 18*67e74705SXin Li 19*67e74705SXin Li int sin; // okay; 'sin' has not been declared, even though it's a builtin. 20*67e74705SXin Li } 21*67e74705SXin Li 22*67e74705SXin Li // <rdar://problem/7677531> 23*67e74705SXin Li void (^test1)(int) = ^(int i) { // expected-warning {{declaration shadows a variable in the global scope}} \ 24*67e74705SXin Li // expected-note{{previous declaration is here}} 25*67e74705SXin Li { 26*67e74705SXin Li int i; // expected-warning {{declaration shadows a local variable}} \ 27*67e74705SXin Li // expected-note{{previous declaration is here}} 28*67e74705SXin Li 29*67e74705SXin Li (^(int i) { return i; })(i); //expected-warning {{declaration shadows a local variable}} 30*67e74705SXin Li } 31*67e74705SXin Li }; 32*67e74705SXin Li 33*67e74705SXin Li 34*67e74705SXin Li struct test2 { 35*67e74705SXin Li int i; 36*67e74705SXin Li }; 37*67e74705SXin Li test3(void)38*67e74705SXin Livoid test3(void) { 39*67e74705SXin Li struct test4 { 40*67e74705SXin Li int i; 41*67e74705SXin Li }; 42*67e74705SXin Li } 43*67e74705SXin Li test4(int i)44*67e74705SXin Livoid test4(int i) { // expected-warning {{declaration shadows a variable in the global scope}} 45*67e74705SXin Li } 46*67e74705SXin Li 47*67e74705SXin Li // Don't warn about shadowing for function declarations. 48*67e74705SXin Li void test5(int i); test6(void (* f)(int i))49*67e74705SXin Livoid test6(void (*f)(int i)) {} test7(void * context,void (* callback)(void * context))50*67e74705SXin Livoid test7(void *context, void (*callback)(void *context)) {} 51*67e74705SXin Li 52*67e74705SXin Li extern int bob; // expected-note {{previous declaration is here}} 53*67e74705SXin Li 54*67e74705SXin Li // rdar://8883302 rdar8883302()55*67e74705SXin Livoid rdar8883302() { 56*67e74705SXin Li extern int bob; // don't warn for shadowing. 57*67e74705SXin Li } 58*67e74705SXin Li test8()59*67e74705SXin Livoid test8() { 60*67e74705SXin Li int bob; // expected-warning {{declaration shadows a variable in the global scope}} 61*67e74705SXin Li } 62