Unified · Split
| @@ -4377,7 +4377,7 @@ static int asm_label_instr(void) · 4376 unmodified lines | ||
| 4377 | 4377 | |
| 4378 | 4378 | static int post_type(CType *type, AttributeDef *ad, int storage, int td) |
| 4379 | 4379 | { |
| 4380 | − int n, l, t1, arg_size, align; | |
| 4380 | + int n, l, t1, arg_size, align, unused_align; | |
| 4381 | 4381 | Sym **plast, *s, *first; |
| 4382 | 4382 | AttributeDef ad1; |
| 4383 | 4383 | CType pt; |
| @@ -4503,10 +4503,15 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td) · 119 unmodified lines | ||
| 4503 | 4503 | skip(']'); |
| 4504 | 4504 | /* parse next post type */ |
| 4505 | 4505 | post_type(type, ad, storage, 0); |
| 4506 | − if (type->t == VT_FUNC) | |
| 4506 | + | |
| 4507 | + if ((type->t & VT_BTYPE) == VT_FUNC) | |
| 4507 | 4508 | tcc_error("declaration of an array of functions"); |
| 4509 | + if ((type->t & VT_BTYPE) == VT_VOID | |
| 4510 | + || type_size(type, &unused_align) < 0) | |
| 4511 | + tcc_error("declaration of an array of incomplete type elements"); | |
| 4512 | + | |
| 4508 | 4513 | t1 |= type->t & VT_VLA; |
| 4509 | − | |
| 4514 | + | |
| 4510 | 4515 | if (t1 & VT_VLA) { |
| 4511 | 4516 | if (n < 0) |
| 4512 | 4517 | tcc_error("need explicit inner array size in VLAs"); |
| @@ -182,4 +182,20 @@ void * _Alignas(16) p1; · 181 unmodified lines | ||
| 182 | 182 | _Static_assert(ONE == 0, "don't show me this"); |
| 183 | 183 | _Static_assert(ONE == 1, "ONE is not 1"); |
| 184 | 184 | |
| 185 | +#elif defined test_void_array | |
| 186 | + void t[3]; | |
| 187 | + | |
| 188 | +#elif defined test_incomplete_enum_array | |
| 189 | + enum e t[3]; | |
| 190 | + | |
| 191 | +#elif defined test_incomplete_struct_array | |
| 192 | + struct s t[3]; | |
| 193 | + | |
| 194 | +#elif defined test_const_fun_array | |
| 195 | + typedef void f(void); | |
| 196 | + const f t[3]; | |
| 197 | + | |
| 198 | +#elif defined test_incomplete_array_array | |
| 199 | + int t[][3]; | |
| 200 | + | |
| 185 | 201 | #endif |
| @@ -86,3 +86,18 @@ · 85 unmodified lines | ||
| 86 | 86 | |
| 87 | 87 | [test_static_assert] |
| 88 | 88 | 60_errors_and_warnings.c:183: error: "ONE is not 1" |
| 89 | + | |
| 90 | +[test_void_array] | |
| 91 | +60_errors_and_warnings.c:186: error: declaration of an array of incomplete type elements | |
| 92 | + | |
| 93 | +[test_incomplete_enum_array] | |
| 94 | +60_errors_and_warnings.c:189: error: declaration of an array of incomplete type elements | |
| 95 | + | |
| 96 | +[test_incomplete_struct_array] | |
| 97 | +60_errors_and_warnings.c:192: error: declaration of an array of incomplete type elements | |
| 98 | + | |
| 99 | +[test_const_fun_array] | |
| 100 | +60_errors_and_warnings.c:196: error: declaration of an array of functions | |
| 101 | + | |
| 102 | +[test_incomplete_array_array] | |
| 103 | +60_errors_and_warnings.c:199: error: unknown type size | |