Fix inc/dec operators not returning an iEXPRESSION (#429)

* Fix inc/dec operators not returning an iEXPRESSION

* Fix inc/dec operators in return statement
This commit is contained in:
Vincent Herbet 2017-04-29 23:33:09 +02:00 committed by GitHub
parent be3ae83c44
commit 1a56577f7a
2 changed files with 7 additions and 3 deletions

View File

@ -5334,7 +5334,7 @@ static void doreturn(void)
/* "return <value>" */ /* "return <value>" */
if ((rettype & uRETNONE)!=0) if ((rettype & uRETNONE)!=0)
error(78); /* mix "return;" and "return value;" */ error(78); /* mix "return;" and "return value;" */
ident=doexpr(TRUE,FALSE,TRUE,TRUE,&tag,&sym,TRUE); ident=doexpr(TRUE,FALSE,TRUE,FALSE,&tag,&sym,TRUE);
needtoken(tTERM); needtoken(tTERM);
if (ident == iARRAY && sym == NULL) { if (ident == iARRAY && sym == NULL) {
/* returning a literal string is not supported (it must be a variable) */ /* returning a literal string is not supported (it must be a variable) */
@ -5495,7 +5495,7 @@ static void doexit(void)
int tag=0; int tag=0;
if (matchtoken(tTERM)==0){ if (matchtoken(tTERM)==0){
doexpr(TRUE,FALSE,FALSE,TRUE,&tag,NULL,TRUE); doexpr(TRUE,FALSE,FALSE,FALSE,&tag,NULL,TRUE);
needtoken(tTERM); needtoken(tTERM);
} else { } else {
ldconst(0,sPRI); ldconst(0,sPRI);
@ -5511,7 +5511,7 @@ static void dosleep(void)
int tag=0; int tag=0;
if (matchtoken(tTERM)==0){ if (matchtoken(tTERM)==0){
doexpr(TRUE,FALSE,FALSE,TRUE,&tag,NULL,TRUE); doexpr(TRUE,FALSE,FALSE, FALSE,&tag,NULL,TRUE);
needtoken(tTERM); needtoken(tTERM);
} else { } else {
ldconst(0,sPRI); ldconst(0,sPRI);

View File

@ -1160,6 +1160,7 @@ static int hier2(value *lval)
if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag))
inc(lval); /* increase variable first */ inc(lval); /* increase variable first */
rvalue(lval); /* and read the result into PRI */ rvalue(lval); /* and read the result into PRI */
lval->ident = iEXPRESSION;
sideeffect=TRUE; sideeffect=TRUE;
return FALSE; /* result is no longer lvalue */ return FALSE; /* result is no longer lvalue */
case tDEC: /* --lval */ case tDEC: /* --lval */
@ -1171,6 +1172,7 @@ static int hier2(value *lval)
if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag))
dec(lval); /* decrease variable first */ dec(lval); /* decrease variable first */
rvalue(lval); /* and read the result into PRI */ rvalue(lval); /* and read the result into PRI */
lval->ident = iEXPRESSION;
sideeffect=TRUE; sideeffect=TRUE;
return FALSE; /* result is no longer lvalue */ return FALSE; /* result is no longer lvalue */
case '~': /* ~ (one's complement) */ case '~': /* ~ (one's complement) */
@ -1379,6 +1381,7 @@ static int hier2(value *lval)
inc(lval); /* increase variable afterwards */ inc(lval); /* increase variable afterwards */
if (saveresult) if (saveresult)
popreg(sPRI); /* restore PRI (result of rvalue()) */ popreg(sPRI); /* restore PRI (result of rvalue()) */
lval->ident = iEXPRESSION;
sideeffect=TRUE; sideeffect=TRUE;
return FALSE; /* result is no longer lvalue */ return FALSE; /* result is no longer lvalue */
case tDEC: /* lval-- */ case tDEC: /* lval-- */
@ -1397,6 +1400,7 @@ static int hier2(value *lval)
dec(lval); /* decrease variable afterwards */ dec(lval); /* decrease variable afterwards */
if (saveresult) if (saveresult)
popreg(sPRI); /* restore PRI (result of rvalue()) */ popreg(sPRI); /* restore PRI (result of rvalue()) */
lval->ident = iEXPRESSION;
sideeffect=TRUE; sideeffect=TRUE;
return FALSE; return FALSE;
case tCHAR: /* char (compute required # of cells */ case tCHAR: /* char (compute required # of cells */