1 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c99 2 3 extern int a1[]; 4 5 void f0(); /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C}} */ 6 void f1(int [*]); 7 void f2(int [const *]); 8 void f3(int [volatile const*]); 9 int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */ 10 int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */ 11 12 char ((((*X)))); 13 14 void (*signal(int, void (*)(int)))(int); 15 16 int aaaa, ***C, * const D, B(int); 17 18 int *A; 19 20 struct str; 21 22 void test2(int *P, int A) { 23 struct str; 24 25 // Hard case for array decl, not Array[*]. 26 int Array[*(int*)P+A]; 27 } 28 29 typedef int atype; 30 void test3(x, /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} */ 31 atype /* expected-error {{unexpected type name 'atype': expected identifier}} */ 32 ) int x, atype; {} 33 34 void test4(x, x) int x; {} // expected-error {{redefinition of parameter 'x'}} \ 35 // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} 36 37 38 // PR3031 39 int (test5), ; // expected-error {{expected identifier or '('}} 40 41 42 43 // PR3963 & rdar://6759604 - test error recovery for mistyped "typenames". 44 45 foo_t *d; // expected-error {{unknown type name 'foo_t'}} 46 foo_t a; // expected-error {{unknown type name 'foo_t'}} 47 int test6() { /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C}} */ 48 return a; // a should be declared. 49 } 50 51 // Use of tagged type without tag. rdar://6783347 52 struct xyz { int y; }; 53 enum myenum { ASDFAS }; 54 xyz b; // expected-error {{must use 'struct' tag to refer to type 'xyz'}} 55 myenum c; // expected-error {{must use 'enum' tag to refer to type 'myenum'}} 56 57 float *test7(void) { 58 // We should recover 'b' by parsing it with a valid type of "struct xyz", which 59 // allows us to diagnose other bad things done with y, such as this. 60 return &b.y; // expected-warning {{incompatible pointer types returning 'int *' from a function with result type 'float *'}} 61 } 62 63 struct xyz test8(void) { return a; } // a should be be marked invalid, no diag. 64 65 66 // Verify that implicit int still works. 67 static f; // expected-warning {{type specifier missing, defaults to 'int'}} 68 static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}} 69 static h // expected-warning {{type specifier missing, defaults to 'int'}} 70 __asm__("foo"); 71 72 73 struct test9 { 74 int x // expected-error {{expected ';' at end of declaration list}} 75 int y; 76 int z // expected-warning {{expected ';' at end of declaration list}} 77 }; 78 79 // PR6208 80 struct test10 { int a; } static test10x; 81 struct test11 { int a; } const test11x; 82 83 // PR6216 84 void test12(void) { 85 (void)__builtin_offsetof(struct { char c; int i; }, i); 86 } 87 88 // rdar://7608537 89 struct test13 { int a; } (test13x); 90 91 // <rdar://problem/8044088> 92 struct X<foo::int> { }; // expected-error{{expected identifier or '('}} 93 94 95 // PR7617 - error recovery on missing ;. 96 97 void test14(void) // expected-error {{expected ';' after top level declarator}} 98 99 void test14a(void); 100 void *test14b = (void*)test14a; // Make sure test14a didn't get skipped. 101 102 // rdar://problem/8358508 103 long struct X { int x; } test15(void); // expected-error {{'long struct' is invalid}} 104 105 void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}} \ 106 // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} 107 void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}} \ 108 // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} 109 void knrNoSemi(i) int i { } // expected-error {{expected ';' at end of declaration}} \ 110 // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}} 111 112 // PR12595 113 void test18(void) { 114 int x = 4+(5-12)); // expected-error {{extraneous ')' before ';'}} 115 } 116 117 enum E1 { e1 }: // expected-error {{expected ';'}} 118 struct EnumBitfield { // expected-warning {{struct without named members is a GNU extension}} 119 enum E2 { e2 } : 4; // ok 120 struct S { int n; }: // expected-error {{expected ';'}} 121 // expected-warning@-1 {{declaration does not declare anything}} 122 123 }; 124 125 // PR10982 126 enum E11 { 127 A1 = 1, 128 }; 129 130 enum E12 { 131 , // expected-error{{expected identifier}} 132 A2 133 }; 134 void func_E12(enum E12 *p) { *p = A2; } 135 136 enum E13 { 137 1D, // expected-error{{expected identifier}} 138 A3 139 }; 140 void func_E13(enum E13 *p) { *p = A3; } 141 142 enum E14 { 143 A4 12, // expected-error{{expected '= constant-expression' or end of enumerator definition}} 144 A4a 145 }; 146 void func_E14(enum E14 *p) { *p = A4a; } 147 148 enum E15 { 149 A5=12 4, // expected-error{{expected '}' or ','}} 150 A5a 151 }; 152 void func_E15(enum E15 *p) { *p = A5a; } 153 154 enum E16 { 155 A6; // expected-error{{expected '= constant-expression' or end of enumerator definition}} 156 A6a 157 }; 158 159 int PR20634 = sizeof(struct { int n; } [5]); 160