mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
cgen: fix codegen for a const assigned a fixed array, initialized with unsafe exprs (fix #23674) (#23676)
This commit is contained in:
parent
0632822fd4
commit
4c14e8e8de
@ -6102,6 +6102,9 @@ fn (mut g Gen) check_expr_is_const(expr ast.Expr) bool {
|
||||
ast.PrefixExpr {
|
||||
return expr.right is ast.Ident || g.check_expr_is_const(expr.right)
|
||||
}
|
||||
ast.UnsafeExpr {
|
||||
return g.check_expr_is_const(expr.expr)
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
|
1
vlib/v/gen/c/testdata/fixed_arr_const_unsafe.c.must_have
vendored
Normal file
1
vlib/v/gen/c/testdata/fixed_arr_const_unsafe.c.must_have
vendored
Normal file
@ -0,0 +1 @@
|
||||
Array_fixed_int_literal_ptr1_8 weapon_keys = {&_const_main__key_weapon1, &_const_main__key_weapon2, &_const_main__key_weapon3, &_const_main__key_weapon4, &_const_main__key_weapon5, &_const_main__key_weapon6, &_const_main__key_weapon7, &_const_main__key_weapon8}; // fixed array const
|
15
vlib/v/gen/c/testdata/fixed_arr_const_unsafe.vv
vendored
Normal file
15
vlib/v/gen/c/testdata/fixed_arr_const_unsafe.vv
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// vtest vflags: -no-skip-unused
|
||||
|
||||
const key_weapon1 = 1
|
||||
const key_weapon2 = 1
|
||||
const key_weapon3 = 1
|
||||
const key_weapon4 = 1
|
||||
const key_weapon5 = 1
|
||||
const key_weapon6 = 1
|
||||
const key_weapon7 = 1
|
||||
const key_weapon8 = 1
|
||||
|
||||
@[export: 'weapon_keys']
|
||||
const weapon_keys = [unsafe { &key_weapon1 }, unsafe { &key_weapon2 }, unsafe { &key_weapon3 },
|
||||
unsafe { &key_weapon4 }, unsafe { &key_weapon5 }, unsafe { &key_weapon6 }, unsafe { &key_weapon7 },
|
||||
unsafe { &key_weapon8 }]!
|
Loading…
x
Reference in New Issue
Block a user