Skip to content

Commit e448694

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 95a746b commit e448694

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
@@ -1280,7 +1280,7 @@ pub const SrcLoc = struct {
12801280
const node = src_loc.relativeToNodeIndex(node_off);
12811281
var buf: [1]Ast.Node.Index = undefined;
12821282
const full = tree.fullFnProto(&buf, node).?;
1283-
return tree.nodeToSpan(full.ast.callconv_expr);
1283+
return tree.nodeToSpan(if (full.ast.callconv_expr != 0) full.ast.callconv_expr else node);
12841284
},
12851285

12861286
.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)