Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser,checker: silence more warnings for
@[translated]
files (#20964)
- Loading branch information
Showing
25 changed files
with
157 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
9 changes: 9 additions & 0 deletions
9
vlib/v/checker/tests/no_arrays_of_references_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@[translated] | ||
module main | ||
|
||
fn main() { | ||
println(*[]&int{len: 1}[0]) | ||
println([1]&int{}) | ||
_ = [][1]&int{len: 1}[0][0] | ||
_ = []map[int]&int{len: 1} | ||
} |
Empty file.
13 changes: 13 additions & 0 deletions
13
vlib/v/checker/tests/no_cannot_cast_a_fixed_array_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@[translated] | ||
module main | ||
|
||
fn main() { | ||
mut array := [3]int{} | ||
mut arrayptr := &int(array) | ||
|
||
for _ in 0 .. 3 { | ||
unsafe { | ||
*(arrayptr++) = 0 | ||
} | ||
} | ||
} |
Empty file.
8 changes: 8 additions & 0 deletions
8
vlib/v/checker/tests/no_function_must_be_called_from_unsafe_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@[translated] | ||
module main | ||
|
||
fn main() { | ||
mut p := C.malloc(4) | ||
s := 'hope' | ||
C.memcpy(p, s.str, 4) | ||
} |
Empty file.
17 changes: 17 additions & 0 deletions
17
vlib/v/checker/tests/no_goto_requires_unsafe_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@[translated] | ||
module main | ||
|
||
fn f() { | ||
goto f2 | ||
goto a1 | ||
a1: | ||
goto a1 | ||
f2: | ||
goto a1 | ||
} | ||
|
||
fn main() { | ||
goto m1 | ||
m1: | ||
println('done') | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
vlib/v/checker/tests/no_method_must_be_called_from_unsafe_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@[translated] | ||
module main | ||
|
||
struct S1 {} | ||
|
||
@[unsafe] | ||
fn (s S1) f() {} | ||
|
||
fn main() { | ||
s := S1{} | ||
s.f() | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
vlib/v/checker/tests/no_operator_can_only_be_used_as_a_statement_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@[translated] | ||
module main | ||
|
||
fn f(i int) {} | ||
|
||
fn main() { | ||
mut x := 1 | ||
_ = (x++) | ||
x--, x-- // OK | ||
f(x++) | ||
a := [x, 2 * x] | ||
dump(x) | ||
z := a[x--] | ||
dump(z) | ||
} |
Empty file.
17 changes: 17 additions & 0 deletions
17
vlib/v/checker/tests/no_pointer_arithmetic_is_only_allowed_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@[translated] | ||
module main | ||
|
||
fn main() { | ||
mut v := 5 | ||
mut p := &v | ||
p++ | ||
p += 2 | ||
_ := v | ||
|
||
v2 := 4 | ||
mut q2 := &v2 - 1 | ||
q2 = q2 + 3 | ||
_ := q2 | ||
_ := v2 | ||
println('done') | ||
} |
Empty file.
17 changes: 17 additions & 0 deletions
17
vlib/v/checker/tests/no_reading_a_union_field_in_translated.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@[translated] | ||
module main | ||
|
||
union Uf32 { | ||
mut: | ||
f f32 | ||
u u32 | ||
} | ||
|
||
fn main() { | ||
mut u := Uf32{ | ||
u: 3 | ||
} | ||
u.f = 3.3 // ok | ||
x := u.u | ||
dump(x) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@[translated] | ||
module main | ||
|
||
fn main() { | ||
a := 123 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters