aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-13 19:12:25 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-13 19:12:25 -0400
commit1e03cf1739c9c7407c4b3a56ee5f2705805c6a83 (patch)
tree2a0dabd42babeb6c6920b5543605a7c4a5369590 /src
parentc06a61e9bf93810174255474598cfeae785cfbd6 (diff)
downloadzig-1e03cf1739c9c7407c4b3a56ee5f2705805c6a83.tar.gz
zig-1e03cf1739c9c7407c4b3a56ee5f2705805c6a83.zip
fix assertion failure on compile-time `@intToPtr` of function
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 86ede7411d..d7d7223657 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -5886,9 +5886,16 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
case ZigTypeIdEnum:
return bigint_to_llvm_const(type_entry->type_ref, &const_val->data.x_enum_tag);
case ZigTypeIdFn:
- assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction);
- assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst);
- return fn_llvm_value(g, const_val->data.x_ptr.data.fn.fn_entry);
+ if (const_val->data.x_ptr.special == ConstPtrSpecialFunction) {
+ assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst);
+ return fn_llvm_value(g, const_val->data.x_ptr.data.fn.fn_entry);
+ } else if (const_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {
+ LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->type_ref;
+ uint64_t addr = const_val->data.x_ptr.data.hard_coded_addr.addr;
+ return LLVMConstIntToPtr(LLVMConstInt(usize_type_ref, addr, false), type_entry->type_ref);
+ } else {
+ zig_unreachable();
+ }
case ZigTypeIdPointer:
return gen_const_val_ptr(g, const_val, name);
case ZigTypeIdErrorUnion: