checker: c2v fixes for enums and pointer to numbers
parent
1fdbdf4a6b
commit
4715fb67c1
|
@ -171,6 +171,9 @@ fn C.tolower(c int) int
|
||||||
[trusted]
|
[trusted]
|
||||||
fn C.toupper(c int) int
|
fn C.toupper(c int) int
|
||||||
|
|
||||||
|
[trusted]
|
||||||
|
fn C.isspace(c int) int
|
||||||
|
|
||||||
[trusted]
|
[trusted]
|
||||||
fn C.strchr(s &char, c int) &char
|
fn C.strchr(s &char, c int) &char
|
||||||
|
|
||||||
|
@ -186,6 +189,9 @@ fn C.strncasecmp(s &char, s2 &char, n int) int
|
||||||
[trusted]
|
[trusted]
|
||||||
fn C.strcasecmp(s &char, s2 &char) int
|
fn C.strcasecmp(s &char, s2 &char) int
|
||||||
|
|
||||||
|
[trusted]
|
||||||
|
fn C.strncmp(s &char, s2 &char, n int) int
|
||||||
|
|
||||||
[trusted]
|
[trusted]
|
||||||
fn C.strerror(int) &char
|
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 {
|
if got == expected {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
got_is_ptr := got.is_ptr()
|
||||||
|
exp_is_ptr := expected.is_ptr()
|
||||||
if c.pref.translated {
|
if c.pref.translated {
|
||||||
if expected == ast.byteptr_type {
|
if expected == ast.byteptr_type {
|
||||||
return true
|
return true
|
||||||
|
@ -40,9 +42,18 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool {
|
||||||
return true
|
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_is_ptr && exp_is_ptr {
|
||||||
if got.nr_muls() != expected.nr_muls() {
|
if got.nr_muls() != expected.nr_muls() {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue