blob: 12ce181e0f111fe623954b04d73fb5d1bfcaac0c [file] [log] [blame]
Douglas Gregor75a45ba2009-02-16 17:45:42 +00001// RUN: clang %s -fsyntax-only -verify
Steve Naroff1e787362008-01-30 00:44:01 +00002
3const int a [1] = {1};
4extern const int a[];
5
6extern const int b[];
7const int b [1] = {1};
8
9extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
10const int c[];
11
Chris Lattner0369c572008-11-23 23:12:31 +000012int i1 = 1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000013int i1 = 2; // expected-error {{redefinition of 'i1'}}
Steve Naroff5bb8f222008-08-08 17:50:35 +000014int i1;
Steve Naroff1e787362008-01-30 00:44:01 +000015int i1;
Chris Lattner0369c572008-11-23 23:12:31 +000016extern int i1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000017static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
18
19static int i2 = 5; // expected-note 2 {{previous definition is here}}
20int i2 = 3; // expected-error{{redefinition of 'i2'}} expected-error{{non-static declaration of 'i2' follows static declaration}}
Steve Naroff1e787362008-01-30 00:44:01 +000021
Steve Naroffa98fe192008-05-12 22:36:43 +000022__private_extern__ int pExtern;
23int pExtern = 0;
24
Steve Naroff5bb8f222008-08-08 17:50:35 +000025int i4;
26int i4;
27extern int i4;
28
Steve Naroff239255d2008-08-09 16:04:40 +000029int (*pToArray)[];
30int (*pToArray)[8];
31
Steve Naroff84e37352008-08-10 15:20:13 +000032int redef[10];
Chris Lattner0369c572008-11-23 23:12:31 +000033int redef[]; // expected-note {{previous definition is here}}
Steve Naroff84e37352008-08-10 15:20:13 +000034int redef[11]; // expected-error{{redefinition of 'redef'}}
35
Steve Naroff1e787362008-01-30 00:44:01 +000036void func() {
Chris Lattner0369c572008-11-23 23:12:31 +000037 extern int i1; // expected-note {{previous definition is here}}
Steve Naroff1e787362008-01-30 00:44:01 +000038 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
39}
Steve Naroffa5629372008-09-17 14:05:40 +000040
41void func2(void)
42{
43 extern double *p;
44 extern double *p;
45}