diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-01-09 10:43:48 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-01-09 10:43:48 -0500 |
| commit | 5864d92b4049e6d60a21a3f22220464808dd0518 (patch) | |
| tree | 0609155ee5e4f4fa589e61c1dee3b4ef5bc800e1 /src/codegen.cpp | |
| parent | 4d5d0d3adad09e9ce34d281327c424de6402fcdb (diff) | |
| download | zig-5864d92b4049e6d60a21a3f22220464808dd0518.tar.gz zig-5864d92b4049e6d60a21a3f22220464808dd0518.zip | |
when rendering llvm const values, ensure the types align
the representation of the const expr val in zig, and the
type that we tell LLVM it is.
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0c979386e3..47f2aa103f 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -5626,6 +5626,8 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con } static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) { + Error err; + ZigType *type_entry = const_val->type; assert(!type_entry->zero_bits); @@ -5769,6 +5771,12 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c } ConstExprValue *field_val = &const_val->data.x_struct.fields[i]; assert(field_val->type != nullptr); + if ((err = ensure_const_val_repr(nullptr, g, nullptr, field_val, + type_struct_field->type_entry))) + { + zig_unreachable(); + } + LLVMValueRef val = gen_const_val(g, field_val, ""); fields[type_struct_field->gen_index] = val; make_unnamed_struct = make_unnamed_struct || is_llvm_value_unnamed_type(field_val->type, val); |
