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