Skip to content

Commit

Permalink
Parser: skip enumerators which are redefinitions
Browse files Browse the repository at this point in the history
Fixes #628
  • Loading branch information
ehaas authored and Vexu committed Feb 22, 2024
1 parent fb79ba5 commit c990ebe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,7 @@ fn enumSpec(p: *Parser) Error!Type {
if (field.ty.eql(Type.int, p.comp, false)) continue;

const sym = p.syms.get(field.name, .vars) orelse continue;
if (sym.kind != .enumeration) continue; // already an error

var res = Result{ .node = field.node, .ty = field.ty, .val = sym.val };
const dest_ty = if (p.comp.fixedEnumTagSpecifier()) |some|
Expand Down
7 changes: 7 additions & 0 deletions test/cases/redefinitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ void f6(void) {}
void f7(void);
void f7() {}

int X;
enum E {
X = 4294967295,
};

#define EXPECTED_ERRORS "redefinitions.c:4:5: error: redefinition of 'foo' as different kind of symbol" \
"redefinitions.c:1:5: note: previous definition is here" \
"redefinitions.c:5:5: error: redefinition of 'foo' as different kind of symbol" \
Expand Down Expand Up @@ -130,4 +135,6 @@ void f7() {}
"redefinitions.c:82:5: note: previous definition is here" \
"redefinitions.c:86:5: error: redefinition of 'f5' with a different type" \
"redefinitions.c:85:5: note: previous definition is here" \
"redefinitions.c:96:5: error: redefinition of 'X' as different kind of symbol" \
"redefinitions.c:94:5: note: previous definition is here" \

0 comments on commit c990ebe

Please sign in to comment.