Skip to content

Commit

Permalink
Raise error if struct member is VLA
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Mar 5, 2024
1 parent 13100eb commit 0815cba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cc/frontend/parser_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,15 @@ static StructInfo *parse_struct(bool is_union) {
#endif

switch (type->kind) {
case TY_ARRAY:
#ifndef __NO_VLA
case TY_PTR:
if (type->pa.vla != NULL) {
parse_error(PE_NOFATAL, ident, "VLA not allowed in struct/union");
// To continue compile.
type->pa.vla = NULL;
type->pa.length = 1;
}
break;
#endif
case TY_ARRAY:
if (type->pa.length == LEN_UND) {
assert(ident != NULL);
flex_arr_mem = ident;
Expand Down

0 comments on commit 0815cba

Please sign in to comment.