Index: src/Parser/ParseNode.h
===================================================================
--- src/Parser/ParseNode.h	(revision fde0a583854b9d8d0c727dba8e9979347f11e82c)
+++ src/Parser/ParseNode.h	(revision 436bbe535206214ada05233b242baa9cb8b0bcad)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 13:28:16 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Feb  1 11:06:18 2022
-// Update Count     : 903
+// Last Modified On : Wed Feb  2 09:15:49 2022
+// Update Count     : 905
 //
 
@@ -410,11 +410,11 @@
 
 Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init );
-Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
+Statement * build_if( CondCtl * ctl, StatementNode * then, StatementNode * else_ );
 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
 Statement * build_case( ExpressionNode * ctl );
 Statement * build_default();
-Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * els = nullptr );
-Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * els = nullptr );
-Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * els = nullptr );
+Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
+Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
+Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ = nullptr );
 Statement * build_branch( BranchStmt::Type kind );
 Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
@@ -424,6 +424,6 @@
 Statement * build_resume( ExpressionNode * ctl );
 Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
-Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt );
-Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body );
+Statement * build_try( StatementNode * try_, StatementNode * catch_, StatementNode * finally_ );
+Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body );
 Statement * build_finally( StatementNode * stmt );
 Statement * build_compound( StatementNode * first );
Index: src/Parser/StatementNode.cc
===================================================================
--- src/Parser/StatementNode.cc	(revision fde0a583854b9d8d0c727dba8e9979347f11e82c)
+++ src/Parser/StatementNode.cc	(revision 436bbe535206214ada05233b242baa9cb8b0bcad)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 14:59:41 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Feb  1 18:39:00 2022
-// Update Count     : 395
+// Last Modified On : Wed Feb  2 09:45:28 2022
+// Update Count     : 415
 //
 
@@ -63,5 +63,5 @@
 	// convert from StatementNode list to Statement list
 	StatementNode * node = dynamic_cast< StatementNode * >(prev);
-	std::list< Statement * > stmts;
+	list< Statement * > stmts;
 	buildMoveList( stmt, stmts );
 	// splice any new Statements to end of current Statements
@@ -78,5 +78,5 @@
 } // build_expr
 
-Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init ) {
+Expression * build_if_control( CondCtl * ctl, list< Statement * > & init ) {
 	if ( ctl->init != 0 ) {
 		buildMoveList( ctl->init, init );
@@ -100,28 +100,29 @@
 } // build_if_control
 
-Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
-	Statement * thenb, * elseb = nullptr;
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( then_stmt, branches );
-	assert( branches.size() == 1 );
-	thenb = branches.front();
-
-	if ( else_stmt ) {
-		std::list< Statement * > branches;
-		buildMoveList< Statement, StatementNode >( else_stmt, branches );
-		assert( branches.size() == 1 );
-		elseb = branches.front();
-	} // if
-
-	std::list< Statement * > init;
-	Expression * cond = build_if_control( ctl, init );
-	return new IfStmt( cond, thenb, elseb, init );
+Statement * build_if( CondCtl * ctl, StatementNode * then, StatementNode * else_ ) {
+	list< Statement * > astinit;						// maybe empty
+	Expression * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
+
+	Statement * astthen, * astelse = nullptr;
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( then, aststmt );
+	assert( aststmt.size() == 1 );
+	astthen = aststmt.front();
+
+	if ( else_ ) {
+		list< Statement * > aststmt;
+		buildMoveList< Statement, StatementNode >( else_, aststmt );
+		assert( aststmt.size() == 1 );
+		astelse = aststmt.front();
+	} // if
+
+	return new IfStmt( astcond, astthen, astelse, astinit );
 } // build_if
 
 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	if ( ! isSwitch ) {										// choose statement
-		for ( Statement * stmt : branches ) {
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	if ( ! isSwitch ) {									// choose statement
+		for ( Statement * stmt : aststmt ) {
 			CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
 			if ( ! caseStmt->stmts.empty() ) {			// code after "case" => end of case list
@@ -131,67 +132,63 @@
 		} // for
 	} // if
-	// branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
-	return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
+	// aststmt.size() == 0 for switch (...) {}, i.e., no declaration or statements
+	return new SwitchStmt( maybeMoveBuild< Expression >(ctl), aststmt );
 } // build_switch
 
 Statement * build_case( ExpressionNode * ctl ) {
-	std::list< Statement * > branches;
-	return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );
+	return new CaseStmt( maybeMoveBuild< Expression >(ctl), list< Statement * >{} );
 } // build_case
 
 Statement * build_default() {
-	std::list< Statement * > branches;
-	return new CaseStmt( nullptr, branches, true );
+	return new CaseStmt( nullptr, list< Statement * >{}, true );
 } // build_default
 
 Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * else_ ) {
-	std::list< Statement * > init;
-	Expression * cond = build_if_control( ctl, init );
-
-	std::list< Statement * > aststmt;
-	buildMoveList< Statement, StatementNode >( stmt, aststmt );
-	assert( aststmt.size() == 1 );
-
-	std::list< Statement * > astelse;
+	list< Statement * > astinit;						// maybe empty
+	Expression * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
+
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+
+	list< Statement * > astelse;						// else clause, maybe empty
 	buildMoveList< Statement, StatementNode >( else_, astelse );
 
-	return new WhileDoStmt( cond, aststmt.front(), astelse.front(), init, false );
+	return new WhileDoStmt( astcond, aststmt.front(), astelse.front(), astinit, false );
 } // build_while
 
 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) {
-	std::list< Statement * > aststmt;
-	buildMoveList< Statement, StatementNode >( stmt, aststmt );
-	assert( aststmt.size() == 1 );
-
-	std::list< Statement * > astelse;
+	// do-while cannot have declarations in the contitional, so always empty
+	list< Statement * > astinit;
+
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );						// compound created if empty
+
+	list< Statement * > astelse;						// else clause, maybe empty
 	buildMoveList< Statement, StatementNode >( else_, astelse );
 
-	std::list< Statement * > init;
-	return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), init, true );
+	return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), astinit, true );
 } // build_do_while
 
 Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ ) {
-	std::list< Statement * > init;
-	if ( forctl->init != nullptr ) {
-		buildMoveList( forctl->init, init );
-	} // if
-
-	Expression * cond = nullptr;
-	if ( forctl->condition != nullptr )
-		cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
-
-	Expression * incr = nullptr;
-	if ( forctl->change != nullptr )
-		incr = maybeMoveBuild< Expression >(forctl->change);
-
-	std::list< Statement * > aststmt;
-	buildMoveList< Statement, StatementNode >( stmt, aststmt );
-	assert( aststmt.size() == 1 );
-
-	std::list< Statement * > astelse;
+	list< Statement * > astinit;						// maybe empty
+	buildMoveList( forctl->init, astinit );
+
+	Expression * astcond = nullptr;						// maybe empty
+	astcond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
+
+	Expression * astincr = nullptr;						// maybe empty
+	astincr = maybeMoveBuild< Expression >(forctl->change);
+	delete forctl;
+
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+
+	list< Statement * > astelse;						// else clause, maybe empty
 	buildMoveList< Statement, StatementNode >( else_, astelse );
 
-	delete forctl;
-	return new ForStmt( init, cond, incr, aststmt.front(), astelse.front() );
+	return new ForStmt( astinit, astcond, astincr, aststmt.front(), astelse.front() );
 } // build_for
 
