parent
2911f03627
commit
c057b45bb1
|
@ -1909,10 +1909,11 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type {
|
|||
if f.language != .v || call_expr.language != .v {
|
||||
// ignore C function of type `fn()`, assume untyped
|
||||
// For now don't check C functions that are variadic, underscored, capitalized
|
||||
// or have no params and return int
|
||||
// or have no params or attributes and return int
|
||||
if f.language == .c && f.params.len != call_expr.args.len && !f.is_variadic
|
||||
&& f.name[2] != `_` && !f.name[2].is_capital()
|
||||
&& (f.params.len != 0 || f.return_type !in [table.void_type, table.int_type]) {
|
||||
&& f.name[2] != `_` && !f.name[2].is_capital() && (f.params.len != 0
|
||||
|| f.return_type !in [table.void_type, table.int_type]
|
||||
|| f.attrs.len > 0) {
|
||||
// change to error later
|
||||
c.warn('expected $f.params.len arguments, but got $call_expr.args.len', call_expr.pos)
|
||||
}
|
||||
|
|
|
@ -24,4 +24,12 @@ vlib/v/checker/tests/c_fn_surplus_args.vv:13:2: error: the `main` function canno
|
|||
12 | // avoid cgen whilst warning, later above should error
|
||||
13 | main()
|
||||
| ~~~~~~
|
||||
14 | }
|
||||
14 | C.af() // ok
|
||||
15 | C.af(3)
|
||||
vlib/v/checker/tests/c_fn_surplus_args.vv:15:4: error: expected 0 arguments, but got 1
|
||||
13 | main()
|
||||
14 | C.af() // ok
|
||||
15 | C.af(3)
|
||||
| ~~~~~
|
||||
16 | }
|
||||
17 |
|
||||
|
|
|
@ -11,4 +11,9 @@ fn main() {
|
|||
C.ret(1)
|
||||
// avoid cgen whilst warning, later above should error
|
||||
main()
|
||||
C.af() // ok
|
||||
C.af(3)
|
||||
}
|
||||
|
||||
[trusted]
|
||||
fn C.af()int
|
||||
|
|
Loading…
Reference in New Issue