Fixes issue #5

This commit is contained in:
Joseph Poirier 2015-06-14 17:03:55 -05:00
parent 09501d22fd
commit 62d1695632

View file

@ -755,7 +755,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
int Size = TypeSize(TopValue->Typ->FromType, 0, true);
struct Value *StackValue;
void *ResultPtr;
if (TopValue->Val->Pointer == NULL)
if (Op != TokenUnaryNot && TopValue->Val->Pointer == NULL)
ProgramFail(Parser, "a. invalid use of a NULL pointer");
if (!TopValue->IsLValue)
ProgramFail(Parser, "can't assign to this");
@ -768,6 +768,10 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
TopValue->Val->Pointer =
(void*)((char*)TopValue->Val->Pointer-Size);
break;
case TokenUnaryNot:
TopValue->Val->Pointer =
(void*)((char*)(!TopValue->Val->Pointer));
break;
default:
ProgramFail(Parser, "invalid operation");
break;