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