diff options
| author | Andrea Orru <andrea@orru.io> | 2018-03-13 21:20:06 -0700 |
|---|---|---|
| committer | Andrea Orru <andrea@orru.io> | 2018-03-13 21:20:06 -0700 |
| commit | 7ac44037db686b93de25b6d826f596985d79ea42 (patch) | |
| tree | 8d324b34251e78ab12a2eadc5674efa710136e98 | |
| parent | 2a6ad23b52aa128dfbfc1fe975fadc38714850b4 (diff) | |
| download | zig-7ac44037db686b93de25b6d826f596985d79ea42.tar.gz zig-7ac44037db686b93de25b6d826f596985d79ea42.zip | |
Compiler error when taking @offsetOf of void struct member
closes #739
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 51e1a0e93e..797e58f991 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15222,6 +15222,12 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira, return ira->codegen->builtin_types.entry_invalid; } + if (field->type_entry->zero_bits) { + ir_add_error(ira, field_name_value, + buf_sprintf("zero-bit field '%s' in struct '%s' has no offset", + buf_ptr(field_name), buf_ptr(&container_type->name))); + return ira->codegen->builtin_types.entry_invalid; + } size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, container_type->type_ref, field->gen_index); ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); bigint_init_unsigned(&out_val->data.x_bigint, byte_offset); |
