Bug fix: INC/DEC evaluated argument twice(!)
This commit is contained in:
parent
f3e5c3032f
commit
81ec28ccb9
1 changed files with 52 additions and 5 deletions
|
@ -474,6 +474,23 @@ addu(sz)
|
||||||
C_adu((arith)sz);
|
C_adu((arith)sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
complex_lhs(nd)
|
||||||
|
register t_node *nd;
|
||||||
|
{
|
||||||
|
switch(nd->nd_class) {
|
||||||
|
case Value:
|
||||||
|
case Name:
|
||||||
|
case Set:
|
||||||
|
case Def:
|
||||||
|
return 0;
|
||||||
|
case Select:
|
||||||
|
return complex_lhs(nd->nd_NEXT);
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CodeStd(nd)
|
CodeStd(nd)
|
||||||
t_node *nd;
|
t_node *nd;
|
||||||
{
|
{
|
||||||
|
@ -545,10 +562,19 @@ CodeStd(nd)
|
||||||
case S_DEC:
|
case S_DEC:
|
||||||
case S_INC: {
|
case S_INC: {
|
||||||
register arith size;
|
register arith size;
|
||||||
|
int compl = complex_lhs(left);
|
||||||
|
arith tmp = 0;
|
||||||
|
|
||||||
size = left->nd_type->tp_size;
|
size = left->nd_type->tp_size;
|
||||||
if ((int) size < (int) word_size) size = word_size;
|
if ((int) size < (int) word_size) size = word_size;
|
||||||
CodePExpr(left);
|
if (compl) {
|
||||||
|
tmp = NewPtr();
|
||||||
|
CodeDAddress(left, 1);
|
||||||
|
STL(tmp, pointer_size);
|
||||||
|
LOL(tmp, pointer_size);
|
||||||
|
C_loi(left->nd_type->tp_size);
|
||||||
|
}
|
||||||
|
else CodePExpr(left);
|
||||||
CodeCoercion(left->nd_type, tp);
|
CodeCoercion(left->nd_type, tp);
|
||||||
if (arg) {
|
if (arg) {
|
||||||
CodePExpr(arg->nd_LEFT);
|
CodePExpr(arg->nd_LEFT);
|
||||||
|
@ -570,7 +596,12 @@ CodeStd(nd)
|
||||||
RangeCheck(left->nd_type, tp->tp_fund == T_INTEGER ?
|
RangeCheck(left->nd_type, tp->tp_fund == T_INTEGER ?
|
||||||
int_type : card_type);
|
int_type : card_type);
|
||||||
}
|
}
|
||||||
CodeDStore(left);
|
if (compl) {
|
||||||
|
LOL(tmp, pointer_size);
|
||||||
|
C_sti(left->nd_type->tp_size);
|
||||||
|
FreePtr(tmp);
|
||||||
|
}
|
||||||
|
else CodeDStore(left);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,8 +610,18 @@ CodeStd(nd)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_INCL:
|
case S_INCL:
|
||||||
case S_EXCL:
|
case S_EXCL: {
|
||||||
CodePExpr(left);
|
int compl = complex_lhs(left);
|
||||||
|
arith tmp = 0;
|
||||||
|
|
||||||
|
if (compl) {
|
||||||
|
tmp = NewPtr();
|
||||||
|
CodeDAddress(left, 1);
|
||||||
|
STL(tmp, pointer_size);
|
||||||
|
LOL(tmp, pointer_size);
|
||||||
|
C_loi(left->nd_type->tp_size);
|
||||||
|
}
|
||||||
|
else CodePExpr(left);
|
||||||
CodePExpr(arg->nd_LEFT);
|
CodePExpr(arg->nd_LEFT);
|
||||||
C_loc(tp->set_low);
|
C_loc(tp->set_low);
|
||||||
C_sbi(word_size);
|
C_sbi(word_size);
|
||||||
|
@ -592,8 +633,14 @@ CodeStd(nd)
|
||||||
C_com(tp->tp_size);
|
C_com(tp->tp_size);
|
||||||
C_and(tp->tp_size);
|
C_and(tp->tp_size);
|
||||||
}
|
}
|
||||||
CodeDStore(left);
|
if (compl) {
|
||||||
|
LOL(tmp, pointer_size);
|
||||||
|
C_sti(left->nd_type->tp_size);
|
||||||
|
FreePtr(tmp);
|
||||||
|
}
|
||||||
|
else CodeDStore(left);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
crash("(CodeStd)");
|
crash("(CodeStd)");
|
||||||
|
|
Loading…
Reference in a new issue