From 25e74cb385dc353bcf0e56b35a6f1c7c8b13267e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 4 Feb 2016 12:59:06 -0700 Subject: ability to explicitly cast bool to int --- src/codegen.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 5c07b34097..e0a2784e95 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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(); } -- cgit v1.2.3