blob: 12af9735d1a9be9627eff065830c712158f267ce [file] [log] [blame]
Eli Friedmane4851f22012-10-23 20:19:32 +00001// RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
2
3// Variable declarations that should trigger a warning.
4int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
5int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
6
Eli Friedman6c8b6492012-10-24 20:14:09 +00007namespace x {
8 int vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
9}
10
Eli Friedmane4851f22012-10-23 20:19:32 +000011// Variable declarations that should not trigger a warning.
12static int vgood1;
13extern int vgood2;
14int vgood2;
15static struct {
16 int mgood1;
17} vgood3;
18
19// Functions should never trigger a warning.
20void fgood1(void);
21void fgood2(void) {
22 int lgood1;
23 static int lgood2;
24}
25static void fgood3(void) {
26 int lgood3;
27 static int lgood4;
28}
29
30// Structures, namespaces and classes should be unaffected.
31struct sgood1 {
32 int mgood2;
33};
34struct {
35 int mgood3;
36} sgood2;
37class CGood1 {
38 static int MGood1;
39};
40int CGood1::MGood1;
41namespace {
42 int mgood4;
43}