IR: pass explicitCastMaybePointers test
parent
6c9ec3688e
commit
110a6f39ca
|
@ -5030,11 +5030,10 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc
|
||||||
static IrInstruction *ir_analyze_pointer_reinterpret(IrAnalyze *ira, IrInstruction *source_instr,
|
static IrInstruction *ir_analyze_pointer_reinterpret(IrAnalyze *ira, IrInstruction *source_instr,
|
||||||
IrInstruction *ptr, TypeTableEntry *wanted_type)
|
IrInstruction *ptr, TypeTableEntry *wanted_type)
|
||||||
{
|
{
|
||||||
assert(wanted_type->id == TypeTableEntryIdPointer);
|
if (ptr->value.type->id != TypeTableEntryIdPointer &&
|
||||||
|
ptr->value.type->id != TypeTableEntryIdMaybe)
|
||||||
if (ptr->value.type->id != TypeTableEntryIdPointer) {
|
{
|
||||||
ir_add_error(ira, ptr,
|
ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&ptr->value.type->name)));
|
||||||
buf_sprintf("expected pointer, found '%s'", buf_ptr(&ptr->value.type->name)));
|
|
||||||
return ira->codegen->invalid_instruction;
|
return ira->codegen->invalid_instruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,14 @@ fn compileTimeGlobalReinterpret() {
|
||||||
assert(*d == 1234);
|
assert(*d == 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn explicitCastMaybePointers() {
|
||||||
|
@setFnTest(this);
|
||||||
|
|
||||||
|
const a: ?&i32 = undefined;
|
||||||
|
const b: ?&f32 = (?&f32)(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO import from std.str
|
// TODO import from std.str
|
||||||
pub fn memeql(a: []const u8, b: []const u8) -> bool {
|
pub fn memeql(a: []const u8, b: []const u8) -> bool {
|
||||||
sliceEql(u8, a, b)
|
sliceEql(u8, a, b)
|
||||||
|
|
Loading…
Reference in New Issue