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,8 +921,9 @@ static int hier14(value *lval1)
|
||||
{
|
||||
int same=TRUE;
|
||||
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]);
|
||||
} /* for */
|
||||
if (same)
|
||||
error(226,lval3.sym->name); /* self-assignment */
|
||||
} /* if */
|
||||
@ -1250,6 +1251,8 @@ static int hier2(value *lval)
|
||||
rvalue(lval);
|
||||
invert(); /* bitwise NOT */
|
||||
lval->constval=~lval->constval;
|
||||
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||
lval->ident=iEXPRESSION;
|
||||
return FALSE;
|
||||
case '!': /* ! (logical negate) */
|
||||
if (hier2(lval))
|
||||
@ -1261,6 +1264,8 @@ static int hier2(value *lval)
|
||||
lneg(); /* 0 -> 1, !0 -> 0 */
|
||||
lval->constval=!lval->constval;
|
||||
lval->tag=pc_addtag("bool");
|
||||
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||
lval->ident=iEXPRESSION;
|
||||
} /* if */
|
||||
return FALSE;
|
||||
case '-': /* unary - (two's complement) */
|
||||
@ -1289,6 +1294,8 @@ static int hier2(value *lval)
|
||||
} else {
|
||||
neg(); /* arithmic negation */
|
||||
lval->constval=-lval->constval;
|
||||
if (lval->ident==iVARIABLE || lval->ident==iARRAYCELL)
|
||||
lval->ident=iEXPRESSION;
|
||||
} /* if */
|
||||
return FALSE;
|
||||
case tLABEL: /* tagname override */
|
||||
|
Loading…
x
Reference in New Issue
Block a user