checker: c2v fixes for enums and pointer to numbers
parent
1fdbdf4a6b
commit
4715fb67c1
|
@ -171,6 +171,9 @@ fn C.tolower(c int) int
|
|||
[trusted]
|
||||
fn C.toupper(c int) int
|
||||
|
||||
[trusted]
|
||||
fn C.isspace(c int) int
|
||||
|
||||
[trusted]
|
||||
fn C.strchr(s &char, c int) &char
|
||||
|
||||
|
@ -186,6 +189,9 @@ fn C.strncasecmp(s &char, s2 &char, n int) int
|
|||
[trusted]
|
||||
fn C.strcasecmp(s &char, s2 &char) int
|
||||
|
||||
[trusted]
|
||||
fn C.strncmp(s &char, s2 &char, n int) int
|
||||
|
||||
[trusted]
|
||||
fn C.strerror(int) &char
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool {
|
|||
if got == expected {
|
||||
return true
|
||||
}
|
||||
got_is_ptr := got.is_ptr()
|
||||
exp_is_ptr := expected.is_ptr()
|
||||
if c.pref.translated {
|
||||
if expected == ast.byteptr_type {
|
||||
return true
|
||||
|
@ -40,9 +42,18 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool {
|
|||
return true
|
||||
}
|
||||
}
|
||||
if expected_sym.kind == .enum_ && got_sym.is_number() {
|
||||
// Allow enums as numbers
|
||||
return true
|
||||
}
|
||||
if got_is_ptr && exp_is_ptr {
|
||||
// deref_sym := c.table.sym(expected.deref()) // set_nr_muls(0))
|
||||
if expected_sym.is_number() && got_sym.is_number() {
|
||||
// Allow `&&u8` used as `&&int` etc
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
got_is_ptr := got.is_ptr()
|
||||
exp_is_ptr := expected.is_ptr()
|
||||
if got_is_ptr && exp_is_ptr {
|
||||
if got.nr_muls() != expected.nr_muls() {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue