Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv14900/F:/nice/src/bossa/syntax
Modified Files:
analyse.nice
Log Message:
Fix checking of assignments to uninitialized local constants inside loops.
Index: analyse.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** analyse.nice 9 May 2003 13:17:03 -0000 1.67
--- analyse.nice 21 May 2003 14:21:00 -0000 1.68
***************
*** 70,73 ****
--- 70,75 ----
?LoopStmt currentLoop = null;
+ ?Set<VarSymbol> currentLoopVars = null;
+
Stack<LabeledStmt> labels = new Stack();
***************
*** 217,223 ****
if (v.index != -1)
{
! if (v.constant && info.flags[v.index])
bossa.util.User.error(loc,
! "" + v + " cannot be assigned a value twice");
info.flags |= 1 << v.index;
--- 219,227 ----
if (v.index != -1)
{
! if (v.constant && (info.flags[v.index] ||
! info.currentLoopVars != null &&
! !notNull(info.currentLoopVars).contains(v)))
bossa.util.User.error(loc,
! "" + v + " cannot be assigned a value multiple times");
info.flags |= 1 << v.index;
***************
*** 551,554 ****
--- 555,561 ----
decl.setIndex(++info.varIndex);
info.addVar(notNull(decl.left));
+
+ if (info.currentLoopVars != null && notNull(decl.left).constant)
+ notNull(info.currentLoopVars).add(notNull(decl.left));
}
***************
*** 607,615 ****
--- 614,626 ----
?LoopStmt save = info.currentLoop;
+ ?Set<VarSymbol> loopVarSave = info.currentLoopVars;
+
info.currentLoop = l;
+ info.currentLoopVars = new HashSet();
analyse(l.loopBody, info);
info.currentLoop = save;
+ info.currentLoopVars = loopVarSave;
/* The update code is considered reachable even if the loop cannot terminate
|