brintos

brintos / llvm-project-archived public Read only

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