1*f4a2713aSLionel Sambuc // RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // Variable declarations that should trigger a warning. 4*f4a2713aSLionel Sambuc int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}} 5*f4a2713aSLionel Sambuc int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}} 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc namespace x { 8*f4a2713aSLionel Sambuc int vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}} 9*f4a2713aSLionel Sambuc } 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc // Variable declarations that should not trigger a warning. 12*f4a2713aSLionel Sambuc static int vgood1; 13*f4a2713aSLionel Sambuc extern int vgood2; 14*f4a2713aSLionel Sambuc int vgood2; 15*f4a2713aSLionel Sambuc static struct { 16*f4a2713aSLionel Sambuc int mgood1; 17*f4a2713aSLionel Sambuc } vgood3; 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc // Functions should never trigger a warning. 20*f4a2713aSLionel Sambuc void fgood1(void); fgood2(void)21*f4a2713aSLionel Sambucvoid fgood2(void) { 22*f4a2713aSLionel Sambuc int lgood1; 23*f4a2713aSLionel Sambuc static int lgood2; 24*f4a2713aSLionel Sambuc } fgood3(void)25*f4a2713aSLionel Sambucstatic void fgood3(void) { 26*f4a2713aSLionel Sambuc int lgood3; 27*f4a2713aSLionel Sambuc static int lgood4; 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc // Structures, namespaces and classes should be unaffected. 31*f4a2713aSLionel Sambuc struct sgood1 { 32*f4a2713aSLionel Sambuc int mgood2; 33*f4a2713aSLionel Sambuc }; 34*f4a2713aSLionel Sambuc struct { 35*f4a2713aSLionel Sambuc int mgood3; 36*f4a2713aSLionel Sambuc } sgood2; 37*f4a2713aSLionel Sambuc class CGood1 { 38*f4a2713aSLionel Sambuc static int MGood1; 39*f4a2713aSLionel Sambuc }; 40*f4a2713aSLionel Sambuc int CGood1::MGood1; 41*f4a2713aSLionel Sambuc namespace { 42*f4a2713aSLionel Sambuc int mgood4; 43*f4a2713aSLionel Sambuc } 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc class C { test()46*f4a2713aSLionel Sambuc void test() { 47*f4a2713aSLionel Sambuc static int x = 0; // no-warn 48*f4a2713aSLionel Sambuc } 49*f4a2713aSLionel Sambuc }; 50