| author | |
| committer | |
| log | 7ce7e2c9d1d43886c93f34b67d32ef77cc0d8a6e |
| tree | b983cf44e18da510aa9b9bb02953f02af076c410 |
| parent | 7f4d4bdb3f8c4ac0c368074c111d5455ea6c8ade |
with byvalue return value or parameter.
currently we don't codegen byvalue parameters or return values
correctly for C compatibilty functions so instead of generating
incorrect code, we emit a compile error.
eventually we'll support this feature and remove the compile error.
See #1803 files changed, 17 insertions(+), 16 deletions(-)
src/analyze.cpp+8-2| ... | @@ -6903,9 +6903,9 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { | ... | @@ -6903,9 +6903,9 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 6903 | add_node_error(g, param_decl_node, buf_sprintf("noalias on non-pointer parameter")); | 6903 | add_node_error(g, param_decl_node, buf_sprintf("noalias on non-pointer parameter")); |
| 6904 | } | 6904 | } |
| 6905 | 6905 | ||
| 6906 | if (fn_type->data.fn.fn_type_id.is_extern && type->id == TypeTableEntryIdStruct) { | 6906 | if (fn_type->data.fn.fn_type_id.is_extern && handle_is_ptr(type)) { |
| 6907 | add_node_error(g, param_decl_node, | 6907 | add_node_error(g, param_decl_node, |
| 6908 | buf_sprintf("byvalue struct parameters not yet supported on extern functions")); | 6908 | buf_sprintf("byvalue types not yet supported on extern function parameters")); |
| 6909 | } | 6909 | } |
| 6910 | 6910 | ||
| 6911 | if (buf_len(param_decl->name) == 0) { | 6911 | if (buf_len(param_decl->name) == 0) { |
| ... | @@ -6927,6 +6927,12 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { | ... | @@ -6927,6 +6927,12 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 6927 | } | 6927 | } |
| 6928 | 6928 | ||
| 6929 | TypeTableEntry *expected_type = fn_type->data.fn.fn_type_id.return_type; | 6929 | TypeTableEntry *expected_type = fn_type->data.fn.fn_type_id.return_type; |
| 6930 | |||
| 6931 | if (fn_type->data.fn.fn_type_id.is_extern && handle_is_ptr(expected_type)) { | ||
| 6932 | add_node_error(g, fn_proto_node->data.fn_proto.return_type, | ||
| 6933 | buf_sprintf("byvalue types not yet supported on extern function return values")); | ||
| 6934 | } | ||
| 6935 | |||
| 6930 | TypeTableEntry *block_return_type = analyze_expression(g, import, context, expected_type, node->data.fn_def.body); | 6936 | TypeTableEntry *block_return_type = analyze_expression(g, import, context, expected_type, node->data.fn_def.body); |
| 6931 | 6937 | ||
| 6932 | node->data.fn_def.implicit_return_type = block_return_type; | 6938 | node->data.fn_def.implicit_return_type = block_return_type; |
std/compiler_rt.zig-12| ... | @@ -210,18 +210,6 @@ export fn __umoddi3(a: du_int, b: du_int) -> du_int { | ... | @@ -210,18 +210,6 @@ export fn __umoddi3(a: du_int, b: du_int) -> du_int { |
| 210 | return r; | 210 | return r; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | struct AeabiUlDivModResult { | ||
| 214 | quot: u64, | ||
| 215 | rem: u64, | ||
| 216 | } | ||
| 217 | #debug_safety(false) | ||
| 218 | export fn __aeabi_uldivmod(numerator: u64, denominator: u64) -> AeabiUlDivModResult{ | ||
| 219 | var result: AeabiUlDivModResult = undefined; | ||
| 220 | result.quot = __udivmoddi4(numerator, denominator, &result.rem); | ||
| 221 | return result; | ||
| 222 | } | ||
| 223 | |||
| 224 | |||
| 225 | #attribute("test") | 213 | #attribute("test") |
| 226 | fn test_umoddi3() { | 214 | fn test_umoddi3() { |
| 227 | test_one_umoddi3(0, 1, 0); | 215 | test_one_umoddi3(0, 1, 0); |
test/run_tests.cpp+9-2| ... | @@ -884,10 +884,17 @@ var a : i32 = 1; | ... | @@ -884,10 +884,17 @@ var a : i32 = 1; |
| 884 | var a : i32 = 2; | 884 | var a : i32 = 2; |
| 885 | )SOURCE", 1, ".tmp_source.zig:3:1: error: redeclaration of variable 'a'"); | 885 | )SOURCE", 1, ".tmp_source.zig:3:1: error: redeclaration of variable 'a'"); |
| 886 | 886 | ||
| 887 | add_compile_fail_case("byvalue struct on exported functions", R"SOURCE( | 887 | add_compile_fail_case("byvalue struct parameter in exported function", R"SOURCE( |
| 888 | struct A { x : i32, } | 888 | struct A { x : i32, } |
| 889 | export fn f(a : A) {} | 889 | export fn f(a : A) {} |
| 890 | )SOURCE", 1, ".tmp_source.zig:3:13: error: byvalue struct parameters not yet supported on extern functions"); | 890 | )SOURCE", 1, ".tmp_source.zig:3:13: error: byvalue types not yet supported on extern function parameters"); |
| 891 | |||
| 892 | add_compile_fail_case("byvalue struct return value in exported function", R"SOURCE( | ||
| 893 | struct A { x: i32, } | ||
| 894 | export fn f() -> A { | ||
| 895 | A {.x = 1234 } | ||
| 896 | } | ||
| 897 | )SOURCE", 1, ".tmp_source.zig:3:18: error: byvalue types not yet supported on extern function return values"); | ||
| 891 | 898 | ||
| 892 | add_compile_fail_case("duplicate field in struct value expression", R"SOURCE( | 899 | add_compile_fail_case("duplicate field in struct value expression", R"SOURCE( |
| 893 | struct A { | 900 | struct A { |