Fix false 'assignment to itself' warning
Change lvalue type (ident) to iEXPRESSION if a unary operator is applied to it ('!', '~', '-'). This allows the self-assignment check to pass. Fixes #78.
This commit is contained in:
parent
9109958fd1
commit
43cd36b891
@ -921,13 +921,14 @@ static int hier14(value *lval1)
|
|||||||
{
|
{
|
||||||
int same=TRUE;
|
int same=TRUE;
|
||||||
assert(lval2.arrayidx==arrayidx2);
|
assert(lval2.arrayidx==arrayidx2);
|
||||||
for (i=0; i<sDIMEN_MAX; i++)
|
for (i=0; i<sDIMEN_MAX; i++) {
|
||||||
same=same && (lval3.arrayidx[i]==lval2.arrayidx[i]);
|
same=same && (lval3.arrayidx[i]==lval2.arrayidx[i]);
|
||||||
|
} /* for */
|
||||||
if (same)
|
if (same)
|
||||||
error(226,lval3.sym->name); /* self-assignment */
|
error(226,lval3.sym->name); /* self-assignment */
|
||||||
} /* if */
|
} /* if */
|
||||||
} else {
|
} else {
|
||||||
if (oper){
|
if (oper) {
|
||||||
rvalue(lval1);
|
rvalue(lval1);
|
||||||
plnge2(oper,hier14,lval1,&lval2);
|
plnge2(oper,hier14,lval1,&lval2);
|
||||||
} else {
|
} else {
|
||||||
@ -936,7 +937,7 @@ static int hier14(value *lval1)
|
|||||||
if (hier14(&lval2))
|
if (hier14(&lval2))
|
||||||
rvalue(&lval2); /* instead of plnge2(). */
|
rvalue(&lval2); /* instead of plnge2(). */
|
||||||
else if (lval2.ident==iVARIABLE)
|
else if (lval2.ident==iVARIABLE)
|
||||||
lval2.ident=iEXPRESSION;/* mark as "rvalue" if it is not an "lvalue" */
|
lval2.ident=iEXPRESSION; /* mark as "rvalue" if it is not an "lvalue" */
|
||||||
checkfunction(&lval2);
|
checkfunction(&lval2);
|
||||||
/* check whether lval2 and lval3 (old lval1) refer to the same variable */
|
/* check whether lval2 and lval3 (old lval1) refer to the same variable */
|
||||||
if (lval2.ident==iVARIABLE && lval3.ident==lval2.ident && lval3.sym==lval2.sym) {
|
if (lval2.ident==iVARIABLE && lval3.ident==lval2.ident && lval3.sym==lval2.sym) {
|
||||||
@ -1250,6 +1251,8 @@ static int hier2(value *lval)
|
|||||||
rvalue(lval);
|
rvalue(lval);
|
||||||
invert(); /* bitwise NOT */
|
invert(); /* bitwise NOT */
|
||||||
lval->constval=~lval->constval;
|
lval->constval=~lval->constval;
|
||||||
|
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||||
|
lval->ident=iEXPRESSION;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case '!': /* ! (logical negate) */
|
case '!': /* ! (logical negate) */
|
||||||
if (hier2(lval))
|
if (hier2(lval))
|
||||||
@ -1261,6 +1264,8 @@ static int hier2(value *lval)
|
|||||||
lneg(); /* 0 -> 1, !0 -> 0 */
|
lneg(); /* 0 -> 1, !0 -> 0 */
|
||||||
lval->constval=!lval->constval;
|
lval->constval=!lval->constval;
|
||||||
lval->tag=pc_addtag("bool");
|
lval->tag=pc_addtag("bool");
|
||||||
|
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||||
|
lval->ident=iEXPRESSION;
|
||||||
} /* if */
|
} /* if */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case '-': /* unary - (two's complement) */
|
case '-': /* unary - (two's complement) */
|
||||||
@ -1289,6 +1294,8 @@ static int hier2(value *lval)
|
|||||||
} else {
|
} else {
|
||||||
neg(); /* arithmic negation */
|
neg(); /* arithmic negation */
|
||||||
lval->constval=-lval->constval;
|
lval->constval=-lval->constval;
|
||||||
|
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||||
|
lval->ident=iEXPRESSION;
|
||||||
} /* if */
|
} /* if */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case tLABEL: /* tagname override */
|
case tLABEL: /* tagname override */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user