Skip to content

Commit

Permalink
Fix bug wrt struct field type parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Nov 9, 2023
1 parent 4a9cc27 commit 921cb53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ncc/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ fn parse_struct(input: &mut Input) -> Result<Type, ParseError>

// Parse one field name and its type
let field_type = parse_type(input)?;
let field_type = parse_array_type(input, field_type)?;
let field_name = input.parse_ident()?;
let field_type = parse_array_type(input, field_type)?;
fields.push((field_name, field_type));
input.expect_token(";")?;
}
Expand Down
11 changes: 11 additions & 0 deletions ncc/tests/structs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Struct with an array field inside
typedef struct
{
int user_id;
char name[32];
} user_t;

int main()
{
return 0;
}

0 comments on commit 921cb53

Please sign in to comment.