IR: pass genericFnWithImplicitCast test
This commit is contained in:
parent
f6ac2fa70e
commit
94f977a6c1
@ -1567,7 +1567,9 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
|
|||||||
}
|
}
|
||||||
|
|
||||||
static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {
|
static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {
|
||||||
bool maybe_is_ptr = (maybe_type->id == TypeTableEntryIdPointer || maybe_type->id == TypeTableEntryIdFn);
|
assert(maybe_type->id == TypeTableEntryIdMaybe);
|
||||||
|
TypeTableEntry *child_type = maybe_type->data.maybe.child_type;
|
||||||
|
bool maybe_is_ptr = (child_type->id == TypeTableEntryIdPointer || child_type->id == TypeTableEntryIdFn);
|
||||||
if (maybe_is_ptr) {
|
if (maybe_is_ptr) {
|
||||||
return LLVMBuildICmp(g->builder, LLVMIntNE, maybe_handle, LLVMConstNull(maybe_type->type_ref), "");
|
return LLVMBuildICmp(g->builder, LLVMIntNE, maybe_handle, LLVMConstNull(maybe_type->type_ref), "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -128,6 +128,17 @@ fn aGenericFn(inline T: type, inline a: T, b: T) -> T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn genericFnWithImplicitCast() {
|
||||||
|
@setFnTest(this);
|
||||||
|
|
||||||
|
assert(getFirstByte(u8, []u8 {13}) == 13);
|
||||||
|
assert(getFirstByte(u16, []u16 {0, 13}) == 0);
|
||||||
|
}
|
||||||
|
fn getByte(ptr: ?&u8) -> u8 {*??ptr}
|
||||||
|
fn getFirstByte(inline T: type, mem: []T) -> u8 {
|
||||||
|
getByte((&u8)(&mem[0]))
|
||||||
|
}
|
||||||
|
|
||||||
// TODO const assert = @import("std").debug.assert;
|
// TODO const assert = @import("std").debug.assert;
|
||||||
fn assert(ok: bool) {
|
fn assert(ok: bool) {
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
// TODO not passing
|
|
||||||
fn genericFnWithImplicitCast() {
|
|
||||||
@setFnTest(this);
|
|
||||||
|
|
||||||
assert(getFirstByte(u8, []u8 {13}) == 13);
|
|
||||||
assert(getFirstByte(u16, []u16 {0, 13}) == 0);
|
|
||||||
}
|
|
||||||
fn getByte(ptr: ?&u8) -> u8 {*??ptr}
|
|
||||||
fn getFirstByte(inline T: type, mem: []T) -> u8 {
|
|
||||||
getByte((&u8)(&mem[0]))
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user