fix warning for cast to pointer from integer of different size, enhance conditional check of pointer to 'if' test

This commit is contained in:
Joseph Poirier 2015-06-14 17:27:41 -05:00
parent 62d1695632
commit 63cd9d074b
3 changed files with 24 additions and 1 deletions

View file

@ -769,8 +769,9 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
(void*)((char*)TopValue->Val->Pointer-Size);
break;
case TokenUnaryNot:
/* conditionally checking a pointer's value */
TopValue->Val->Pointer =
(void*)((char*)(!TopValue->Val->Pointer));
(void*)((TopValue->Val->Pointer) ? NULL : (void*)1);
break;
default:
ProgramFail(Parser, "invalid operation");

View file

@ -13,5 +13,23 @@ if (b)
else
printf("b is false\n");
int *c = 0;
if (c)
printf("c is true\n");
else
printf("c is false\n");
if (!c)
printf("c is true\n");
else
printf("c is false\n");
c = &b;
if (c)
printf("c is true\n");
else
printf("c is false\n");
if (!c)
printf("c is true\n");
else
printf("c is false\n");
void main() {}

View file

@ -1,2 +1,6 @@
a is true
b is false
c is false
c is true
c is true
c is false