tests
This commit is contained in:
@@ -4223,8 +4223,16 @@ pub const CodeGen = struct {
|
||||
|
||||
fn genSizeOf(self: *CodeGen, call_node: ast.Call) !c.LLVMValueRef {
|
||||
if (call_node.args.len != 1) return self.emitError("size_of expects exactly 1 argument");
|
||||
const ty = self.resolveType(call_node.args[0]);
|
||||
const arg = call_node.args[0];
|
||||
const ty = self.resolveType(arg);
|
||||
if (std.meta.eql(ty, Type.void_type)) {
|
||||
// Uninstantiated generic type function → size of a function pointer
|
||||
if (arg.data == .identifier or arg.data == .type_expr) {
|
||||
const name = if (arg.data == .identifier) arg.data.identifier.name else arg.data.type_expr.name;
|
||||
if (self.generic_templates.contains(name) or self.generic_struct_templates.contains(name)) {
|
||||
return self.constInt64(self.getTypeSize(self.ptrType()));
|
||||
}
|
||||
}
|
||||
return self.constInt64(0);
|
||||
}
|
||||
const llvm_ty = self.typeToLLVM(ty);
|
||||
|
||||
@@ -97,10 +97,15 @@ pub fn main(init: std.process.Init) !void {
|
||||
std.debug.print("error: failed to run program\n", .{});
|
||||
return;
|
||||
};
|
||||
_ = child.wait(io) catch {
|
||||
const term = child.wait(io) catch {
|
||||
std.debug.print("error: program execution failed\n", .{});
|
||||
return;
|
||||
};
|
||||
switch (term) {
|
||||
.exited => |code| if (code != 0) std.process.exit(code),
|
||||
.signal => std.process.exit(1),
|
||||
.stopped, .unknown => std.process.exit(1),
|
||||
}
|
||||
} else {
|
||||
printUsage();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user