Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc %s -fsyntax-only -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 | |
Steve Naroff | 235549c | 2008-05-12 22:36:43 +0000 | [diff] [blame] | 35 | __private_extern__ int pExtern; |
| 36 | int pExtern = 0; |
| 37 | |
Steve Naroff | ff9eb1f | 2008-08-08 17:50:35 +0000 | [diff] [blame] | 38 | int i4; |
| 39 | int i4; |
| 40 | extern int i4; |
| 41 | |
Steve Naroff | 907747b | 2008-08-09 16:04:40 +0000 | [diff] [blame] | 42 | int (*pToArray)[]; |
| 43 | int (*pToArray)[8]; |
| 44 | |
Steve Naroff | f855e6f | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 45 | int redef[10]; |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 46 | int redef[]; // expected-note {{previous definition is here}} |
Steve Naroff | f855e6f | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 47 | int redef[11]; // expected-error{{redefinition of 'redef'}} |
| 48 | |
Steve Naroff | b7b032e | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 49 | void func() { |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 50 | extern int i6; // expected-note {{previous definition is here}} |
| 51 | 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] | 52 | } |
Steve Naroff | 094cefb | 2008-09-17 14:05:40 +0000 | [diff] [blame] | 53 | |
| 54 | void func2(void) |
| 55 | { |
| 56 | extern double *p; |
| 57 | extern double *p; |
| 58 | } |
Douglas Gregor | a03aca8 | 2009-03-10 21:58:27 +0000 | [diff] [blame] | 59 | |
Douglas Gregor | b6c8c8b | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 60 | // <rdar://problem/6808352> |
| 61 | static int a0[]; |
| 62 | static int b0; |
| 63 | |
| 64 | static int a0[] = { 4 }; |
| 65 | static int b0 = 5; |