Fix pointer issue and test

This commit is contained in:
Joey Yakimowich-Payne 2020-05-05 14:47:42 -06:00
commit e69aafa40d
3 changed files with 12 additions and 1 deletions

View file

@ -548,7 +548,15 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode =
# Input -> true, false
# Output -> true, false
result = gState.parseString(node.val)
of "type_descriptor", "sized_type_specifier":
of "type_descriptor":
let pointerDecl = node.anyChildInTree("abstract_pointer_declarator")
if pointerDecl.isNil:
result = gState.processTSNode(node[0], typeofNode)
else:
result = nkPtrTy.newTree(
gState.processTSNode(node[0], typeofNode)
)
of "sized_type_specifier", "primitive_type", "type_identifier":
# Input -> int, unsigned int, long int, etc
# Output -> cint, cuint, clong, etc
let ty = getType(node.val)

View file

@ -20,6 +20,7 @@ extern "C" {
#define COERCE 645635634896ull + 35436
#define COERCE2 645635634896 + 35436ul
#define BINEXPR ~(-(1u << !-1)) ^ (10 >> 1)
#define POINTEREXPR (int*)0
#define BOOL true
#define MATHEXPR (1 + 2/3*20 - 100)
#define ANDEXPR (100 & 11000)

View file

@ -150,6 +150,8 @@ assert SHL1 == (1.uint shl 1)
assert SHL2 == (1.uint shl 2)
assert SHL3 == (1.uint shl 3)
assert typeof(POINTEREXPR) is (ptr cint)
assert ALLSHL == (SHL1 or SHL2 or SHL3)
assert A0 is object