Fix so the result of sizeof has type unsigned long (i.e. size_t), not signed long.

The following test case demonstrates the problem:

#include <stdio.h>

int main (void)
{
        if (sizeof(int) - 5 < 0) puts("error 1");
        if (sizeof &main - 9 < 0) puts("error 2");
}
This commit is contained in:
Stephen Heumann 2016-11-05 00:24:22 -05:00
parent 26a800e667
commit 5950002d03

View File

@ -1188,7 +1188,7 @@ var
op^.left := Pop;
if op^.token.kind = sizeofsy then begin
op^.token.kind := longConst;
op^.token.kind := ulongConst;
op^.token.class := longConstant;
if op^.left^.token.kind = stringConst then
op^.token.lval := op^.left^.token.sval^.length+1
@ -1604,7 +1604,7 @@ if token.kind in startExpression then begin
sp^.left := nil;
sp^.middle := nil;
sp^.right := nil;
sp^.token.kind := longconst;
sp^.token.kind := ulongconst;
sp^.token.class := longConstant;
sp^.token.lval := typeSpec^.size;
if typeSpec^.kind = arrayType then