ability to explicitly cast bool to int

This commit is contained in:
Andrew Kelley
2016-02-04 12:59:06 -07:00
parent 32642ac9cb
commit 25e74cb385
4 changed files with 34 additions and 0 deletions

View File

@@ -530,6 +530,11 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) {
return LLVMBuildFPToUI(g->builder, expr_val, wanted_type->type_ref, "");
}
case CastOpBoolToInt:
assert(wanted_type->id == TypeTableEntryIdInt);
assert(actual_type->id == TypeTableEntryIdBool);
return LLVMBuildZExt(g->builder, expr_val, wanted_type->type_ref, "");
}
zig_unreachable();
}