authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-12-24 13:25:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-12-24 13:25:54-07:00
log8915883cf627c12a7e6da9bb813d456407ebb091
treee940326978476e284ed7e9565bd806f0e943524f
parent4e52281142c80230e1c60ece2824656dd08afcbd

add error for byvalue struct param on exported fn


2 files changed, 11 insertions(+), 0 deletions(-)

src/analyze.cpp+6
......@@ -1653,6 +1653,7 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import,
16531653 node->codegen_node->data.fn_def_node.block_context = context;
16541654
16551655 AstNodeFnProto *fn_proto = &fn_proto_node->data.fn_proto;
1656 bool is_exported = (fn_proto->visib_mod == FnProtoVisibModExport);
16561657 for (int i = 0; i < fn_proto->params.length; i += 1) {
16571658 AstNode *param_decl_node = fn_proto->params.at(i);
16581659 assert(param_decl_node->type == NodeTypeParamDecl);
......@@ -1662,6 +1663,11 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import,
16621663 assert(param_decl->type->type == NodeTypeType);
16631664 TypeTableEntry *type = param_decl->type->codegen_node->data.type_node.entry;
16641665
1666 if (is_exported && type->id == TypeTableEntryIdStruct) {
1667 add_node_error(g, param_decl_node,
1668 buf_sprintf("byvalue struct parameters not yet supported on exported functions"));
1669 }
1670
16651671 VariableTableEntry *variable_entry = allocate<VariableTableEntry>(1);
16661672 buf_init_from_buf(&variable_entry->name, &param_decl->name);
16671673 variable_entry->type = type;
test/run_tests.cpp+5
......@@ -872,6 +872,11 @@ fn f() {
872872struct A { x : i32, }
873873struct A { y : i32, }
874874 )SOURCE", 1, ".tmp_source.zig:3:1: error: redefinition of 'A'");
875
876 add_compile_fail_case("byvalue struct on exported functions", R"SOURCE(
877struct A { x : i32, }
878export fn f(a : A) {}
879 )SOURCE", 1, ".tmp_source.zig:3:13: error: byvalue struct parameters not yet supported on exported functions");
875880}
876881
877882static void print_compiler_invocation(TestCase *test_case) {