Skip to content

Commit ffb161a

Browse files
committed
check array depends for modifications for W214
1 parent 116ec5f commit ffb161a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

source/compiler/sc1.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,9 +4907,20 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
49074907
error(204,sym->name); /* value assigned to symbol is never used */
49084908
errorset(sSETPOS,-1);
49094909
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
4910-
errorset(sSETPOS,sym->lnumber);
4911-
error(214,sym->name); /* make array argument "const" */
4912-
errorset(sSETPOS,-1);
4910+
int warn = 1;
4911+
symbol* depend = finddepend(sym);
4912+
while (depend != NULL) {
4913+
if ((depend->usage & (uWRITTEN | uPUBLIC | uCONST)) != 0) {
4914+
warn = 0;
4915+
break;
4916+
}
4917+
depend = finddepend(depend);
4918+
} /* while */
4919+
if (warn) {
4920+
errorset(sSETPOS, sym->lnumber);
4921+
error(214, sym->name); /* make array argument "const" */
4922+
errorset(sSETPOS, -1);
4923+
} /* if */
49134924
} /* if */
49144925
/* also mark the variable (local or global) to the debug information */
49154926
if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0)

0 commit comments

Comments
 (0)