1 // RUN: %clang_cc1 -fsyntax-only -verify=c,expected %s 2 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify=cxx,expected %s 3 4 5 6 struct foo; // c-note 5 {{forward declaration of 'struct foo'}} \ 7 cxx-note 3 {{forward declaration of 'foo'}} 8 9 void b; // expected-error {{variable has incomplete type 'void'}} 10 struct foo f; // c-error {{tentative definition has type 'struct foo' that is never completed}} \ 11 cxx-error {{variable has incomplete type 'struct foo'}} 12 13 static void c; // expected-error {{variable has incomplete type 'void'}} 14 static struct foo g; // c-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \ 15 c-error {{tentative definition has type 'struct foo' that is never completed}} \ 16 cxx-error {{variable has incomplete type 'struct foo'}} 17 18 extern void d; // cxx-error {{variable has incomplete type 'void'}} 19 extern struct foo e; 20 21 int ary[]; // c-warning {{tentative array definition assumed to have one element}} \ 22 cxx-error {{definition of variable with array type needs an explicit size or an initializer}} 23 struct foo bary[]; // c-error {{array has incomplete element type 'struct foo'}} \ 24 cxx-error {{definition of variable with array type needs an explicit size or an initializer}} 25 func(void)26void func(void) { 27 int ary[]; // expected-error {{definition of variable with array type needs an explicit size or an initializer}} 28 void b; // expected-error {{variable has incomplete type 'void'}} 29 struct foo f; // expected-error {{variable has incomplete type 'struct foo'}} 30 } 31 32 int h[]; // c-warning {{tentative array definition assumed to have one element}} \ 33 cxx-error {{definition of variable with array type needs an explicit size or an initializer}} 34 int (*i)[] = &h+1; // c-error {{arithmetic on a pointer to an incomplete type 'int[]'}} 35 36 struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \ 37 c-note {{forward declaration of 'struct bar'}} \ 38 cxx-note 2 {{forward declaration of 'bar'}} 39 40 struct bar k; // cxx-error {{variable has incomplete type 'struct bar'}} 41 struct bar { int a; }; 42 43 struct x y; //c-note 2 {{forward declaration of 'struct x'}} \ 44 cxx-error {{variable has incomplete type 'struct x'}} \ 45 cxx-note {{forward declaration of 'x'}} foo()46void foo() { 47 (void)(1 ? y : y); // c-error 2 {{incomplete type 'struct x' where a complete type is required}} 48 } 49 struct x{ 50 int a; 51 }; 52