Index: src/ControlStruct/MLEMutator.cc
===================================================================
--- src/ControlStruct/MLEMutator.cc	(revision 888cbe433d3c2fa38fa20f2b18976e3d44b8a51f)
+++ src/ControlStruct/MLEMutator.cc	(revision 4dcea3fb46591eadeb03906f898a98a598996702)
@@ -27,4 +27,5 @@
 #include "SynTree/Statement.h"
 #include "SynTree/Expression.h"
+#include "SynTree/Attribute.h"
 
 namespace ControlStruct {
@@ -32,4 +33,7 @@
 		delete targetTable;
 		targetTable = 0;
+	}
+	namespace {
+		Statement * isLoop( Statement * stmt ) { return dynamic_cast< WhileStmt * >( stmt ) ? stmt : dynamic_cast< ForStmt * >( stmt ) ? stmt : 0; }
 	}
 
@@ -44,13 +48,6 @@
 			if ( ! get_breakLabel().empty() ) {
 				std::list< Statement * >::iterator next = k+1;
-				Statement * stmt = 0;
-				if ( next == kids.end() ) {
-					std::list<Label> ls; ls.push_back( get_breakLabel() );
-					kids.push_back( stmt = new NullStmt( ls ) );
-				} else {
-					(stmt = *next)->get_labels().push_back( get_breakLabel() );
-				}
-				stmt->get_labels().front().set_statement( stmt );
-
+				std::list<Label> ls; ls.push_back( get_breakLabel() );
+				kids.insert( next, new NullStmt( ls ) );
 				set_breakLabel("");
 			} // if
@@ -62,5 +59,5 @@
 		if ( labeledBlock ) {
 			Label brkLabel = generator->newLabel("blockBreak");
-			enclosingBlocks.push_back( Entry( cmpndStmt, brkLabel ) );
+			enclosingControlStructures.push_back( Entry( cmpndStmt, brkLabel ) );
 		} // if
 
@@ -71,9 +68,9 @@
 
 		if ( labeledBlock ) {
-			assert( ! enclosingBlocks.empty() );
-			if ( ! enclosingBlocks.back().useBreakExit().empty() ) {
-				set_breakLabel( enclosingBlocks.back().useBreakExit() );
-			}
-			enclosingBlocks.pop_back();
+			assert( ! enclosingControlStructures.empty() );
+			if ( ! enclosingControlStructures.back().useBreakExit().empty() ) {
+				set_breakLabel( enclosingControlStructures.back().useBreakExit() );
+			}
+			enclosingControlStructures.pop_back();
 		} // if
 
@@ -89,9 +86,9 @@
 		Label brkLabel = generator->newLabel("loopBreak");
 		Label contLabel = generator->newLabel("loopContinue");
-		enclosingLoops.push_back( Entry( loopStmt, brkLabel, contLabel ) );
+		enclosingControlStructures.push_back( Entry( loopStmt, brkLabel, contLabel ) );
 		loopStmt->set_body ( loopStmt->get_body()->acceptMutator( *this ) );
 
 		// sanity check that the enclosing loops have been popped correctly
-		Entry &e = enclosingLoops.back();
+		Entry &e = enclosingControlStructures.back();
 		assert ( e == loopStmt );
 
@@ -99,5 +96,5 @@
 		// two labels, if they are used.
 		loopStmt->set_body( mutateLoop( loopStmt->get_body(), e ) );
-		enclosingLoops.pop_back();
+		enclosingControlStructures.pop_back();
 
 		return loopStmt;
@@ -115,8 +112,8 @@
 		// generate a label for breaking out of a labeled switch
 		Label brkLabel = generator->newLabel("switchBreak");
-		enclosingSwitches.push_back( Entry(switchStmt, brkLabel) );
+		enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) );
 		mutateAll( switchStmt->get_branches(), *this );
 
-		Entry &e = enclosingSwitches.back();
+		Entry &e = enclosingControlStructures.back();
 		assert ( e == switchStmt );
 
@@ -133,12 +130,10 @@
 			if ( CaseStmt * c = dynamic_cast< CaseStmt * >( branches.back() ) ) {
 				std::list<Label> temp; temp.push_back( brkLabel );
-				Statement * stmt = new BranchStmt( temp, Label(""), BranchStmt::Break );
-				stmt->get_labels().front().set_statement( stmt );
-				c->get_statements().push_back( stmt );
+				c->get_statements().push_back( new BranchStmt( temp, Label("brkLabel"), BranchStmt::Break ) );
 			} else assert(0); // as of this point, all branches of a switch are still CaseStmts
 		}
 
-		assert ( enclosingSwitches.back() == switchStmt );
-		enclosingSwitches.pop_back();
+		assert ( enclosingControlStructures.back() == switchStmt );
+		enclosingControlStructures.pop_back();
 		return switchStmt;
 	}
@@ -147,35 +142,33 @@
 		std::string originalTarget = branchStmt->get_originalTarget();
 
