1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: add all C reserved words to CReserved

This commit is contained in:
Delyan Angelov 2019-08-26 20:04:57 +03:00 committed by Alexander Medvednikov
parent d88315d789
commit 99c9410cc2
2 changed files with 37 additions and 3 deletions

View File

@ -124,7 +124,7 @@ fn (p mut Parser) select_query(fn_ph int) string {
for i, field in fields { for i, field in fields {
mut cast := '' mut cast := ''
if field.typ == 'int' { if field.typ == 'int' {
cast = 'string_int' cast = 'v_string_int'
} }
obj_gen.writeln('${qprefix}$tmp . $field.name = $cast( *(string*)array__get(${qprefix}row.vals, $i) );') obj_gen.writeln('${qprefix}$tmp . $field.name = $cast( *(string*)array__get(${qprefix}row.vals, $i) );')
} }

View File

@ -102,10 +102,44 @@ const (
'error', 'error',
'malloc', 'malloc',
'calloc', 'calloc',
'char',
'free', 'free',
'panic', 'panic',
'register'
// Full list of C reserved words, from: https://en.cppreference.com/w/c/keyword
'auto',
'break',
'case',
'char',
'const',
'continue',
'default',
'do',
'double',
'else',
'enum',
'extern',
'float',
'for',
'goto',
'if',
'inline',
'int',
'long',
'register',
'restrict',
'return',
'short',
'signed',
'sizeof',
'static',
'struct',
'switch',
'typedef',
'union',
'unsigned',
'void',
'volatile',
'while',
] ]
) )