diff options
| author | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-12-06 23:33:10 -0700 |
|---|---|---|
| committer | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-12-06 23:33:10 -0700 |
| commit | 66e3aa09104781f460da1ea721b083d18eec351b (patch) | |
| tree | fa6a39c1df96635168fa02e1427daf238e31e8bd /src/codegen.cpp | |
| parent | 180f539f6722e72b661825e9d4971651da872b99 (diff) | |
| download | zig-66e3aa09104781f460da1ea721b083d18eec351b.tar.gz zig-66e3aa09104781f460da1ea721b083d18eec351b.zip | |
initialize mutable variables to zero
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index be4d695279..e1a5525e37 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -526,14 +526,14 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) { variable->value_ref = gen_expr(g, node->data.variable_declaration.expr); return nullptr; } else { + LLVMValueRef value; if (node->data.variable_declaration.expr) { - LLVMValueRef value = gen_expr(g, node->data.variable_declaration.expr); - - add_debug_source_node(g, node); - return LLVMBuildStore(g->builder, value, variable->value_ref); + value = gen_expr(g, node->data.variable_declaration.expr); } else { - + value = LLVMConstNull(variable->type->type_ref); } + add_debug_source_node(g, node); + return LLVMBuildStore(g->builder, value, variable->value_ref); } } case NodeTypeCastExpr: |
