Skip to content

Commit efabf07

Browse files
committed
fix incorrect error source location on function calling convention
AstGen doesn't seem to report enough information to figure out if a func decl has a calling convention ast node. A calling convention could be present without it by marking the function as inline for example.
1 parent 5d2b2b3 commit efabf07

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Zcu.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ pub const SrcLoc = struct {
14991499
const node = src_loc.relativeToNodeIndex(node_off);
15001500
var buf: [1]Ast.Node.Index = undefined;
15011501
const full = tree.fullFnProto(&buf, node).?;
1502-
return tree.nodeToSpan(full.ast.callconv_expr);
1502+
return tree.nodeToSpan(if (full.ast.callconv_expr != 0) full.ast.callconv_expr else node);
15031503
},
15041504

15051505
.node_offset_fn_type_ret_ty => |node_off| {

test/cases/compile_errors/invalid_variadic_function.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ comptime {
1313
//
1414
// :1:1: error: variadic function does not support 'auto' calling convention
1515
// :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
16-
// :1:1: error: variadic function does not support 'inline' calling convention
17-
// :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
16+
// :2:8: error: variadic function does not support 'inline' calling convention
17+
// :2:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'

0 commit comments

Comments
 (0)