Skip to content

Commit 5022aea

Browse files
committed
Don't issue warning 210 if a variable is defined inside a 'for' loop or if its value is incremented/decremented with operator '++'/'--'
1 parent 22ce305 commit 5022aea

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

source/compiler/sc1.c

+5
Original file line numberDiff line numberDiff line change
@@ -5740,8 +5740,13 @@ static int dofor(void)
57405740
/* The variable in expr1 of the for loop is at a
57415741
* 'compound statement' level of it own.
57425742
*/
5743+
symbol *sym;
57435744
nestlevel++;
57445745
declloc(FALSE); /* declare local variable */
5746+
for (sym=loctab.next; sym!=NULL; sym=sym->next) {
5747+
if (sym->compound==nestlevel)
5748+
sym->usage |= uEXPLINIT;
5749+
} /* for */
57455750
} else {
57465751
doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 1 */
57475752
needtoken(';');

source/compiler/sc3.c

+2
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,7 @@ static int hier2(value *lval)
15021502
assert(lval->sym!=NULL);
15031503
if ((lval->sym->usage & uCONST)!=0)
15041504
return error(22); /* assignment to const argument */
1505+
lval->sym->usage |= uEXPLINIT;
15051506
/* on incrementing array cells, the address in PRI must be saved for
15061507
* incremening the value, whereas the current value must be in PRI
15071508
* on exit.
@@ -1524,6 +1525,7 @@ static int hier2(value *lval)
15241525
assert(lval->sym!=NULL);
15251526
if ((lval->sym->usage & uCONST)!=0)
15261527
return error(22); /* assignment to const argument */
1528+
lval->sym->usage |= uEXPLINIT;
15271529
saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR);
15281530
if (saveresult)
15291531
pushreg(sPRI); /* save address in PRI */

0 commit comments

Comments
 (0)