Fariborz Jahanian | 767a1a2 | 2012-08-17 21:44:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s |
Daniel Dunbar | 5466c7b | 2009-04-14 02:25:56 +0000 | [diff] [blame] | 2 | |
| 3 | static int g0; // expected-note{{previous definition}} |
| 4 | int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}} |
| 5 | |
| 6 | static int g1; |
| 7 | extern int g1; |
| 8 | |
| 9 | static int g2; |
| 10 | __private_extern__ int g2; |
| 11 | |
| 12 | int g3; // expected-note{{previous definition}} |
| 13 | static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}} |
| 14 | |
| 15 | extern int g4; // expected-note{{previous definition}} |
| 16 | static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}} |
| 17 | |
| 18 | __private_extern__ int g5; // expected-note{{previous definition}} |
| 19 | static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}} |
| 20 | |
| 21 | void f0() { |
Argyrios Kyrtzidis | 6684d85 | 2011-01-31 07:04:46 +0000 | [diff] [blame] | 22 | int g6; // expected-note {{previous}} |
| 23 | extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}} |
Daniel Dunbar | 5466c7b | 2009-04-14 02:25:56 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | void f1() { |
Argyrios Kyrtzidis | 6684d85 | 2011-01-31 07:04:46 +0000 | [diff] [blame] | 27 | int g7; // expected-note {{previous}} |
| 28 | __private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}} |
Daniel Dunbar | 5466c7b | 2009-04-14 02:25:56 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | void f2() { |
| 32 | extern int g8; // expected-note{{previous definition}} |
Argyrios Kyrtzidis | 6684d85 | 2011-01-31 07:04:46 +0000 | [diff] [blame] | 33 | int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}} |
Daniel Dunbar | 5466c7b | 2009-04-14 02:25:56 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void f3() { |
| 37 | __private_extern__ int g9; // expected-note{{previous definition}} |
Argyrios Kyrtzidis | 6684d85 | 2011-01-31 07:04:46 +0000 | [diff] [blame] | 38 | int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}} |
Daniel Dunbar | 5466c7b | 2009-04-14 02:25:56 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void f4() { |
| 42 | extern int g10; |
| 43 | extern int g10; |
| 44 | } |
| 45 | |
| 46 | void f5() { |
| 47 | __private_extern__ int g11; |
| 48 | __private_extern__ int g11; |
| 49 | } |
| 50 | |
| 51 | void f6() { |
| 52 | // FIXME: Diagnose |
| 53 | extern int g12; |
| 54 | __private_extern__ int g12; |
| 55 | } |
| 56 | |
| 57 | void f7() { |
| 58 | // FIXME: Diagnose |
| 59 | __private_extern__ int g13; |
| 60 | extern int g13; |
| 61 | } |
| 62 | |
| 63 | struct s0; |
| 64 | void f8() { |
| 65 | extern struct s0 g14; |
| 66 | __private_extern__ struct s0 g14; |
| 67 | } |
| 68 | struct s0 { int x; }; |
| 69 | |
| 70 | void f9() { |
| 71 | extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}} |
| 72 | // FIXME: linkage specifier in warning. |
| 73 | __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}} |
| 74 | } |
| 75 | |
| 76 | extern int g17; |
| 77 | int g17 = 0; |
| 78 | |
| 79 | extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}} |
| 80 | |
| 81 | __private_extern__ int g19; |
| 82 | int g19 = 0; |
| 83 | |
Steve Naroff | ee3899e | 2009-04-15 15:20:03 +0000 | [diff] [blame] | 84 | __private_extern__ int g20 = 0; |