Do not corrupt long long expressions that cannot be evaluated at compile time.

The changes to constant expressions were not allowing the unsupported constant expressions to be evaluated at run time when they appear in regular code.
This commit is contained in:
Stephen Heumann 2021-02-13 21:14:26 -06:00
parent c48811add6
commit e8b860f89a

View File

@ -1230,6 +1230,7 @@ var
goto 1; goto 1;
end; {if} end; {if}
end; {if} end; {if}
if kindRight in [intconst,uintconst,longconst,ulongconst, if kindRight in [intconst,uintconst,longconst,ulongconst,
longlongconst,ulonglongconst] then begin longlongconst,ulonglongconst] then begin
if kindLeft in [intconst,uintconst,longconst,ulongconst, if kindLeft in [intconst,uintconst,longconst,ulongconst,
@ -1248,10 +1249,6 @@ var
GetLongLongVal(llop1, op^.left^.token); GetLongLongVal(llop1, op^.left^.token);
GetLongLongVal(llop2, op^.right^.token); GetLongLongVal(llop2, op^.right^.token);
dispose(op^.right);
op^.right := nil;
dispose(op^.left);
op^.left := nil;
case op^.token.kind of case op^.token.kind of
barbarop : begin {||} barbarop : begin {||}
@ -1296,12 +1293,22 @@ var
minusch, {-} minusch, {-}
asteriskch, {*} asteriskch, {*}
slashch, {/} slashch, {/}
percentch: {%} percentch: begin {%}
if not (kind in [normalExpression,autoInitializerExpression]) if kind in [normalExpression,autoInitializerExpression]
then then goto 1;
Error(157); Error(157);
llop1 := longlong0;
op1 := 0;
if op^.token.kind in [ltch,gtch,lteqop,gteqop] then
ekind := intconst;
end;
otherwise: Error(57); otherwise: Error(57);
end; {case} end; {case}
dispose(op^.right);
op^.right := nil;
dispose(op^.left);
op^.left := nil;
op^.token.kind := ekind; op^.token.kind := ekind;
if ekind in [longlongconst,ulonglongconst] then begin if ekind in [longlongconst,ulonglongconst] then begin
op^.token.qval := llop1; op^.token.qval := llop1;
@ -1314,6 +1321,7 @@ var
goto 1; goto 1;
end; {if} end; {if}
end; {if} end; {if}
if op^.right^.token.kind in if op^.right^.token.kind in
[intconst,uintconst,longconst,ulongconst,doubleconst] then [intconst,uintconst,longconst,ulongconst,doubleconst] then
if op^.left^.token.kind in if op^.left^.token.kind in
@ -1378,6 +1386,7 @@ var
end; {else} end; {else}
goto 1; goto 1;
end; {if} end; {if}
if op^.right^.token.kind in [intconst,uintconst,longconst, if op^.right^.token.kind in [intconst,uintconst,longconst,
ulongconst,longlongconst,ulonglongconst,doubleconst] then ulongconst,longlongconst,ulonglongconst,doubleconst] then
if op^.left^.token.kind in [intconst,uintconst,longconst, if op^.left^.token.kind in [intconst,uintconst,longconst,