reject invalid arrays in post_type()
This commit is contained in:
parent
942b73bbbb
commit
cbbba01b46
3 changed files with 39 additions and 3 deletions
9
tccgen.c
9
tccgen.c
|
@ -4377,7 +4377,7 @@ static int asm_label_instr(void)
|
||||||
|
|
||||||
static int post_type(CType *type, AttributeDef *ad, int storage, int td)
|
static int post_type(CType *type, AttributeDef *ad, int storage, int td)
|
||||||
{
|
{
|
||||||
int n, l, t1, arg_size, align;
|
int n, l, t1, arg_size, align, unused_align;
|
||||||
Sym **plast, *s, *first;
|
Sym **plast, *s, *first;
|
||||||
AttributeDef ad1;
|
AttributeDef ad1;
|
||||||
CType pt;
|
CType pt;
|
||||||
|
@ -4503,8 +4503,13 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
|
||||||
skip(']');
|
skip(']');
|
||||||
/* parse next post type */
|
/* parse next post type */
|
||||||
post_type(type, ad, storage, 0);
|
post_type(type, ad, storage, 0);
|
||||||
if (type->t == VT_FUNC)
|
|
||||||
|
if ((type->t & VT_BTYPE) == VT_FUNC)
|
||||||
tcc_error("declaration of an array of functions");
|
tcc_error("declaration of an array of functions");
|
||||||
|
if ((type->t & VT_BTYPE) == VT_VOID
|
||||||
|
|| type_size(type, &unused_align) < 0)
|
||||||
|
tcc_error("declaration of an array of incomplete type elements");
|
||||||
|
|
||||||
t1 |= type->t & VT_VLA;
|
t1 |= type->t & VT_VLA;
|
||||||
|
|
||||||
if (t1 & VT_VLA) {
|
if (t1 & VT_VLA) {
|
||||||
|
|
|
@ -182,4 +182,20 @@ void * _Alignas(16) p1;
|
||||||
_Static_assert(ONE == 0, "don't show me this");
|
_Static_assert(ONE == 0, "don't show me this");
|
||||||
_Static_assert(ONE == 1, "ONE is not 1");
|
_Static_assert(ONE == 1, "ONE is not 1");
|
||||||
|
|
||||||
|
#elif defined test_void_array
|
||||||
|
void t[3];
|
||||||
|
|
||||||
|
#elif defined test_incomplete_enum_array
|
||||||
|
enum e t[3];
|
||||||
|
|
||||||
|
#elif defined test_incomplete_struct_array
|
||||||
|
struct s t[3];
|
||||||
|
|
||||||
|
#elif defined test_const_fun_array
|
||||||
|
typedef void f(void);
|
||||||
|
const f t[3];
|
||||||
|
|
||||||
|
#elif defined test_incomplete_array_array
|
||||||
|
int t[][3];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -86,3 +86,18 @@
|
||||||
|
|
||||||
[test_static_assert]
|
[test_static_assert]
|
||||||
60_errors_and_warnings.c:183: error: "ONE is not 1"
|
60_errors_and_warnings.c:183: error: "ONE is not 1"
|
||||||
|
|
||||||
|
[test_void_array]
|
||||||
|
60_errors_and_warnings.c:186: error: declaration of an array of incomplete type elements
|
||||||
|
|
||||||
|
[test_incomplete_enum_array]
|
||||||
|
60_errors_and_warnings.c:189: error: declaration of an array of incomplete type elements
|
||||||
|
|
||||||
|
[test_incomplete_struct_array]
|
||||||
|
60_errors_and_warnings.c:192: error: declaration of an array of incomplete type elements
|
||||||
|
|
||||||
|
[test_const_fun_array]
|
||||||
|
60_errors_and_warnings.c:196: error: declaration of an array of functions
|
||||||
|
|
||||||
|
[test_incomplete_array_array]
|
||||||
|
60_errors_and_warnings.c:199: error: unknown type size
|
||||||
|
|
Loading…
Add table
Reference in a new issue