mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-03 10:29:41 +00:00
Allow unsigned constants in "address+constant" constant expressions.
This affected initializers like the following: static int a[50]; static int *ip = &a[0] + 2U; Also, introduce some basic range checks for calculations that are obviously outside the 65816's address space.
This commit is contained in:
parent
a3050c76a9
commit
32ae4c2e17
29
Parser.pas
29
Parser.pas
@ -1852,8 +1852,13 @@ var
|
|||||||
size := rtree^.token.ival
|
size := rtree^.token.ival
|
||||||
else if rtree^.token.kind in [longconst,ulongconst] then
|
else if rtree^.token.kind in [longconst,ulongconst] then
|
||||||
size := rtree^.token.lval
|
size := rtree^.token.lval
|
||||||
else if rtree^.token.kind in [longlongconst,ulonglongconst] then
|
else if rtree^.token.kind in [longlongconst,ulonglongconst] then begin
|
||||||
size := rtree^.token.qval.lo
|
size := rtree^.token.qval.lo;
|
||||||
|
with rtree^.token.qval do
|
||||||
|
if not (((hi = 0) and (lo & $ff000000 = 0)) or
|
||||||
|
((hi = -1) and (lo & $ff000000 = $ff000000))) then
|
||||||
|
Error(6);
|
||||||
|
end {else if}
|
||||||
else begin
|
else begin
|
||||||
Error(18);
|
Error(18);
|
||||||
errorFound := true;
|
errorFound := true;
|
||||||
@ -2085,13 +2090,25 @@ var
|
|||||||
operator := tree^.token.kind;
|
operator := tree^.token.kind;
|
||||||
while operator in [plusch,minusch] do begin
|
while operator in [plusch,minusch] do begin
|
||||||
with tree^.right^.token do
|
with tree^.right^.token do
|
||||||
if kind in [intConst,longConst,longlongConst] then begin
|
if kind in [intConst,uintconst,longConst,ulongconst,
|
||||||
|
longlongConst,ulonglongconst] then begin
|
||||||
if kind = intConst then
|
if kind = intConst then
|
||||||
offSet2 := ival
|
offSet2 := ival
|
||||||
else if kind = longConst then
|
else if kind = uintConst then
|
||||||
offset2 := lval
|
offset2 := ival & $0000ffff
|
||||||
else {if kind = longlongConst then}
|
else if kind in [longConst,ulongconst] then begin
|
||||||
|
offset2 := lval;
|
||||||
|
if (lval & $ff000000 <> 0)
|
||||||
|
and (lval & $ff000000 <> $ff000000) then
|
||||||
|
Error(6);
|
||||||
|
end {else if}
|
||||||
|
else {if kind = longlongConst then} begin
|
||||||
offset2 := qval.lo;
|
offset2 := qval.lo;
|
||||||
|
with qval do
|
||||||
|
if not (((hi = 0) and (lo & $ff000000 = 0)) or
|
||||||
|
((hi = -1) and (lo & $ff000000 = $ff000000))) then
|
||||||
|
Error(6);
|
||||||
|
end; {else}
|
||||||
if operator = plusch then
|
if operator = plusch then
|
||||||
offset := offset + offset2
|
offset := offset + offset2
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user