Skip to content

Commit

Permalink
fix runtime fn ptr equality codegen
Browse files Browse the repository at this point in the history
closes #1140
  • Loading branch information
andrewrk committed Jun 20, 2018
1 parent 7c99c30 commit 55193cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/codegen.cpp
Expand Up @@ -2246,12 +2246,12 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
} else if (type_entry->id == TypeTableEntryIdInt) {
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, type_entry->data.integral.is_signed);
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");
} else if (type_entry->id == TypeTableEntryIdEnum) {
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, false);
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");
} else if (type_entry->id == TypeTableEntryIdErrorSet ||
} else if (type_entry->id == TypeTableEntryIdEnum ||
type_entry->id == TypeTableEntryIdErrorSet ||
type_entry->id == TypeTableEntryIdPointer ||
type_entry->id == TypeTableEntryIdBool)
type_entry->id == TypeTableEntryIdBool ||
type_entry->id == TypeTableEntryIdPromise ||
type_entry->id == TypeTableEntryIdFn)
{
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, false);
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");
Expand Down
5 changes: 5 additions & 0 deletions test/cases/misc.zig
Expand Up @@ -701,3 +701,8 @@ test "comptime cast fn to ptr" {
const addr2 = @ptrCast(*const u8, emptyFn);
comptime assert(addr1 == addr2);
}

test "equality compare fn ptrs" {
var a = emptyFn;
assert(a == a);
}

0 comments on commit 55193cb

Please sign in to comment.