Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 1 | // RUN: clang %s -fsyntax-only -verify |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | 8145742 | 2009-03-10 21:58:27 +0000 | [diff] [blame^] | 3 | // PR3310 |
| 4 | struct a x1; // expected-note 2{{forward declaration of 'struct a'}} |
| 5 | static struct a x2; // expected-error{{variable has incomplete type 'struct a'}} |
| 6 | struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}} |
| 7 | struct a {int x;}; |
| 8 | struct b x4; // FIXME: error because 'struct b' is never defined |
| 9 | |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 10 | const int a [1] = {1}; |
| 11 | extern const int a[]; |
| 12 | |
| 13 | extern const int b[]; |
| 14 | const int b [1] = {1}; |
| 15 | |
| 16 | extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}} |
| 17 | const int c[]; |
| 18 | |
Chris Lattner | 0369c57 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 19 | int i1 = 1; // expected-note {{previous definition is here}} |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 20 | int i1 = 2; // expected-error {{redefinition of 'i1'}} |
Steve Naroff | 5bb8f22 | 2008-08-08 17:50:35 +0000 | [diff] [blame] | 21 | int i1; |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 22 | int i1; |
Chris Lattner | 0369c57 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 23 | extern int i1; // expected-note {{previous definition is here}} |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 24 | static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}} |
| 25 | |
| 26 | static int i2 = 5; // expected-note 2 {{previous definition is here}} |
| 27 | int i2 = 3; // expected-error{{redefinition of 'i2'}} expected-error{{non-static declaration of 'i2' follows static declaration}} |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 28 | |
Steve Naroff | a98fe19 | 2008-05-12 22:36:43 +0000 | [diff] [blame] | 29 | __private_extern__ int pExtern; |
| 30 | int pExtern = 0; |
| 31 | |
Steve Naroff | 5bb8f22 | 2008-08-08 17:50:35 +0000 | [diff] [blame] | 32 | int i4; |
| 33 | int i4; |
| 34 | extern int i4; |
| 35 | |
Steve Naroff | 239255d | 2008-08-09 16:04:40 +0000 | [diff] [blame] | 36 | int (*pToArray)[]; |
| 37 | int (*pToArray)[8]; |
| 38 | |
Steve Naroff | 84e3735 | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 39 | int redef[10]; |
Chris Lattner | 0369c57 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 40 | int redef[]; // expected-note {{previous definition is here}} |
Steve Naroff | 84e3735 | 2008-08-10 15:20:13 +0000 | [diff] [blame] | 41 | int redef[11]; // expected-error{{redefinition of 'redef'}} |
| 42 | |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 43 | void func() { |
Chris Lattner | 0369c57 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 44 | extern int i1; // expected-note {{previous definition is here}} |
Steve Naroff | 1e78736 | 2008-01-30 00:44:01 +0000 | [diff] [blame] | 45 | static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}} |
| 46 | } |
Steve Naroff | a562937 | 2008-09-17 14:05:40 +0000 | [diff] [blame] | 47 | |
| 48 | void func2(void) |
| 49 | { |
| 50 | extern double *p; |
| 51 | extern double *p; |
| 52 | } |
Douglas Gregor | 8145742 | 2009-03-10 21:58:27 +0000 | [diff] [blame^] | 53 | |