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