Skip to content

Commit 505a247

Browse files
authored
cgen: fix struct field name using c keyword typeof (fix #22779) (#22782)
1 parent 107167a commit 505a247

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

vlib/v/gen/c/cgen.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const c_reserved = ['asm', 'array', 'auto', 'bool', 'break', 'calloc', 'case', '
2525
'exit', 'export', 'extern', 'false', 'float', 'for', 'free', 'goto', 'if', 'inline', 'int',
2626
'link', 'long', 'malloc', 'namespace', 'new', 'nil', 'panic', 'register', 'restrict', 'return',
2727
'short', 'signed', 'sizeof', 'static', 'string', 'struct', 'switch', 'typedef', 'typename',
28-
'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small', 'stdout',
29-
'stdin', 'stderr', 'far', 'near', 'huge', 'requires']
28+
'typeof', 'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small',
29+
'stdout', 'stdin', 'stderr', 'far', 'near', 'huge', 'requires']
3030
const c_reserved_chk = token.new_keywords_matcher_from_array_trie(c_reserved)
3131
// same order as in token.Kind
3232
const cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le']
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct Keywords {
2+
typeof u8
3+
}
4+
5+
fn test_struct_field_name_using_c_reserved() {
6+
key := Keywords{}
7+
println(key)
8+
assert true
9+
}

0 commit comments

Comments
 (0)