2012-08-16 02:42:26 +08:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -verify
|
2008-01-30 08:44:01 +08:00
|
|
|
|
2009-03-11 05:58:27 +08:00
|
|
|
// PR3310
|
|
|
|
struct a x1; // expected-note 2{{forward declaration of 'struct a'}}
|
2009-07-21 02:46:59 +08:00
|
|
|
static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}
|
2009-03-11 05:58:27 +08:00
|
|
|
struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}
|
|
|
|
struct a {int x;};
|
2009-03-11 07:43:53 +08:00
|
|
|
static struct a x2_okay;
|
|
|
|
struct a x3_okay[10];
|
|
|
|
struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \
|
|
|
|
// expected-note{{forward declaration of 'struct b'}}
|
2009-03-11 05:58:27 +08:00
|
|
|
|
2008-01-30 08:44:01 +08:00
|
|
|
const int a [1] = {1};
|
|
|
|
extern const int a[];
|
|
|
|
|
|
|
|
extern const int b[];
|
|
|
|
const int b [1] = {1};
|
|
|
|
|
|
|
|
extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
|
|
|
|
const int c[];
|
|
|
|
|
2008-11-24 07:12:31 +08:00
|
|
|
int i1 = 1; // expected-note {{previous definition is here}}
|
2009-02-17 01:45:42 +08:00
|
|
|
int i1 = 2; // expected-error {{redefinition of 'i1'}}
|
2008-08-09 01:50:35 +08:00
|
|
|
int i1;
|
2008-01-30 08:44:01 +08:00
|
|
|
int i1;
|
2009-04-25 16:06:05 +08:00
|
|
|
extern int i5; // expected-note {{previous definition is here}}
|
|
|
|
static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
|
2009-02-17 01:45:42 +08:00
|
|
|
|
2009-03-11 07:43:53 +08:00
|
|
|
static int i2 = 5; // expected-note 1 {{previous definition is here}}
|
2009-03-24 00:17:01 +08:00
|
|
|
int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
|
|
|
|
|
|
|
|
static int i3 = 5;
|
|
|
|
extern int i3;
|
2008-01-30 08:44:01 +08:00
|
|
|
|
2012-08-16 02:42:26 +08:00
|
|
|
// rdar://7703982
|
2012-08-18 05:44:55 +08:00
|
|
|
__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}} \
|
|
|
|
// expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}
|
2008-05-13 06:36:43 +08:00
|
|
|
int pExtern = 0;
|
|
|
|
|
2008-08-09 01:50:35 +08:00
|
|
|
int i4;
|
|
|
|
int i4;
|
|
|
|
extern int i4;
|
|
|
|
|
2008-08-10 00:04:40 +08:00
|
|
|
int (*pToArray)[];
|
|
|
|
int (*pToArray)[8];
|
|
|
|
|
2008-08-10 23:20:13 +08:00
|
|
|
int redef[10];
|
2008-11-24 07:12:31 +08:00
|
|
|
int redef[]; // expected-note {{previous definition is here}}
|
2008-08-10 23:20:13 +08:00
|
|
|
int redef[11]; // expected-error{{redefinition of 'redef'}}
|
|
|
|
|
2008-01-30 08:44:01 +08:00
|
|
|
void func() {
|
2009-04-25 16:06:05 +08:00
|
|
|
extern int i6; // expected-note {{previous definition is here}}
|
|
|
|
static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
|
2008-01-30 08:44:01 +08:00
|
|
|
}
|
2008-09-17 22:05:40 +08:00
|
|
|
|
|
|
|
void func2(void)
|
|
|
|
{
|
|
|
|
extern double *p;
|
|
|
|
extern double *p;
|
|
|
|
}
|
2009-03-11 05:58:27 +08:00
|
|
|
|
2009-04-22 01:11:58 +08:00
|
|
|
// <rdar://problem/6808352>
|
|
|
|
static int a0[];
|
|
|
|
static int b0;
|
|
|
|
|
|
|
|
static int a0[] = { 4 };
|
|
|
|
static int b0 = 5;
|