diff --git a/src/Parser.zig b/src/Parser.zig index 44f12a2a..b44470c3 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -2365,7 +2365,9 @@ fn enumSpec(p: *Parser) Error!Type { // check if this is a reference to a previous type const interned_name = try p.comp.intern(p.tokSlice(ident)); if (try p.syms.findTag(p, interned_name, .keyword_enum, ident, p.tok_ids[p.tok_i])) |prev| { - try p.checkEnumFixedTy(fixed_ty, ident, prev); + // only check fixed underlying type in forward declarations and not in references. + if (p.tok_ids[p.tok_i] == .semicolon) + try p.checkEnumFixedTy(fixed_ty, ident, prev); return prev.ty; } else { // this is a forward declaration, create a new enum Type. diff --git a/test/cases/enum fixed.c b/test/cases/enum fixed.c index 10339404..d02b7484 100644 --- a/test/cases/enum fixed.c +++ b/test/cases/enum fixed.c @@ -30,6 +30,10 @@ enum E6: char { a = 0u, }; +enum E e; +enum E: int; +void fn(enum E); + #define EXPECTED_ERRORS "enum fixed.c:2:7: warning: enumeration types with a fixed underlying type are a Clang extension [-Wfixed-enum-extension]" \ "enum fixed.c:4:6: error: enumeration previously declared with fixed underlying type" \ "enum fixed.c:2:6: note: previous definition is here" \