Merge pull request #4433 from LemonBoy/ohno

Trivial patchset
This commit is contained in:
Andrew Kelley 2020-02-11 13:12:42 -05:00 committed by GitHub
commit ab4ea5d3cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 9 deletions

View File

@ -149,7 +149,7 @@ comptime {
@export(@import("compiler_rt/clzsi2.zig").__clzsi2, .{ .name = "__clzsi2", .linkage = linkage });
if (builtin.arch.isARM() and !is_test) {
if ((builtin.arch.isARM() or builtin.arch.isThumb()) and !is_test) {
@export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage });
@export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });
@export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });

View File

@ -78,7 +78,6 @@ pub const cpu = struct {
.d,
.f,
.m,
.relax,
}),
};
@ -92,7 +91,6 @@ pub const cpu = struct {
.d,
.f,
.m,
.relax,
}),
};

View File

@ -11873,10 +11873,15 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted
}
if (wanted_type->id == ZigTypeIdInt && actual_type->id == ZigTypeIdInt) {
result.id = ConstCastResultIdIntShorten;
result.data.int_shorten = heap::c_allocator.allocate_nonzero<ConstCastIntShorten>(1);
result.data.int_shorten->wanted_type = wanted_type;
result.data.int_shorten->actual_type = actual_type;
if (wanted_type->data.integral.is_signed != actual_type->data.integral.is_signed ||
wanted_type->data.integral.bit_count != actual_type->data.integral.bit_count)
{
result.id = ConstCastResultIdIntShorten;
result.data.int_shorten = heap::c_allocator.allocate_nonzero<ConstCastIntShorten>(1);
result.data.int_shorten->wanted_type = wanted_type;
result.data.int_shorten->actual_type = actual_type;
return result;
}
return result;
}

View File

@ -146,8 +146,8 @@ fn testAtomicStore() void {
}
test "atomicrmw with floats" {
if (builtin.arch == .aarch64 or builtin.arch == .arm)
return;
if (builtin.arch == .aarch64 or builtin.arch == .arm or builtin.arch == .riscv64)
return error.SkipZigTest;
testAtomicRmwFloat();
}

View File

@ -782,3 +782,16 @@ test "cast between [*c]T and ?[*:0]T on fn parameter" {
};
S.doTheTest();
}
test "cast between C pointer with different but compatible types" {
const S = struct {
fn foo(arg: [*]c_ushort) u16 {
return arg[0];
}
fn doTheTest() void {
var x = [_]u16{ 4, 2, 1, 3 };
expect(foo(@ptrCast([*]u16, &x)) == 4);
}
};
S.doTheTest();
}