authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 18:34:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 19:02:06-07:00
log8daa8d255b84880de60dc1a86d2f1d4a89463bbc
tree59b91d81929943f420ebf5c5c1af368fe26937fd
parent727b371bbc53b1fcabb6c6899043da3a84195b3c

Sema: fix fn_proto_param LazySrcLoc resolution

to match source code span from merge-base.

5 files changed, 14 insertions(+), 7 deletions(-)

src/Module.zig+9-2
......@@ -2152,8 +2152,15 @@ pub const SrcLoc = struct {
21522152 while (it.next()) |param| : (i += 1) {
21532153 if (i == fn_proto_param.param_index) {
21542154 if (param.anytype_ellipsis3) |token| return tokenToSpan(tree, token);
2155 if (param.name_token) |token| return tokenToSpan(tree, token);
2156 return nodeToSpan(tree, param.type_expr);
2155 const first_token = param.comptime_noalias orelse
2156 param.name_token orelse
2157 tree.firstToken(param.type_expr);
2158 return tokensToSpan(
2159 tree,
2160 first_token,
2161 tree.lastToken(param.type_expr),
2162 first_token,
2163 );
21572164 }
21582165 }
21592166 unreachable;
test/cases/compile_errors/array_in_c_exported_function.zig+2-2
......@@ -10,7 +10,7 @@ export fn zig_return_array() [10]u8 {
1010// backend=stage2
1111// target=native
1212//
13// :1:24: error: parameter of type '[10]u8' not allowed in function with calling convention 'C'
14// :1:24: note: arrays are not allowed as a parameter type
13// :1:21: error: parameter of type '[10]u8' not allowed in function with calling convention 'C'
14// :1:21: note: arrays are not allowed as a parameter type
1515// :5:30: error: return type '[10]u8' not allowed in function with calling convention 'C'
1616// :5:30: note: arrays are not allowed as a return type
test/cases/compile_errors/export_function_with_comptime_parameter.zig+1-1
......@@ -6,4 +6,4 @@ export fn foo(comptime x: anytype, y: i32) i32 {
66// backend=stage2
77// target=native
88//
9// :1:15: error: comptime parameters not allowed in function with calling convention 'C'
9// :1:27: error: comptime parameters not allowed in function with calling convention 'C'
test/cases/compile_errors/export_generic_function.zig+1-1
......@@ -7,4 +7,4 @@ export fn foo(num: anytype) i32 {
77// backend=stage2
88// target=native
99//
10// :1:15: error: generic parameters not allowed in function with calling convention 'C'
10// :1:20: error: generic parameters not allowed in function with calling convention 'C'
test/cases/compile_errors/extern_function_with_comptime_parameter.zig+1-1
......@@ -19,5 +19,5 @@ comptime {
1919// target=native
2020//
2121// :5:30: error: comptime parameters not allowed in function with calling convention 'C'
22// :6:30: error: generic parameters not allowed in function with calling convention 'C'
22// :6:41: error: generic parameters not allowed in function with calling convention 'C'
2323// :1:15: error: comptime parameters not allowed in function with calling convention 'C'