comparison dmd/func.c @ 1158:08c1c3bfea5a

Fix goto inside synchronized functions.
author Christian Kamm <kamm incasoftware de>
date Sat, 28 Mar 2009 14:26:23 +0100
parents 1860414bf3b7
children a8b9fc41c34b
comparison
equal deleted inserted replaced
1157:ee8db0b7bb62 1158:08c1c3bfea5a
1265 { 1265 {
1266 // non-static member functions synchronize on this 1266 // non-static member functions synchronize on this
1267 sync = new VarExp(loc, vthis); 1267 sync = new VarExp(loc, vthis);
1268 } 1268 }
1269 1269
1270 // is is ok to not rerun semantic on the whole fbody here; only the enclosingScopeExit 1270 // we do not want to rerun semantics on the whole function, so we
1271 // value will differ and as it is impossible to goto out of this synchronized statement, 1271 // manually adjust all labels in the function that currently don't
1272 // that should not lead to errors 1272 // have an enclosingScopeExit to use the new SynchronizedStatement
1273 SynchronizedStatement* s = new SynchronizedStatement(loc, sync, NULL); 1273 SynchronizedStatement* s = new SynchronizedStatement(loc, sync, NULL);
1274 s->semantic(sc2); 1274 s->semantic(sc2);
1275 s->body = fbody; 1275 s->body = fbody;
1276
1277 // LDC
1278 LabelMap::iterator it, end = labmap.end();
1279 for (it = labmap.begin(); it != end; ++it)
1280 if (it->second->enclosingScopeExit == NULL)
1281 it->second->enclosingScopeExit = s;
1276 1282
1277 a = new Statements; 1283 a = new Statements;
1278 a->push(s); 1284 a->push(s);
1279 fbody = new CompoundStatement(0, a); 1285 fbody = new CompoundStatement(0, a);
1280 } 1286 }