invalid-decl.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // RUN: %clang_cc1 %s -fsyntax-only -verify
  2. void test() {
  3. char = 4; // expected-error {{expected identifier}}
  4. }
  5. // PR2400
  6. typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}}
  7. typedef void ytype();
  8. typedef struct _zend_module_entry zend_module_entry;
  9. struct _zend_module_entry {
  10. ytype globals_size; // expected-error {{field 'globals_size' declared as a function}}
  11. };
  12. zend_module_entry openssl_module_entry = {
  13. sizeof(zend_module_entry)
  14. };
  15. // <rdar://problem/11067144>
  16. typedef int (FunctionType)(int *value);
  17. typedef struct {
  18. UndefinedType undef; // expected-error {{unknown type name 'UndefinedType'}}
  19. FunctionType fun; // expected-error {{field 'fun' declared as a function}}
  20. } StructType;
  21. void f(StructType *buf) {
  22. buf->fun = 0;
  23. }
  24. // rdar://11743706
  25. static void bar(hid_t, char); // expected-error {{expected identifier}}
  26. static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}}
  27. void foo() {
  28. (void)bar;
  29. }
  30. void test2();
  31. void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
  32. void test2() { }
  33. void test3();
  34. void test3; // expected-error {{incomplete type}}
  35. void test3() { }
  36. void ellipsis1(...); // expected-error {{ISO C requires a named parameter before '...'}}