Give an error when trying to evaluate constant expressions with long long operands.

This commit is contained in:
Stephen Heumann 2021-02-04 14:56:15 -06:00
parent 2408c9602c
commit 5e5434987b
2 changed files with 8 additions and 0 deletions

View File

@ -1058,6 +1058,10 @@ var
op^.left := Pop;
kindRight := op^.right^.token.kind;
kindLeft := op^.left^.token.kind;
if not (kind in [normalExpression,autoInitializerExpression]) then
if (kindLeft in [longlongconst,ulonglongconst])
or (kindRight in [longlongconst,ulonglongconst]) then
Error(157);
if kindRight in [intconst,uintconst,longconst,ulongconst] then begin
if kindLeft in [intconst,uintconst,longconst,ulongconst] then begin
if kind = preprocessorExpression then begin
@ -1378,6 +1382,9 @@ var
else if not (op^.token.kind in
[typedef,plusplusop,minusminusop,opplusplus,opminusminus,uand]) then
begin
if not (kind in [normalExpression,autoInitializerExpression]) then
if op^.left^.token.kind in [longlongconst,ulonglongconst] then
Error(157);
if (op^.left^.token.kind
in [intconst,uintconst,longconst,ulongconst]) then begin

View File

@ -687,6 +687,7 @@ if list or (numErr <> 0) then begin
154: msg := @'lint: function declared _Noreturn can return or has unreachable code';
155: msg := @'lint: non-void function may not return a value or has unreachable code';
156: msg := @'invalid suffix on numeric constant';
157: msg := @'ORCA/C cannot evaluate this constant expression with long long operand(s)';
otherwise: Error(57);
end; {case}
writeln(msg^);