mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-11 13:29:36 +00:00
Fix bad code generation in some cases where compound assignment operators are used to update a value through a pointer.
This could occur because a temporary location might be used both in the l-value and r-value computations, but the final assignment code assumed it still had the value from the l-value computation. The following function demonstrates this problem (*ip is not updated, and *p is trashed): int badinc(char **p, int *ip) { *ip += *(*p)++; }
This commit is contained in:
parent
5969d80e57
commit
afe3e9586b
|
@ -2967,6 +2967,7 @@ case tree^.token.kind of
|
||||||
doingScalar := true;
|
doingScalar := true;
|
||||||
LoadScalar(id);
|
LoadScalar(id);
|
||||||
lType := id^.itype;
|
lType := id^.itype;
|
||||||
|
t1 := 0;
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
doingScalar := false;
|
doingScalar := false;
|
||||||
|
@ -2978,7 +2979,6 @@ case tree^.token.kind of
|
||||||
Gen2t(pc_str, t1, 0, cgULong);
|
Gen2t(pc_str, t1, 0, cgULong);
|
||||||
Gen2t(pc_lod, t1, 0, cgULong);
|
Gen2t(pc_lod, t1, 0, cgULong);
|
||||||
Gen2t(pc_lod, t1, 0, cgULong);
|
Gen2t(pc_lod, t1, 0, cgULong);
|
||||||
FreeTemp(t1, cgLongSize);
|
|
||||||
lType := expressionType^.pType;
|
lType := expressionType^.pType;
|
||||||
if isBitField then begin
|
if isBitField then begin
|
||||||
if unsigned then
|
if unsigned then
|
||||||
|
@ -3150,6 +3150,8 @@ case tree^.token.kind of
|
||||||
end; {else}
|
end; {else}
|
||||||
Gen0t(pc_bno, lType^.baseType);
|
Gen0t(pc_bno, lType^.baseType);
|
||||||
end; {else}
|
end; {else}
|
||||||
|
if t1 <> 0 then
|
||||||
|
FreeTemp(t1, cgLongSize);
|
||||||
end; {with}
|
end; {with}
|
||||||
|
|
||||||
commach: begin {,}
|
commach: begin {,}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user