authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-12-16 19:53:05+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-16 15:54:06-05:00
logde0d8885b4623dab14c379fc844ae0b18d9f8405
tree202f3bd2eab8417c6d20878ef971aa7c437eb652
parent170de5ecae27373149db247ca0cff464e090e31b

Fix alignment query on unresolved types

Fixes #3919

1 files changed, 6 insertions(+), 1 deletions(-)

src/ir.cpp+6-1
...@@ -26983,6 +26983,8 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_...@@ -26983,6 +26983,8 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_
26983static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,26983static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
26984 ZigType *ptr_type)26984 ZigType *ptr_type)
26985{26985{
26986 Error err;
26987
26986 ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr);26988 ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr);
26987 ir_assert(type_has_bits(ptr_type), source_instr);26989 ir_assert(type_has_bits(ptr_type), source_instr);
2698826990
...@@ -27002,7 +27004,10 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc...@@ -27002,7 +27004,10 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
27002 return ira->codegen->invalid_instruction;27004 return ira->codegen->invalid_instruction;
27003 }27005 }
2700427006
27005 const uint32_t align_bytes = get_ptr_align(ira->codegen, ptr_type);27007 uint32_t align_bytes;
27008 if ((err = resolve_ptr_align(ira, ptr_type, &align_bytes)))
27009 return ira->codegen->invalid_instruction;
27010
27006 if (addr != 0 && addr % align_bytes != 0) {27011 if (addr != 0 && addr % align_bytes != 0) {
27007 ir_add_error(ira, source_instr,27012 ir_add_error(ira, source_instr,
27008 buf_sprintf("pointer type '%s' requires aligned address",27013 buf_sprintf("pointer type '%s' requires aligned address",