xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/invalid-decl.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -verify
2f4a2713aSLionel Sambuc 
test()3f4a2713aSLionel Sambuc void test() {
4f4a2713aSLionel Sambuc     char = 4;  // expected-error {{expected identifier}}
5f4a2713aSLionel Sambuc }
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc // PR2400
9f4a2713aSLionel Sambuc 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'}}
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc typedef void ytype();
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc typedef struct _zend_module_entry zend_module_entry;
15f4a2713aSLionel Sambuc struct _zend_module_entry {
16f4a2713aSLionel Sambuc     ytype globals_size; // expected-error {{field 'globals_size' declared as a function}}
17f4a2713aSLionel Sambuc };
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc zend_module_entry openssl_module_entry = {
20f4a2713aSLionel Sambuc     sizeof(zend_module_entry)
21f4a2713aSLionel Sambuc };
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc // <rdar://problem/11067144>
24f4a2713aSLionel Sambuc typedef int (FunctionType)(int *value);
25f4a2713aSLionel Sambuc typedef struct {
26f4a2713aSLionel Sambuc   UndefinedType undef; // expected-error {{unknown type name 'UndefinedType'}}
27f4a2713aSLionel Sambuc   FunctionType fun; // expected-error {{field 'fun' declared as a function}}
28f4a2713aSLionel Sambuc } StructType;
f(StructType * buf)29f4a2713aSLionel Sambuc void f(StructType *buf) {
30f4a2713aSLionel Sambuc   buf->fun = 0;
31f4a2713aSLionel Sambuc }
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc // rdar://11743706
34f4a2713aSLionel Sambuc static void bar(hid_t, char); // expected-error {{expected identifier}}
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}}
37f4a2713aSLionel Sambuc 
foo()38f4a2713aSLionel Sambuc void foo() {
39f4a2713aSLionel Sambuc   (void)bar;
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc void test2();
43f4a2713aSLionel Sambuc void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
test2()44f4a2713aSLionel Sambuc void test2() { }
45f4a2713aSLionel Sambuc 
46f4a2713aSLionel Sambuc void test3();
47f4a2713aSLionel Sambuc void test3; // expected-error {{incomplete type}}
test3()48f4a2713aSLionel Sambuc void test3() { }
49*0a6a1f1dSLionel Sambuc 
50*0a6a1f1dSLionel Sambuc void ellipsis1(...); // expected-error {{ISO C requires a named parameter before '...'}}
51