-		if ( branchStmt->get_type() == BranchStmt::Goto )
+		std::list< Entry >::reverse_iterator targetEntry;
+		if ( branchStmt->get_type() == BranchStmt::Goto ) {
 			return branchStmt;
-
-		// test if continue target is a loop
-		if ( branchStmt->get_type() == BranchStmt::Continue) {
-			if ( enclosingLoops.empty() ) {
-				throw SemanticError( "'continue' outside a loop" );
-			} else if ( branchStmt->get_target() != "" && std::find( enclosingLoops.begin(), enclosingLoops.end(), (*targetTable)[branchStmt->get_target()] ) == enclosingLoops.end() ) {
-				throw SemanticError( "'continue' target label must be an enclosing loop: " + originalTarget );
-			}
-		}
-
-		if ( branchStmt->get_type() == BranchStmt::Break && (enclosingLoops.empty() && enclosingSwitches.empty() && enclosingBlocks.empty() ) )
-			throw SemanticError( "'break' outside a loop or switch" );
-
-		if ( branchStmt->get_target() == "" ) return branchStmt;
-
-		if ( targetTable->find( branchStmt->get_target() ) == targetTable->end() )
+		} else if ( branchStmt->get_type() == BranchStmt::Continue) {
+			// continue target must be a loop
+			if ( branchStmt->get_target() == "" ) {
+				targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), [](Entry &e) { return isLoop( e.get_controlStructure() ); } );
+			} else {
+				// labelled continue - lookup label in table ot find attached control structure
+				targetEntry = std::find( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), (*targetTable)[branchStmt->get_target()] );
+			}
+			if ( targetEntry == enclosingControlStructures.rend() || ! isLoop( targetEntry->get_controlStructure() ) ) {
+				throw SemanticError( "'continue' target must be an enclosing loop: " + originalTarget );
+			}
+		} else if ( branchStmt->get_type() == BranchStmt::Break ) {
+			if ( enclosingControlStructures.empty() ) throw SemanticError( "'break' outside a loop, switch, or labelled block" );
+			targetEntry = enclosingControlStructures.rbegin();
+		} else {
+			assert( false );
+		}
+
+		if ( branchStmt->get_target() != "" && targetTable->find( branchStmt->get_target() ) == targetTable->end() ) {
 			throw SemanticError("The label defined in the exit loop statement does not exist: " + originalTarget );  // shouldn't happen (since that's already checked)
-
-		std::list< Entry >::iterator check;
-		if ( ( check = std::find( enclosingLoops.begin(), enclosingLoops.end(), (*targetTable)[branchStmt->get_target()] ) ) == enclosingLoops.end() )
-			// not in loop, checking if in block
-			if ( (check = std::find( enclosingBlocks.begin(), enclosingBlocks.end(), (*targetTable)[branchStmt->get_target()] )) == enclosingBlocks.end() )
-				// neither in loop nor in block, checking if in switch/choose
-				if ( (check = std::find( enclosingSwitches.begin(), enclosingSwitches.end(), (*targetTable)[branchStmt->get_target()] )) == enclosingSwitches.end() )
-					throw SemanticError("The target specified in the exit loop statement does not correspond to an enclosing control structure: " + originalTarget );
-
+		}
+
+		// xxx - possibly remove this
 		// what about exiting innermost block or switch???
-		if ( enclosingLoops.back() == (*check) )
-			return branchStmt;				// exit the innermost loop (labels unnecessary)
+		// if ( enclosingControlStructures.back() == (*targetEntry) )
+		// 	return branchStmt;				// exit the innermost loop (labels unnecessary)
 
 		// branch error checks, get the appropriate label name and create a goto
@@ -183,10 +176,10 @@
 		switch ( branchStmt->get_type() ) {
 		  case BranchStmt::Break:
-				assert( check->useBreakExit() != "");
-				exitLabel = check->useBreakExit();
+				assert( targetEntry->useBreakExit() != "");
+				exitLabel = targetEntry->useBreakExit();
 				break;
 		  case BranchStmt::Continue:
-				assert( check->useContExit() != "");
-				exitLabel = check->useContExit();
+				assert( targetEntry->useContExit() != "");
+				exitLabel = targetEntry->useContExit();
 				break;
 		  default:
@@ -194,5 +187,14 @@
 		} // switch
 
-		return new BranchStmt( std::list<Label>(), exitLabel, BranchStmt::Goto );
+		if ( branchStmt->get_target() == "" && branchStmt->get_type() != BranchStmt::Continue ) {
+			// unlabelled break/continue - can keep branch as break/continue for extra semantic information, but add
+			// exitLabel as its destination so that label passes can easily determine where the break/continue goes to
+			branchStmt->set_target( exitLabel );
+			return branchStmt;
+		} else {
+			// labelled break/continue - can't easily emulate this with break and continue, so transform into a goto
+			delete branchStmt;
+			return new BranchStmt( std::list<Label>(), exitLabel, BranchStmt::Goto );
+		}
 	}
 
@@ -210,7 +212,5 @@
 			// continue label goes in the body as the last statement
 			std::list< Label > labels; labels.push_back( e.useContExit() );
-			Statement * stmt = new NullStmt( labels );
-			stmt->get_labels().front().set_statement( stmt );
-			newBody->get_kids().push_back( stmt );
+			newBody->get_kids().push_back( new NullStmt( labels ) );
 		}
 
Index: src/ControlStruct/MLEMutator.h
===================================================================
--- src/ControlStruct/MLEMutator.h	(revision 888cbe433d3c2fa38fa20f2b18976e3d44b8a51f)
+++ src/ControlStruct/MLEMutator.h	(revision 4dcea3fb46591eadeb03906f898a98a598996702)
@@ -56,7 +56,7 @@
 			bool operator!=( const Statement *stmt ) { return ( loop != stmt ); }
 
-			bool operator==( const Entry &other ) { return ( loop == other.get_loop() ); }
+			bool operator==( const Entry &other ) { return ( loop == other.get_controlStructure() ); }
 
-			Statement *get_loop() const { return loop; }
+			Statement *get_controlStructure() const { return loop; }
 
 			Label useContExit() { contUsed = true; return contExit; }
@@ -73,5 +73,5 @@
 
 		std::map< Label, Statement * > *targetTable;
-		std::list< Entry > enclosingBlocks, enclosingLoops, enclosingSwitches;
+		std::list< Entry > enclosingControlStructures;
 		Label breakLabel;
 		LabelGenerator *generator;
