2023-03-27 14:45:43 -04:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify=c,expected %s
|
|
|
|
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify=cxx,expected %s
|
2008-01-18 00:39:39 +00:00
|
|
|
|
2023-03-27 14:45:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
struct foo; // c-note 5 {{forward declaration of 'struct foo'}} \
|
|
|
|
cxx-note 3 {{forward declaration of 'foo'}}
|
2009-01-19 19:26:10 +00:00
|
|
|
|
2008-01-18 00:39:39 +00:00
|
|
|
void b; // expected-error {{variable has incomplete type 'void'}}
|
2023-03-27 14:45:43 -04:00
|
|
|
struct foo f; // c-error {{tentative definition has type 'struct foo' that is never completed}} \
|
|
|
|
cxx-error {{variable has incomplete type 'struct foo'}}
|
2008-01-18 00:39:39 +00:00
|
|
|
|
|
|
|
static void c; // expected-error {{variable has incomplete type 'void'}}
|
2023-03-27 14:45:43 -04:00
|
|
|
static struct foo g; // c-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \
|
|
|
|
c-error {{tentative definition has type 'struct foo' that is never completed}} \
|
|
|
|
cxx-error {{variable has incomplete type 'struct foo'}}
|
2008-01-18 00:39:39 +00:00
|
|
|
|
2023-03-27 14:45:43 -04:00
|
|
|
extern void d; // cxx-error {{variable has incomplete type 'void'}}
|
2008-01-18 00:39:39 +00:00
|
|
|
extern struct foo e;
|
|
|
|
|
2023-03-27 14:45:43 -04:00
|
|
|
int ary[]; // c-warning {{tentative array definition assumed to have one element}} \
|
|
|
|
cxx-error {{definition of variable with array type needs an explicit size or an initializer}}
|
|
|
|
struct foo bary[]; // c-error {{array has incomplete element type 'struct foo'}} \
|
|
|
|
cxx-error {{definition of variable with array type needs an explicit size or an initializer}}
|
2008-01-18 20:40:52 +00:00
|
|
|
|
2022-02-04 15:19:56 -05:00
|
|
|
void func(void) {
|
2023-03-27 14:45:43 -04:00
|
|
|
int ary[]; // expected-error {{definition of variable with array type needs an explicit size or an initializer}}
|
2008-01-18 00:39:39 +00:00
|
|
|
void b; // expected-error {{variable has incomplete type 'void'}}
|
|
|
|
struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
|
|
|
|
}
|
2008-07-03 03:53:40 +00:00
|
|
|
|
2023-03-27 14:45:43 -04:00
|
|
|
int h[]; // c-warning {{tentative array definition assumed to have one element}} \
|
|
|
|
cxx-error {{definition of variable with array type needs an explicit size or an initializer}}
|
|
|
|
int (*i)[] = &h+1; // c-error {{arithmetic on a pointer to an incomplete type 'int[]'}}
|
2008-07-03 03:53:40 +00:00
|
|
|
|
2009-04-13 21:28:54 +00:00
|
|
|
struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \
|
2023-03-27 14:45:43 -04:00
|
|
|
c-note {{forward declaration of 'struct bar'}} \
|
|
|
|
cxx-note 2 {{forward declaration of 'bar'}}
|
|
|
|
|
|
|
|
struct bar k; // cxx-error {{variable has incomplete type 'struct bar'}}
|
2009-04-13 21:28:54 +00:00
|
|
|
struct bar { int a; };
|
|
|
|
|
2023-03-27 14:45:43 -04:00
|
|
|
struct x y; //c-note 2 {{forward declaration of 'struct x'}} \
|
|
|
|
cxx-error {{variable has incomplete type 'struct x'}} \
|
|
|
|
cxx-note {{forward declaration of 'x'}}
|
|
|
|
void foo() {
|
|
|
|
(void)(1 ? y : y); // c-error 2 {{incomplete type 'struct x' where a complete type is required}}
|
|
|
|
}
|
|
|
|
struct x{
|
|
|
|
int a;
|
|
|
|
};
|