zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 236567de8d7706b7a6c529670a1a15f4c8b9f95e (tree)
parent a69d403cb2c82ce6257bfa1ee7eba52f895c14e7
Author: Evan Haas <evan@lagerdata.com>
Date:   Tue, 30 Jul 2024 10:52:33 -0700

aro_translate_c: Emit compile errors instead of panicking for var decls

Diffstat:
Mlib/compiler/aro_translate_c.zig | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/compiler/aro_translate_c.zig b/lib/compiler/aro_translate_c.zig @@ -304,7 +304,7 @@ fn transDecl(c: *Context, scope: *Scope, decl: NodeIndex) !void { .threadlocal_extern_var, .threadlocal_static_var, => { - try transVarDecl(c, decl, null); + try transVarDecl(c, decl); }, .static_assert => try warn(c, &c.global_scope.base, 0, "ignoring _Static_assert declaration", .{}), else => unreachable, @@ -566,8 +566,10 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void { return addTopLevelDecl(c, fn_name, proto_node); } -fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void { - @panic("TODO"); +fn transVarDecl(c: *Context, node: NodeIndex) Error!void { + const data = c.tree.nodes.items(.data)[@intFromEnum(node)]; + const name = c.tree.tokSlice(data.decl.name); + return failDecl(c, data.decl.name, name, "unable to translate variable declaration", .{}); } fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void {