diff --git a/src/Sema.zig b/src/Sema.zig index d3ca6a8cc5..593b299833 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -6654,7 +6654,11 @@ fn zirFunc( src_locs = sema.code.extraData(Zir.Inst.Func.SrcLocs, extra_index).data; } - const cc: std.builtin.CallingConvention = if (sema.owner_decl.is_exported) + // If this instruction has a body it means it's the type of the `owner_decl` + // otherwise it's a function type without a `callconv` attribute and should + // never be `.C`. + // NOTE: revisit when doing #1717 + const cc: std.builtin.CallingConvention = if (sema.owner_decl.is_exported and has_body) .C else .Unspecified; diff --git a/test/cases/compile_errors/runtime_indexing_comptime_array.zig b/test/cases/compile_errors/runtime_indexing_comptime_array.zig index da603d3630..3acd0feb61 100644 --- a/test/cases/compile_errors/runtime_indexing_comptime_array.zig +++ b/test/cases/compile_errors/runtime_indexing_comptime_array.zig @@ -23,9 +23,9 @@ pub export fn entry3() void { // error // backend=stage2,llvm // -// :6:33: error: values of type '[2]fn() callconv(.C) void' must be comptime known, but index value is runtime known -// :6:33: note: use '*const fn() callconv(.C) void' for a function pointer type -// :13:33: error: values of type '[2]fn() callconv(.C) void' must be comptime known, but index value is runtime known -// :13:33: note: use '*const fn() callconv(.C) void' for a function pointer type -// :19:33: error: values of type '[2]fn() callconv(.C) void' must be comptime known, but index value is runtime known -// :19:33: note: use '*const fn() callconv(.C) void' for a function pointer type +// :6:5: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known +// :6:5: note: use '*const fn() void' for a function pointer type +// :13:5: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known +// :13:5: note: use '*const fn() void' for a function pointer type +// :19:5: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known +// :19:5: note: use '*const fn() void' for a function pointer type