incomplete-decl.c 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. struct foo; // expected-note 5 {{forward declaration of 'struct foo'}}
  3. void b; // expected-error {{variable has incomplete type 'void'}}
  4. struct foo f; // expected-error{{tentative definition has type 'struct foo' that is never completed}}
  5. static void c; // expected-error {{variable has incomplete type 'void'}}
  6. static struct foo g; // expected-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \
  7. expected-error{{tentative definition has type 'struct foo' that is never completed}}
  8. extern void d;
  9. extern struct foo e;
  10. int ary[]; // expected-warning {{tentative array definition assumed to have one element}}
  11. struct foo bary[]; // expected-error {{array has incomplete element type 'struct foo'}}
  12. void func() {
  13. int ary[]; // expected-error{{definition of variable with array type needs an explicit size or an initializer}}
  14. void b; // expected-error {{variable has incomplete type 'void'}}
  15. struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
  16. }
  17. int h[]; // expected-warning {{tentative array definition assumed to have one element}}
  18. int (*i)[] = &h+1; // expected-error {{arithmetic on a pointer to an incomplete type 'int []'}}
  19. struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \
  20. expected-note {{forward declaration of 'struct bar'}}
  21. struct bar k;
  22. struct bar { int a; };