authorgravatar for andrea@orru.ioAndrea Orru <andrea@orru.io> 2018-03-13 21:20:06-07:00
committergravatar for andrea@orru.ioAndrea Orru <andrea@orru.io> 2018-03-13 21:20:06-07:00
log7ac44037db686b93de25b6d826f596985d79ea42
tree8d324b34251e78ab12a2eadc5674efa710136e98
parent2a6ad23b52aa128dfbfc1fe975fadc38714850b4

Compiler error when taking @offsetOf of void struct member

closes #739

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

src/ir.cpp+6
...@@ -15222,6 +15222,12 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,...@@ -15222,6 +15222,12 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
15222 return ira->codegen->builtin_types.entry_invalid;15222 return ira->codegen->builtin_types.entry_invalid;
15223 }15223 }
1522415224
15225 if (field->type_entry->zero_bits) {
15226 ir_add_error(ira, field_name_value,
15227 buf_sprintf("zero-bit field '%s' in struct '%s' has no offset",
15228 buf_ptr(field_name), buf_ptr(&container_type->name)));
15229 return ira->codegen->builtin_types.entry_invalid;
15230 }
15225 size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, container_type->type_ref, field->gen_index);15231 size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, container_type->type_ref, field->gen_index);
15226 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);15232 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
15227 bigint_init_unsigned(&out_val->data.x_bigint, byte_offset);15233 bigint_init_unsigned(&out_val->data.x_bigint, byte_offset);