cgen: use `(void)` parameter list instead of `()` for type safety (#8898)

pull/8904/head
Nick Treleaven 2021-02-22 12:48:32 +00:00 committed by GitHub
parent f54c1a5cc2
commit 59446d7051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -351,6 +351,10 @@ fn (mut g Gen) write_defer_stmts_when_needed() {
fn (mut g Gen) fn_args(args []table.Param, is_variadic bool) ([]string, []string) {
mut fargs := []string{}
mut fargtypes := []string{}
if args.len == 0 {
// in C, `()` is untyped, unlike `(void)`
g.write('void')
}
for i, arg in args {
caname := if arg.name == '_' { g.new_tmp_var() } else { c_name(arg.name) }
typ := g.unwrap_generic(arg.typ)