Skip to content

Commit

Permalink
Parser: save enumerator value to field decl node
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu committed Oct 17, 2023
1 parent 0ef9708 commit 482951b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2702,6 +2702,7 @@ fn enumerator(p: *Parser, e: *Enumerator) Error!?EnumFieldAndNode {
.node = res.node,
} },
});
try p.value_map.put(node, e.res.val);
return EnumFieldAndNode{ .field = .{
.name = interned_name,
.ty = res.ty,
Expand Down
4 changes: 2 additions & 2 deletions test/cases/ast/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ fn_def: 'fn (a: d[2]const int, b: d[2]const int) void'
implicit_return: 'void'

enum_decl_two: 'enum E: unsigned int'
enum_field_decl: 'int'
enum_field_decl: 'int' (value: 2)
name: A
value:
implicit_cast: (int_cast) 'int'
explicit_cast: (int_cast) 'char' (value: 2)
int_literal: 'int' (value: 2)
enum_field_decl: 'int'
enum_field_decl: 'int' (value: 3)
name: B
value:
implicit_cast: (int_cast) 'int'
Expand Down

0 comments on commit 482951b

Please sign in to comment.