Fariborz Jahanian | 4cc83c2 | 2012-08-15 18:42:26 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -verify |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | a03aca8 | 2009-03-10 21:58:27 +0000 | [diff] [blame] | 3 | // PR3310 |
| 4 | struct a x1; // expected-note 2{{forward declaration of 'struct a'}} |
Douglas Gregor | ec8b59f | 2009-07-20 18:46:59 +0000 | [diff] [blame] | 5 | static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}} |
Douglas Gregor | a03aca8 | 2009-03-10 21:58:27 +0000 | [diff] [blame] | 6 | struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}} |
| 7 | struct a {int x;}; |
Douglas Gregor | 275a369 | 2009-03-10 23:43:53 +0000 | [diff] [blame] | 8 | static struct a x2_okay; |
| 9 | struct a x3_okay[10]; |
| 10 | struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \ |
| 11 | // expected-note{{forward declaration of 'struct b'}} |
Douglas Gregor | a03aca8 | 2009-03-10 21:58:27 +0000 | [diff] [blame] | 12 | |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 13 | const int a [1] = {1}; |
| 14 | extern const int a[]; |
| 15 | |
| 16 | extern const int b[]; |
| 17 | const int b [1] = {1}; |
| 18 | |
| 19 | extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}} |
| 20 | const int c[]; |
| 21 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 22 | int i1 = 1; // expected-note {{previous definition is here}} |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 23 | int i1 = 2; // expected-error {{redefinition of 'i1'}} |
Steve Naroff | ff9eb1f | 2008-08-08 17:50:35 +0000 | [diff] [blame] | 24 | int i1; |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 25 | int i1; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 26 | extern int i5; // expected-note {{previous definition is here}} |
| 27 | static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}} |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 28 | |
Douglas Gregor | 275a369 | 2009-03-10 23:43:53 +0000 | [diff] [blame] | 29 | static int i2 = 5; // expected-note 1 {{previous definition is here}} |
Douglas Gregor | 38179b2 | 2009-03-23 16:17:01 +0000 | [diff] [blame] | 30 | int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}} |
| 31 | |
| 32 | static int i3 = 5; |
| 33 | extern int i3; |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 34 | |
Fariborz Jahanian | 4cc83c2 | 2012-08-15 18:42:26 +0000 | [diff] [blame] | 35 | // rdar://7703982 |
Fariborz Jahanian | 767a1a2 | 2012-08-17 21:44:55 +0000 | [diff] [blame] | 36 | __private_extern__ int pExtern; // expected-warning {{use of __private_extern__ on a declaration may not produce external symbol private to the linkage unit and is deprecated}} \ |
| 37 | // expected-note {{use __attribute__((visibility("hidden"))) attribute instead}} |
Steve Naroff | 235549c | 2008-05-12 22:36:43 +0000 | [diff] [blame] | 38 | int pExtern = 0; |
| 39 | |
Steve Naroff | ff9eb1f | 2008-08-08 17:50:35 +0000 | [diff] [blame] | 40 | int i4; |
| 41 | int i4; |
| 42 | extern int i4; |
| 43 | |
Steve Naroff | 907747b | 2008-08-09 16:04:40 +0000 | [diff] [blame] | 44 | int (*pToArray)[]; |
| 45 | int (*pToArray)[8]; |
| 46 | |
Steve Naroff | f855e6f | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 47 | int redef[10]; |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 48 | int redef[]; // expected-note {{previous definition is here}} |
Steve Naroff | f855e6f | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 49 | int redef[11]; // expected-error{{redefinition of 'redef'}} |
| 50 | |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 51 | void func() { |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 52 | extern int i6; // expected-note {{previous definition is here}} |
| 53 | static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}} |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 54 | } |
Steve Naroff | 094cefb | 2008-09-17 14:05:40 +0000 | [diff] [blame] | 55 | |
| 56 | void func2(void) |
| 57 | { |
| 58 | extern double *p; |
| 59 | extern double *p; |
| 60 | } |
Douglas Gregor | a03aca8 | 2009-03-10 21:58:27 +0000 | [diff] [blame] | 61 | |
Douglas Gregor | b6c8c8b | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 62 | // <rdar://problem/6808352> |
| 63 | static int a0[]; |
| 64 | static int b0; |
| 65 | |
| 66 | static int a0[] = { 4 }; |
| 67 | static int b0 = 5; |