Commit 46033a2128

Andrew Kelley <superjoe30@gmail.com>
2016-12-22 06:46:17
pass void parameters test
1 parent 23bebdb
Changed files (4)
src/analyze.cpp
@@ -2234,7 +2234,10 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
         VariableTableEntry *var = add_variable(g, param_decl_node, fn_table_entry->child_scope, param_decl->name, param_type, true, nullptr);
         var->src_arg_index = i;
         fn_table_entry->child_scope = var->child_scope;
-        fn_table_entry->variable_list.append(var);
+
+        if (type_has_bits(param_type)) {
+            fn_table_entry->variable_list.append(var);
+        }
 
         if (fn_type->data.fn.gen_param_info) {
             var->gen_arg_index = fn_type->data.fn.gen_param_info[i].gen_index;
src/codegen.cpp
@@ -1650,6 +1650,9 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, Ir
 }
 
 static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstructionPhi *instruction) {
+    if (!type_has_bits(instruction->base.type_entry))
+        return nullptr;
+
     LLVMTypeRef phi_type;
     if (handle_is_ptr(instruction->base.type_entry)) {
         phi_type = LLVMPointerType(instruction->base.type_entry->type_ref, 0);
test/cases3/fn.zig
@@ -19,6 +19,17 @@ fn testLocVars(b: i32) {
 }
 
 
+fn voidParameters() {
+    @setFnTest(this);
+
+    voidFun(1, void{}, 2, {});
+}
+fn voidFun(a: i32, b: void, c: i32, d: void) {
+    const v = b;
+    const vv: void = if (a == 1) {v} else {};
+    assert(a + c == 3);
+    return vv;
+}
 
 
 // TODO const assert = @import("std").debug.assert;
test/self_hosted.zig
@@ -17,18 +17,6 @@ const test_this = @import("cases/this.zig");
 
 
 
-fn voidParameters() {
-    @setFnTest(this);
-
-    voidFun(1, void{}, 2, {});
-}
-fn voidFun(a: i32, b: void, c: i32, d: void) {
-    const v = b;
-    const vv: void = if (a == 1) {v} else {};
-    assert(a + c == 3);
-    return vv;
-}
-
 fn mutableLocalVariables() {
     @setFnTest(this, true);