| author | |
| committer | |
| log | d7b93c78769360c954a364613c1c1b382020da0a |
| tree | 363328ae0821551f48c9079ef8fd84c38f2835cf |
| parent | 86064e66d60241ae1c56c6852ebd1ad880edfcce |
As calling convention may not be specified explicitly in the source,
so use va_arg's location instead.
Signed-off-by: Tw <tw19881113@gmail.com>2 files changed, 11 insertions(+), 5 deletions(-)
src/Sema.zig+7-1| ... | ... | @@ -9669,7 +9669,13 @@ fn funcCommon( |
| 9669 | 9669 | if (is_generic) { |
| 9670 | 9670 | return sema.fail(block, func_src, "generic function cannot be variadic", .{}); |
| 9671 | 9671 | } |
| 9672 | try sema.checkCallConvSupportsVarArgs(block, cc_src, cc); | |
| 9672 | const va_args_src = block.src(.{ | |
| 9673 | .fn_proto_param = .{ | |
| 9674 | .fn_proto_node_offset = src_node_offset, | |
| 9675 | .param_index = @intCast(block.params.len), // va_arg must be the last parameter | |
| 9676 | }, | |
| 9677 | }); | |
| 9678 | try sema.checkCallConvSupportsVarArgs(block, va_args_src, cc); | |
| 9673 | 9679 | } |
| 9674 | 9680 | |
| 9675 | 9681 | const ret_poison = bare_return_type.isGenericPoison(); |
test/cases/compile_errors/invalid_variadic_function.zig+4-4| ... | ... | @@ -11,7 +11,7 @@ comptime { |
| 11 | 11 | // error |
| 12 | 12 | // target=x86_64-linux |
| 13 | 13 | // |
| 14 | // :1:1: error: variadic function does not support 'auto' calling convention | |
| 15 | // :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' | |
| 14 | // :1:8: error: variadic function does not support 'auto' calling convention | |
| 15 | // :1:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' | |
| 16 | // :2:16: error: variadic function does not support 'inline' calling convention | |
| 17 | // :2:16: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' |