Skip to content

Commit

Permalink
fix: only check fixed underlying type in declarations, not in references
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsan901998 committed Oct 27, 2023
1 parent 44b9bab commit 2a58f02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions test/cases/enum fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit 2a58f02

Please sign in to comment.