mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix more of byteptr=> &byte, vfmt check_types.v
This commit is contained in:
parent
e9b8d9ba9e
commit
9cc9ce698f
@ -54,7 +54,8 @@ pub fn (mut c Checker) check_expected_call_arg(got ast.Type, expected_ ast.Type,
|
||||
}
|
||||
idx_got := got.idx()
|
||||
idx_expected := expected.idx()
|
||||
if idx_got in [ ast.byteptr_type_idx, ast.charptr_type_idx] || idx_expected in [ast.byteptr_type_idx, ast.charptr_type_idx] {
|
||||
if idx_got in [ast.byteptr_type_idx, ast.charptr_type_idx]
|
||||
|| idx_expected in [ast.byteptr_type_idx, ast.charptr_type_idx] {
|
||||
igot := int(got)
|
||||
iexpected := int(expected)
|
||||
// TODO: remove; transitional compatibility for byteptr === &byte
|
||||
@ -69,16 +70,20 @@ pub fn (mut c Checker) check_expected_call_arg(got ast.Type, expected_ ast.Type,
|
||||
}
|
||||
muls_got := got.nr_muls()
|
||||
muls_expected := expected.nr_muls()
|
||||
if idx_got == ast.byteptr_type_idx && idx_expected == ast.byte_type_idx && muls_got + 1 == muls_expected {
|
||||
if idx_got == ast.byteptr_type_idx && idx_expected == ast.byte_type_idx
|
||||
&& muls_got + 1 == muls_expected {
|
||||
return
|
||||
}
|
||||
if idx_expected == ast.byteptr_type_idx && idx_got == ast.byte_type_idx && muls_expected + 1 == muls_got {
|
||||
if idx_expected == ast.byteptr_type_idx && idx_got == ast.byte_type_idx
|
||||
&& muls_expected + 1 == muls_got {
|
||||
return
|
||||
}
|
||||
if idx_got == ast.charptr_type_idx && idx_expected == ast.char_type_idx && muls_got + 1 == muls_expected {
|
||||
if idx_got == ast.charptr_type_idx && idx_expected == ast.char_type_idx
|
||||
&& muls_got + 1 == muls_expected {
|
||||
return
|
||||
}
|
||||
if idx_expected == ast.charptr_type_idx && idx_got == ast.char_type_idx && muls_expected + 1 == muls_got {
|
||||
if idx_expected == ast.charptr_type_idx && idx_got == ast.char_type_idx
|
||||
&& muls_expected + 1 == muls_got {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||
}
|
||||
}
|
||||
|
||||
fn C.strtol(str charptr, endptr &&char, base int) int
|
||||
fn C.strtol(str &char, endptr &&char, base int) int
|
||||
|
||||
fn (mut g Gen) expr(node ast.Expr) {
|
||||
// println('cgen expr()')
|
||||
|
@ -15,17 +15,17 @@ fn test_offsetof() {
|
||||
age: 2147483647
|
||||
}
|
||||
unsafe {
|
||||
assert *(&string(byteptr(&cat) + __offsetof(Cat, name))) == 'Cthulhu'
|
||||
assert *(&string(byteptr(&cat) + __offsetof(Cat, breed))) == 'Great Old One'
|
||||
assert *(&int(byteptr(&cat) + __offsetof(Cat, age))) == 2147483647
|
||||
assert *(&string(&byte(&cat) + __offsetof(Cat, name))) == 'Cthulhu'
|
||||
assert *(&string(&byte(&cat) + __offsetof(Cat, breed))) == 'Great Old One'
|
||||
assert *(&int(&byte(&cat) + __offsetof(Cat, age))) == 2147483647
|
||||
}
|
||||
}
|
||||
|
||||
fn test_offsetof_struct_from_another_module() {
|
||||
num := complex.Complex{1.0, 1.0}
|
||||
unsafe {
|
||||
assert *(&f64(byteptr(&num) + __offsetof(complex.Complex, re))) == 1.0
|
||||
assert *(&f64(byteptr(&num) + __offsetof(complex.Complex, im))) == 1.0
|
||||
assert *(&f64(&byte(&num) + __offsetof(complex.Complex, re))) == 1.0
|
||||
assert *(&f64(&byte(&num) + __offsetof(complex.Complex, im))) == 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,8 +36,8 @@ fn test_offsetof_alias() {
|
||||
age: 2147483647
|
||||
}
|
||||
unsafe {
|
||||
assert *(&string(byteptr(&fel) + __offsetof(Feline, name))) == 'Cthulhu'
|
||||
assert *(&string(byteptr(&fel) + __offsetof(Feline, breed))) == 'Great Old One'
|
||||
assert *(&int(byteptr(&fel) + __offsetof(Feline, age))) == 2147483647
|
||||
assert *(&string(&byte(&fel) + __offsetof(Feline, name))) == 'Cthulhu'
|
||||
assert *(&string(&byte(&fel) + __offsetof(Feline, breed))) == 'Great Old One'
|
||||
assert *(&int(&byte(&fel) + __offsetof(Feline, age))) == 2147483647
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user