changeset 1158:08c1c3bfea5a

Fix goto inside synchronized functions.
author Christian Kamm <kamm incasoftware de>
date Sat, 28 Mar 2009 14:26:23 +0100
parents ee8db0b7bb62
children c6d6a68bb5db
files dmd/func.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/func.c	Sat Mar 28 10:50:44 2009 +0100
+++ b/dmd/func.c	Sat Mar 28 14:26:23 2009 +0100
@@ -1267,13 +1267,19 @@
 		    sync = new VarExp(loc, vthis);
 		}
                 
-		// is is ok to not rerun semantic on the whole fbody here; only the enclosingScopeExit
-		// value will differ and as it is impossible to goto out of this synchronized statement,
-		// that should not lead to errors
+		// we do not want to rerun semantics on the whole function, so we
+		// manually adjust all labels in the function that currently don't
+		// have an enclosingScopeExit to use the new SynchronizedStatement
 		SynchronizedStatement* s = new SynchronizedStatement(loc, sync, NULL);
 		s->semantic(sc2);
 		s->body = fbody;
 		
+		// LDC
+		LabelMap::iterator it, end = labmap.end();
+		for (it = labmap.begin(); it != end; ++it)
+		    if (it->second->enclosingScopeExit == NULL)
+			it->second->enclosingScopeExit = s;
+		
 		a = new Statements;
 		a->push(s);
 		fbody = new CompoundStatement(0, a);