aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-02-04 12:59:06 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-02-04 12:59:06 -0700
commit25e74cb385dc353bcf0e56b35a6f1c7c8b13267e (patch)
tree09c18cff4b8e63c040db933fe9d321c2e0b09eca /src/codegen.cpp
parent32642ac9cb00b59fef97c1888e0424b0eb4db784 (diff)
downloadzig-25e74cb385dc353bcf0e56b35a6f1c7c8b13267e.tar.gz
zig-25e74cb385dc353bcf0e56b35a6f1c7c8b13267e.zip
ability to explicitly cast bool to int
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp5
1 files changed, 5 insertions, 0 deletions
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();
}