aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-08-22 14:31:30 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-08-22 14:31:30 -0400
commit4b68ef45af54abd7ba56878f93132ca608891cf1 (patch)
treec55317df4451d47d77c168c231fdd8d1fe140566 /src
parent5aeb3217ee42753f7bc837fdfe7cc04fb132d150 (diff)
downloadzig-4b68ef45af54abd7ba56878f93132ca608891cf1.tar.gz
zig-4b68ef45af54abd7ba56878f93132ca608891cf1.zip
fix incorrectly generating an unused const fn global
closes #1277
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 539356ef2f..16595be9dd 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -5220,13 +5220,13 @@ static bool is_llvm_value_unnamed_type(TypeTableEntry *type_entry, LLVMValueRef
}
static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, const char *name) {
- render_const_val_global(g, const_val, name);
switch (const_val->data.x_ptr.special) {
case ConstPtrSpecialInvalid:
case ConstPtrSpecialDiscard:
zig_unreachable();
case ConstPtrSpecialRef:
{
+ render_const_val_global(g, const_val, name);
ConstExprValue *pointee = const_val->data.x_ptr.data.ref.pointee;
render_const_val(g, pointee, "");
render_const_val_global(g, pointee, "");
@@ -5237,6 +5237,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
}
case ConstPtrSpecialBaseArray:
{
+ render_const_val_global(g, const_val, name);
ConstExprValue *array_const_val = const_val->data.x_ptr.data.base_array.array_val;
size_t elem_index = const_val->data.x_ptr.data.base_array.elem_index;
assert(array_const_val->type->id == TypeTableEntryIdArray);
@@ -5257,6 +5258,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
}
case ConstPtrSpecialBaseStruct:
{
+ render_const_val_global(g, const_val, name);
ConstExprValue *struct_const_val = const_val->data.x_ptr.data.base_struct.struct_val;
assert(struct_const_val->type->id == TypeTableEntryIdStruct);
if (struct_const_val->type->zero_bits) {
@@ -5279,6 +5281,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
}
case ConstPtrSpecialHardCodedAddr:
{
+ render_const_val_global(g, const_val, name);
uint64_t addr_value = const_val->data.x_ptr.data.hard_coded_addr.addr;
TypeTableEntry *usize = g->builtin_types.entry_usize;
const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstInt(usize->type_ref, addr_value, false),