66 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -pedantic -verify2 3// PR33104struct a x1; // expected-note 2{{forward declaration of 'struct a'}}5static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}6struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}7struct a {int x;};8static struct a x2_okay;9struct a x3_okay[10];10struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \11 // expected-note{{forward declaration of 'struct b'}}12 13const int a [1] = {1};14extern const int a[];15 16extern const int b[];17const int b [1] = {1};18 19extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}20const int c[];21 22int i1 = 1; // expected-note {{previous definition is here}}23int i1 = 2; // expected-error {{redefinition of 'i1'}}24int i1;25int i1;26extern int i5; // expected-note {{previous declaration is here}}27static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}28 29static int i2 = 5; // expected-note 1 {{previous definition is here}}30int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}31 32static int i3 = 5;33extern int i3;34 35__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}} \36// expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}37int pExtern = 0;38 39int i4;40int i4;41extern int i4;42 43int (*pToArray)[];44int (*pToArray)[8];45 46int redef[10];47int redef[]; // expected-note {{previous definition is here}}48int redef[11]; // expected-error{{redefinition of 'redef'}}49 50void func(void) {51 extern int i6; // expected-note {{previous declaration is here}}52 static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}53}54 55void func2(void)56{57 extern double *p;58 extern double *p;59}60 61static int a0[]; // expected-warning {{tentative definition of variable with internal linkage has incomplete array type 'int[]'}}62static int b0;63 64static int a0[] = { 4 };65static int b0 = 5;66