parent
216e14891e
commit
2e0b114fdc
|
@ -12473,6 +12473,13 @@ static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstr
|
||||||
return ira->codegen->builtin_types.entry_invalid;
|
return ira->codegen->builtin_types.entry_invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type_ensure_zero_bits_known(ira->codegen, dest_type);
|
||||||
|
if (!type_has_bits(dest_type)) {
|
||||||
|
ir_add_error(ira, dest_type_value,
|
||||||
|
buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name)));
|
||||||
|
return ira->codegen->builtin_types.entry_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
IrInstruction *target = instruction->target->other;
|
IrInstruction *target = instruction->target->other;
|
||||||
if (type_is_invalid(target->value.type))
|
if (type_is_invalid(target->value.type))
|
||||||
return ira->codegen->builtin_types.entry_invalid;
|
return ira->codegen->builtin_types.entry_invalid;
|
||||||
|
|
|
@ -1895,6 +1895,13 @@ export fn entry() {
|
||||||
const foo = Arch.x86;
|
const foo = Arch.x86;
|
||||||
}
|
}
|
||||||
)SOURCE", 1, ".tmp_source.zig:3:21: error: container 'Arch' has no member called 'x86'");
|
)SOURCE", 1, ".tmp_source.zig:3:21: error: container 'Arch' has no member called 'x86'");
|
||||||
|
|
||||||
|
add_compile_fail_case("int to ptr of 0 bits", R"SOURCE(
|
||||||
|
export fn foo() {
|
||||||
|
var x: usize = 0x1000;
|
||||||
|
var y: &void = @intToPtr(&void, x);
|
||||||
|
}
|
||||||
|
)SOURCE", 1, ".tmp_source.zig:4:31: error: type '&void' has 0 bits and cannot store information");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue