mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
parent
42ba06133a
commit
9eb51e20ed
@ -19796,6 +19796,12 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
if (!type_has_bits(target->value.type)) {
|
||||
ir_add_error(ira, target,
|
||||
buf_sprintf("pointer to size 0 type has no address"));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
if (instr_is_comptime(target)) {
|
||||
ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
|
||||
if (!val)
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@ptrToInt on *void",
|
||||
\\export fn entry() bool {
|
||||
\\ return @ptrToInt(&{}) == @ptrToInt(&{});
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:23: error: pointer to size 0 type has no address",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"@popCount - non-integer",
|
||||
\\export fn entry(x: f32) u32 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user