mirror of
https://github.com/vlang/v.git
synced 2025-09-14 18:06:48 -04:00
cgen: add asm
to c_reserved, fixes compilation of struct Abc { @asm int }
(#22340)
This commit is contained in:
parent
4a01b2cca8
commit
2e0fa12261
@ -20,13 +20,13 @@ import sync.pool
|
||||
// in C++, or have special meaning in V, thus need escaping too. `small`
|
||||
// should not be needed, but see:
|
||||
// https://stackoverflow.com/questions/5874215/what-is-rpcndr-h
|
||||
const c_reserved = ['array', 'auto', 'bool', 'break', 'calloc', 'case', 'char', 'class', 'complex',
|
||||
'const', 'continue', 'default', 'delete', 'do', 'double', 'else', 'enum', 'error', 'exit',
|
||||
'export', 'extern', 'false', 'float', 'for', 'free', 'goto', 'if', 'inline', 'int', 'link',
|
||||
'long', 'malloc', 'namespace', 'new', 'nil', 'panic', 'register', 'restrict', 'return', 'short',
|
||||
'signed', 'sizeof', 'static', 'string', 'struct', 'switch', 'typedef', 'typename', 'union',
|
||||
'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small', 'stdout', 'stdin',
|
||||
'stderr', 'far', 'near', 'huge', 'requires']
|
||||
const c_reserved = ['asm', 'array', 'auto', 'bool', 'break', 'calloc', 'case', 'char', 'class',
|
||||
'complex', 'const', 'continue', 'default', 'delete', 'do', 'double', 'else', 'enum', 'error',
|
||||
'exit', 'export', 'extern', 'false', 'float', 'for', 'free', 'goto', 'if', 'inline', 'int',
|
||||
'link', 'long', 'malloc', 'namespace', 'new', 'nil', 'panic', 'register', 'restrict', 'return',
|
||||
'short', 'signed', 'sizeof', 'static', 'string', 'struct', 'switch', 'typedef', 'typename',
|
||||
'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small', 'stdout',
|
||||
'stdin', 'stderr', 'far', 'near', 'huge', 'requires']
|
||||
const c_reserved_chk = token.new_keywords_matcher_from_array_trie(c_reserved)
|
||||
// same order as in token.Kind
|
||||
const cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le']
|
||||
|
26
vlib/v/tests/reserved_keyword_asm_test.v
Normal file
26
vlib/v/tests/reserved_keyword_asm_test.v
Normal file
@ -0,0 +1,26 @@
|
||||
struct Abc {
|
||||
@asm string
|
||||
}
|
||||
|
||||
enum Enum {
|
||||
@asm
|
||||
end
|
||||
}
|
||||
|
||||
fn test_struct() {
|
||||
dump(Abc{})
|
||||
assert true
|
||||
}
|
||||
|
||||
fn test_local() {
|
||||
@asm := 12
|
||||
dump(@asm)
|
||||
assert true
|
||||
}
|
||||
|
||||
fn test_enum() {
|
||||
dump(unsafe { Enum(0) })
|
||||
dump(Enum.@asm)
|
||||
dump(Enum.end)
|
||||
assert true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user