fix constant debug info when number literal is 0

This commit is contained in:
Andrew Kelley
2017-08-06 18:15:11 -04:00
parent a0a57beed5
commit d83e4092bf
2 changed files with 18 additions and 19 deletions

View File

@@ -3891,6 +3891,9 @@ static void do_code_gen(CodeGen *g) {
ConstExprValue *const_val = var->value;
assert(const_val->special != ConstValSpecialRuntime);
size_t bits_needed = bigint_bits_needed(&const_val->data.x_bigint);
if (bits_needed < 8) {
bits_needed = 8;
}
TypeTableEntry *var_type = get_int_type(g, const_val->data.x_bigint.is_negative, bits_needed);
LLVMValueRef init_val = bigint_to_llvm_const(var_type->type_ref, &const_val->data.x_bigint);
gen_global_var(g, var, init_val, var_type);