Commit 96f9e20152
Changed files (4)
src/aro_translate_c.zig
@@ -308,7 +308,6 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void {
fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void {
const node_types = c.tree.nodes.items(.ty);
const ty = node_types[@intFromEnum(enum_decl)];
- const node_data = c.tree.nodes.items(.data);
if (c.decl_table.get(@intFromPtr(ty.data.@"enum"))) |_|
return; // Avoid processing this decl twice
const toplevel = scope.id == .root;
@@ -342,11 +341,15 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes:
else => |e| return e,
};
+ const val = c.tree.value_map.get(field_node).?;
+ const str = try std.fmt.allocPrint(c.arena, "{d}", .{val.data.int});
+ const int = try ZigTag.integer_literal.create(c.arena, str);
+
const enum_const_def = try ZigTag.enum_constant.create(c.arena, .{
.name = enum_val_name,
.is_public = toplevel,
.type = enum_const_type_node,
- .value = transExpr(c, node_data[@intFromEnum(field_node)].decl.node, .used) catch @panic("TODO"),
+ .value = int,
});
if (toplevel)
try addTopLevelDecl(c, enum_val_name, enum_const_def)
src/Compilation.zig
@@ -3936,6 +3936,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
man.hash.addBytes(c_src);
+ man.hash.add(comp.c_frontend);
// If the previous invocation resulted in clang errors, we will see a hit
// here with 0 files in the manifest, in which case it is actually a miss.
src/main.zig
@@ -4238,6 +4238,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati
defer man.deinit();
man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
+ man.hash.add(comp.c_frontend);
Compilation.cache_helpers.hashCSource(&man, c_source_file) catch |err| {
fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) });
};
test/src/Cases.zig
@@ -681,11 +681,11 @@ pub fn lowerToBuildSteps(
}
}
- for (self.translate.items) |*case| switch (case.kind) {
+ for (self.translate.items) |case| switch (case.kind) {
.run => |output| {
const annotated_case_name = b.fmt("run-translated-c {s}", .{case.name});
if (opt_test_filter) |filter| {
- if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return;
+ if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue;
}
if (!std.process.can_spawn) {
std.debug.print("Unable to spawn child processes on {s}, skipping test.\n", .{@tagName(builtin.os.tag)});
@@ -723,7 +723,7 @@ pub fn lowerToBuildSteps(
.translate => |output| {
const annotated_case_name = b.fmt("zig translate-c {s}", .{case.name});
if (opt_test_filter) |filter| {
- if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return;
+ if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue;
}
const write_src = b.addWriteFiles();