diff --git a/src/Module.zig b/src/Module.zig index 0467688974c49cb34842b3e3e249a8a66da581b2..ea444d3cc4b4e598b39f90501bbebe197c630bb4 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2152,8 +2152,15 @@ pub const SrcLoc = struct { while (it.next()) |param| : (i += 1) { if (i == fn_proto_param.param_index) { if (param.anytype_ellipsis3) |token| return tokenToSpan(tree, token); - if (param.name_token) |token| return tokenToSpan(tree, token); - return nodeToSpan(tree, param.type_expr); + const first_token = param.comptime_noalias orelse + param.name_token orelse + tree.firstToken(param.type_expr); + return tokensToSpan( + tree, + first_token, + tree.lastToken(param.type_expr), + first_token, + ); } } unreachable; diff --git a/test/cases/compile_errors/array_in_c_exported_function.zig b/test/cases/compile_errors/array_in_c_exported_function.zig index 0d31f69370f5954f834880263c96efc7208bada1..e938b6afd4b60fa20a4561291c7f7b90da5f9c42 100644 --- a/test/cases/compile_errors/array_in_c_exported_function.zig +++ b/test/cases/compile_errors/array_in_c_exported_function.zig @@ -10,7 +10,7 @@ export fn zig_return_array() [10]u8 { // backend=stage2 // target=native // -// :1:24: error: parameter of type '[10]u8' not allowed in function with calling convention 'C' -// :1:24: note: arrays are not allowed as a parameter type +// :1:21: error: parameter of type '[10]u8' not allowed in function with calling convention 'C' +// :1:21: note: arrays are not allowed as a parameter type // :5:30: error: return type '[10]u8' not allowed in function with calling convention 'C' // :5:30: note: arrays are not allowed as a return type diff --git a/test/cases/compile_errors/export_function_with_comptime_parameter.zig b/test/cases/compile_errors/export_function_with_comptime_parameter.zig index 8d5dbef1c36c20968a9139e42dc7b2990101103c..948053534dba92d3cdcd39b4a8feb5eb9eda6f46 100644 --- a/test/cases/compile_errors/export_function_with_comptime_parameter.zig +++ b/test/cases/compile_errors/export_function_with_comptime_parameter.zig @@ -6,4 +6,4 @@ export fn foo(comptime x: anytype, y: i32) i32 { // backend=stage2 // target=native // -// :1:15: error: comptime parameters not allowed in function with calling convention 'C' +// :1:27: error: comptime parameters not allowed in function with calling convention 'C' diff --git a/test/cases/compile_errors/export_generic_function.zig b/test/cases/compile_errors/export_generic_function.zig index 4ffbad9df7d972e74364e91448c2cae9a334a218..65469be6d94213437660c465a5d93f47fccd397a 100644 --- a/test/cases/compile_errors/export_generic_function.zig +++ b/test/cases/compile_errors/export_generic_function.zig @@ -7,4 +7,4 @@ export fn foo(num: anytype) i32 { // backend=stage2 // target=native // -// :1:15: error: generic parameters not allowed in function with calling convention 'C' +// :1:20: error: generic parameters not allowed in function with calling convention 'C' diff --git a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig index fac09cc2651949958ca07143dcf2d04a3acf02e4..b8f5f0b1b8265c3a02bc0eb759537e0257b91d55 100644 --- a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig +++ b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig @@ -19,5 +19,5 @@ comptime { // target=native // // :5:30: error: comptime parameters not allowed in function with calling convention 'C' -// :6:30: error: generic parameters not allowed in function with calling convention 'C' +// :6:41: error: generic parameters not allowed in function with calling convention 'C' // :1:15: error: comptime parameters not allowed in function with calling convention 'C'