| author | |
| committer | |
| log | 9eb51e20ed1a040a617541303db760f80ffd3aa1 |
| tree | a85f682a1d27f889d1c106188c2e2406c1026f2a |
| parent | 42ba06133aec995feec3ea24ee7fbbc40d7ac2ca |
closes #11922 files changed, 15 insertions(+), 0 deletions(-)
src/ir.cpp+6| ... | ... | @@ -19796,6 +19796,12 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr |
| 19796 | 19796 | return ira->codegen->builtin_types.entry_invalid; |
| 19797 | 19797 | } |
| 19798 | 19798 | |
| 19799 | if (!type_has_bits(target->value.type)) { | |
| 19800 | ir_add_error(ira, target, | |
| 19801 | buf_sprintf("pointer to size 0 type has no address")); | |
| 19802 | return ira->codegen->builtin_types.entry_invalid; | |
| 19803 | } | |
| 19804 | ||
| 19799 | 19805 | if (instr_is_comptime(target)) { |
| 19800 | 19806 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| 19801 | 19807 | if (!val) |
test/compile_errors.zig+9| ... | ... | @@ -1,6 +1,15 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | |
| 5 | "@ptrToInt on *void", | |
| 6 | \\export fn entry() bool { | |
| 7 | \\ return @ptrToInt(&{}) == @ptrToInt(&{}); | |
| 8 | \\} | |
| 9 | , | |
| 10 | ".tmp_source.zig:2:23: error: pointer to size 0 type has no address", | |
| 11 | ); | |
| 12 | ||
| 4 | 13 | cases.add( |
| 5 | 14 | "@popCount - non-integer", |
| 6 | 15 | \\export fn entry(x: f32) u32 { |