Added fix from Duncan Forster for bug #85

git-svn-id: http://picoc.googlecode.com/svn/trunk@468 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2010-07-21 05:45:44 +00:00
parent e744c816c5
commit 6cc5724395

View file

@ -771,6 +771,24 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
ExpressionAssign(Parser, BottomValue, TopValue, FALSE, NULL, 0, FALSE); ExpressionAssign(Parser, BottomValue, TopValue, FALSE, NULL, 0, FALSE);
ExpressionStackPushValueNode(Parser, StackTop, BottomValue); ExpressionStackPushValueNode(Parser, StackTop, BottomValue);
} }
else if (Op == TokenAddAssign || Op == TokenSubtractAssign)
{
/* pointer arithmetic */
int Size = TypeSize(BottomValue->Typ->FromType, 0, TRUE);
Pointer = BottomValue->Val->Pointer;
if (Pointer == NULL)
ProgramFail(Parser, "invalid use of a NULL pointer");
if (Op == TokenAddAssign)
Pointer = (void *)((char *)Pointer + TopInt * Size);
else
Pointer = (void *)((char *)Pointer - TopInt * Size);
HeapUnpopStack(sizeof(struct Value)); /* XXX - possible bug if lvalue is a temp value and takes more than sizeof(struct Value) */
BottomValue->Val->Pointer = Pointer;
ExpressionStackPushValueNode(Parser, StackTop, BottomValue);
}
else else
ProgramFail(Parser, "invalid operation"); ProgramFail(Parser, "invalid operation");
} }