@@ -201,5 +198,5 @@
 } // build_branch
 
-Statement * build_branch( std::string * identifier, BranchStmt::Type kind ) {
+Statement * build_branch( string * identifier, BranchStmt::Type kind ) {
 	Statement * ret = new BranchStmt( * identifier, kind );
 	delete identifier; 									// allocated by lexer
@@ -212,5 +209,5 @@
 
 Statement * build_return( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
 	return new ReturnStmt( exps.size() > 0 ? exps.back() : nullptr );
@@ -218,14 +215,14 @@
 
 Statement * build_throw( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
-	assertf( exps.size() < 2, "This means we are leaking memory");
+	assertf( exps.size() < 2, "CFA internal error: leaking memory" );
 	return new ThrowStmt( ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr );
 } // build_throw
 
 Statement * build_resume( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
-	assertf( exps.size() < 2, "This means we are leaking memory");
+	assertf( exps.size() < 2, "CFA internal error: leaking memory" );
 	return new ThrowStmt( ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );
 } // build_resume
@@ -237,24 +234,24 @@
 } // build_resume_at
 
-Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ) {
-	std::list< CatchStmt * > branches;
-	buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
-	CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
-	FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
-	return new TryStmt( tryBlock, branches, finallyBlock );
+Statement * build_try( StatementNode * try_, StatementNode * catch_, StatementNode * finally_ ) {
+	list< CatchStmt * > aststmt;
+	buildMoveList< CatchStmt, StatementNode >( catch_, aststmt );
+	CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_));
+	FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_) );
+	return new TryStmt( tryBlock, aststmt, finallyBlock );
 } // build_try
 
 Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( body, branches );
-	assert( branches.size() == 1 );
-	return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( body, aststmt );
+	assert( aststmt.size() == 1 );
+	return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), aststmt.front() );
 } // build_catch
 
 Statement * build_finally( StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() == 1 );
-	return new FinallyStmt( dynamic_cast< CompoundStmt * >( branches.front() ) );
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+	return new FinallyStmt( dynamic_cast< CompoundStmt * >( aststmt.front() ) );
 } // build_finally
 
@@ -264,5 +261,5 @@
 	node->type = type;
 
-	std::list< Statement * > stmts;
+	list< Statement * > stmts;
 	buildMoveList< Statement, StatementNode >( then, stmts );
 	if(!stmts.empty()) {
@@ -329,5 +326,5 @@
 } // build_waitfor_timeout
 
-WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_stmt, ExpressionNode * else_when ) {
+WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_, ExpressionNode * else_when ) {
 	auto node = new WaitForStmt();
 
@@ -336,5 +333,5 @@
 	node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
 
-	node->orelse.statement  = maybeMoveBuild<Statement >( else_stmt );
+	node->orelse.statement  = maybeMoveBuild<Statement >( else_ );
 	node->orelse.condition  = notZeroExpr( maybeMoveBuild<Expression>( else_when ) );
 
@@ -343,5 +340,5 @@
 
 Statement * build_with( ExpressionNode * exprs, StatementNode * stmt ) {
-	std::list< Expression * > e;
+	list< Expression * > e;
 	buildMoveList( exprs, e );
 	Statement * s = maybeMoveBuild<Statement>( stmt );
@@ -371,6 +368,6 @@
 
 Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {
-	std::list< Expression * > out, in;
-	std::list< ConstantExpr * > clob;
+	list< Expression * > out, in;
+	list< ConstantExpr * > clob;
 
 	buildMoveList( output, out );
@@ -385,5 +382,5 @@
 
 Statement * build_mutex( ExpressionNode * exprs, StatementNode * stmt ) {
-	std::list< Expression * > expList;
+	list< Expression * > expList;
 	buildMoveList( exprs, expList );
 	Statement * body = maybeMoveBuild<Statement>( stmt );
