Added "typeof" and "restrict" to special words. (#9226)
* Added "typeof" and "restrict" to special words. * Added C and C++ reserved keyword as object field identifier test
This commit is contained in:
parent
dbfc5c5a44
commit
eb3c9e1d1c
2 changed files with 43 additions and 4 deletions
|
|
@ -73,9 +73,9 @@ type
|
||||||
wConst_cast, wDefault, wDelete, wDouble, wDynamic_cast,
|
wConst_cast, wDefault, wDelete, wDouble, wDynamic_cast,
|
||||||
wExplicit, wExtern, wFalse, wFloat, wFriend,
|
wExplicit, wExtern, wFalse, wFloat, wFriend,
|
||||||
wGoto, wInt, wLong, wMutable, wNamespace, wNew, wOperator,
|
wGoto, wInt, wLong, wMutable, wNamespace, wNew, wOperator,
|
||||||
wPrivate, wProtected, wPublic, wRegister, wReinterpret_cast,
|
wPrivate, wProtected, wPublic, wRegister, wReinterpret_cast, wRestrict,
|
||||||
wShort, wSigned, wSizeof, wStatic_cast, wStruct, wSwitch,
|
wShort, wSigned, wSizeof, wStatic_cast, wStruct, wSwitch,
|
||||||
wThis, wThrow, wTrue, wTypedef, wTypeid, wTypename,
|
wThis, wThrow, wTrue, wTypedef, wTypeid, wTypeof, wTypename,
|
||||||
wUnion, wPacked, wUnsigned, wVirtual, wVoid, wVolatile, wWchar_t,
|
wUnion, wPacked, wUnsigned, wVirtual, wVoid, wVolatile, wWchar_t,
|
||||||
|
|
||||||
wAlignas, wAlignof, wConstexpr, wDecltype, wNullptr, wNoexcept,
|
wAlignas, wAlignof, wConstexpr, wDecltype, wNullptr, wNoexcept,
|
||||||
|
|
@ -161,9 +161,9 @@ const
|
||||||
"dynamic_cast", "explicit", "extern", "false",
|
"dynamic_cast", "explicit", "extern", "false",
|
||||||
"float", "friend", "goto", "int", "long", "mutable",
|
"float", "friend", "goto", "int", "long", "mutable",
|
||||||
"namespace", "new", "operator",
|
"namespace", "new", "operator",
|
||||||
"private", "protected", "public", "register", "reinterpret_cast",
|
"private", "protected", "public", "register", "reinterpret_cast", "restrict",
|
||||||
"short", "signed", "sizeof", "static_cast", "struct", "switch",
|
"short", "signed", "sizeof", "static_cast", "struct", "switch",
|
||||||
"this", "throw", "true", "typedef", "typeid",
|
"this", "throw", "true", "typedef", "typeid", "typeof",
|
||||||
"typename", "union", "packed", "unsigned", "virtual", "void", "volatile",
|
"typename", "union", "packed", "unsigned", "virtual", "void", "volatile",
|
||||||
"wchar_t",
|
"wchar_t",
|
||||||
|
|
||||||
|
|
|
||||||
39
tests/misc/treservedcidentsasfields.nim
Normal file
39
tests/misc/treservedcidentsasfields.nim
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
discard """
|
||||||
|
targets: "c cpp"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import macros
|
||||||
|
|
||||||
|
macro make_test_type(idents: varargs[untyped]): untyped =
|
||||||
|
result = nnkStmtList.newTree()
|
||||||
|
|
||||||
|
var ident_defs: seq[NimNode] = @[]
|
||||||
|
for i in idents:
|
||||||
|
ident_defs.add newIdentDefs(i, ident("int"))
|
||||||
|
|
||||||
|
result.add newTree(nnkTypeSection,
|
||||||
|
newTree(nnkTypeDef,
|
||||||
|
ident("TestType"),
|
||||||
|
newEmptyNode(),
|
||||||
|
newTree(nnkObjectTy,
|
||||||
|
newEmptyNode(),
|
||||||
|
newEmptyNode(),
|
||||||
|
newTree(nnkRecList,
|
||||||
|
ident_defs
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
make_test_type(
|
||||||
|
auto, bool, catch, char, class, const_cast, default, delete, double,
|
||||||
|
dynamic_cast, explicit, extern, false, float, friend, goto, int, long,
|
||||||
|
mutable, namespace, new, operator, private, protected, public, register,
|
||||||
|
reinterpret_cast, restrict, short, signed, sizeof, static_cast, struct, switch,
|
||||||
|
this, throw, true, typedef, typeid, typeof, typename, union, packed, unsigned,
|
||||||
|
virtual, void, volatile, wchar_t, alignas, alignof, constexpr, decltype, nullptr,
|
||||||
|
noexcept, thread_local, static_assert, char16_t, char32_t
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make sure the type makes it to codegen.
|
||||||
|
var test_instance: TestType
|
||||||
Loading…
Add table
Add a link
Reference in a new issue