diff --git a/src/aro/Parser.zig b/src/aro/Parser.zig index c20a273c..0836ca86 100644 --- a/src/aro/Parser.zig +++ b/src/aro/Parser.zig @@ -1152,8 +1152,10 @@ fn decl(p: *Parser) Error!bool { const interned_name = try StrInt.intern(p.comp, p.tokSlice(init_d.d.name)); if (decl_spec.storage_class == .typedef) { - try p.syms.defineTypedef(p, interned_name, init_d.d.ty, init_d.d.name, node); - p.typedefDefined(interned_name, init_d.d.ty); + if (!init_d.d.ty.is(.invalid)) { + try p.syms.defineTypedef(p, interned_name, init_d.d.ty, init_d.d.name, node); + p.typedefDefined(interned_name, init_d.d.ty); + } } else if (init_d.initializer.node != .none or (p.func.ty != null and decl_spec.storage_class != .@"extern")) { diff --git a/src/aro/SymbolStack.zig b/src/aro/SymbolStack.zig index dba72234..a8e06407 100644 --- a/src/aro/SymbolStack.zig +++ b/src/aro/SymbolStack.zig @@ -175,6 +175,7 @@ pub fn defineTypedef( tok: TokenIndex, node: NodeIndex, ) !void { + assert(!ty.is(.invalid)); if (s.get(name, .vars)) |prev| { switch (prev.kind) { .typedef => { diff --git a/test/cases/redefine invalid typedef.c b/test/cases/redefine invalid typedef.c new file mode 100644 index 00000000..e4138760 --- /dev/null +++ b/test/cases/redefine invalid typedef.c @@ -0,0 +1,5 @@ +typedef float *invalid1 __attribute__((vector_size(8))); +typedef float invalid1; + +#define EXPECTED_ERRORS "redefine invalid typedef.c:1:40: error: invalid vector element type 'float *'" \ +