parser: fix variadic function unused var C error

pull/2326/head
joe-conigliaro 2019-10-14 00:58:54 +11:00 committed by Alexander Medvednikov
parent 53c64abdeb
commit a90427a663
1 changed files with 12 additions and 11 deletions

View File

@ -3475,7 +3475,10 @@ fn (p mut Parser) for_st() {
else { typ.right(pad) }
// typ = strings.Replace(typ, "_ptr", "*", -1)
mut i_var_type := 'int'
if is_arr {
if is_variadic_arg {
p.gen_for_varg_header(i, expr, typ, val)
}
else if is_arr {
p.gen_for_header(i, tmp, var_typ, val)
}
else if is_map {
@ -3486,9 +3489,6 @@ fn (p mut Parser) for_st() {
i_var_type = 'byte'
p.gen_for_str_header(i, tmp, var_typ, val)
}
else if is_variadic_arg {
p.gen_for_varg_header(i, expr, typ, val)
}
// Register temp vars
if i != '_' {
p.register_var(Var {
@ -3542,7 +3542,14 @@ fn (p mut Parser) for_st() {
// TODO var_type := if...
i := p.get_tmp()
mut var_type := typ
if is_arr {
if is_variadic_arg {
p.gen_for_varg_header(i, expr, typ, val)
}
else if is_range {
var_type = 'int'
p.gen_for_range_header(i, range_end, tmp, var_type, val)
}
else if is_arr {
var_type = typ.right(6)// all after `array_`
p.gen_for_header(i, tmp, var_type, val)
}
@ -3550,12 +3557,6 @@ fn (p mut Parser) for_st() {
var_type = 'byte'
p.gen_for_str_header(i, tmp, var_type, val)
}
else if is_range {
var_type = 'int'
p.gen_for_range_header(i, range_end, tmp, var_type, val)
} else if is_variadic_arg {
p.gen_for_varg_header(i, expr, typ, val)
}
// println('for typ=$typ vartyp=$var_typ')
// Register temp var
if val != '_' {