Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/CodeGen/CodeGenerator.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -288,17 +288,17 @@
 	}
 
-	void CodeGenerator::printDesignators( std::list< Expression * > & designators ) {
-		typedef std::list< Expression * > DesignatorList;
+	void CodeGenerator::visit( Designation * designation ) {
+		std::list< Expression * > designators = designation->get_designators();
 		if ( designators.size() == 0 ) return;
-		for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) {
-			if ( dynamic_cast< NameExpr * >( *iter ) ) {
-				// if expression is a name, then initializing aggregate member
+		for ( Expression * des : designators ) {
+			if ( dynamic_cast< ConstantExpr * >( des ) ) {
+				// if expression is a ConstantExpr, then initializing array element
+				output << "[";
+				des->accept( *this );
+				output << "]";
+			} else {
+				// if not a ConstantExpr, it has to be a NameExpr or VariableExpr, initializing aggregate member
 				output << ".";
-				(*iter)->accept( *this );
-			} else {
-				// if not a simple name, it has to be a constant expression, i.e. an array designator
-				output << "[";
-				(*iter)->accept( *this );
-				output << "]";
+				des->accept( *this );
 			} // if
 		} // for
@@ -307,13 +307,24 @@
 
 	void CodeGenerator::visit( SingleInit * init ) {
-		printDesignators( init->get_designators() );
 		init->get_value()->accept( *this );
 	}
 
 	void CodeGenerator::visit( ListInit * init ) {
-		printDesignators( init->get_designators() );
+		auto initBegin = init->begin();
+		auto initEnd = init->end();
+		auto desigBegin = init->get_designations().begin();
+		auto desigEnd = init->get_designations().end();
+
 		output << "{ ";
-		genCommaList( init->begin(), init->end() );
+		for ( ; initBegin != initEnd && desigBegin != desigEnd; ) {
+			(*desigBegin)->accept( *this );
+			(*initBegin)->accept( *this );
+			++initBegin, ++desigBegin;
+			if ( initBegin != initEnd ) {
+				output << ", ";
+			}
+		}
 		output << " }";
+		assertf( initBegin == initEnd && desigBegin == desigEnd, "Initializers and designators not the same length. %s", toString( init ).c_str() );
 	}
 
@@ -716,6 +727,9 @@
 
 	void CodeGenerator::visit( TypeExpr * typeExpr ) {
-		assertf( ! genC, "TypeExpr should not reach code generation." );
-		output<< genType( typeExpr->get_type(), "", pretty, genC );
+		// if ( genC ) std::cerr << "typeexpr still exists: " << typeExpr << std::endl;
+		// assertf( ! genC, "TypeExpr should not reach code generation." );
+		if ( ! genC ) {
+			output<< genType( typeExpr->get_type(), "", pretty, genC );
+		}
 	}
 
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/CodeGen/CodeGenerator.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -47,4 +47,5 @@
 
 		//*** Initializer
+		virtual void visit( Designation * );
 		virtual void visit( SingleInit * );
 		virtual void visit( ListInit * );
@@ -137,5 +138,4 @@
 		bool lineMarks = false;
 
-		void printDesignators( std::list< Expression * > & );
 		void handleStorageClass( DeclarationWithType *decl );
 		void handleAggregate( AggregateDecl *aggDecl, const std::string & kind );
Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/Common/utility.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -305,5 +305,5 @@
 // for ( val : group_iterate( container1, container2, ... ) ) {}
 // syntax to have a for each that iterates multiple containers of the same length
-// TODO: update to use variadic arguments
+// TODO: update to use variadic arguments, perfect forwarding
 
 template< typename T1, typename T2 >
Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/InitTweak/FixInit.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -724,5 +724,5 @@
 						// static bool __objName_uninitialized = true
 						BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
-						SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ), noDesignators );
+						SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ) );
 						ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
 						isUninitializedVar->fixUniqueId();
Index: src/InitTweak/InitTweak.cc
===================================================================
--- src/InitTweak/InitTweak.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/InitTweak/InitTweak.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -14,11 +14,8 @@
 		public:
 			bool hasDesignations = false;
-			template<typename Init>
-			void handleInit( Init * init ) {
-				if ( ! init->get_designators().empty() ) hasDesignations = true;
-				else Visitor::visit( init );
-			}
-			virtual void visit( SingleInit * singleInit ) { handleInit( singleInit); }
-			virtual void visit( ListInit * listInit ) { handleInit( listInit); }
+			virtual void visit( Designation * des ) {
+				if ( ! des->get_designators().empty() ) hasDesignations = true;
+				else Visitor::visit( des );
+			}
 		};
 
Index: src/MakeLibCfa.cc
===================================================================
--- src/MakeLibCfa.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/MakeLibCfa.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -92,5 +92,5 @@
 		assert( ! objDecl->get_init() );
 		std::list< Expression* > noDesignators;
-		objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), noDesignators, false ) ); // cannot be constructed
+		objDecl->set_init( new SingleInit( new NameExpr( objDecl->get_name() ), false ) ); // cannot be constructed
 		newDecls.push_back( objDecl );
 	}
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/Makefile.in	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -161,4 +161,5 @@
 	ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT) \
 	ResolvExpr/driver_cfa_cpp-TypeEnvironment.$(OBJEXT) \
+	ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT) \
 	SymTab/driver_cfa_cpp-Indexer.$(OBJEXT) \
 	SymTab/driver_cfa_cpp-Mangler.$(OBJEXT) \
@@ -414,12 +415,12 @@
 	ResolvExpr/RenameVars.cc ResolvExpr/FindOpenVars.cc \
 	ResolvExpr/PolyCost.cc ResolvExpr/Occurs.cc \
-	ResolvExpr/TypeEnvironment.cc SymTab/Indexer.cc \
-	SymTab/Mangler.cc SymTab/Validate.cc SymTab/FixFunction.cc \
-	SymTab/ImplementationType.cc SymTab/TypeEquality.cc \
-	SymTab/Autogen.cc SynTree/Type.cc SynTree/VoidType.cc \
-	SynTree/BasicType.cc SynTree/PointerType.cc \
-	SynTree/ArrayType.cc SynTree/FunctionType.cc \
-	SynTree/ReferenceToType.cc SynTree/TupleType.cc \
-	SynTree/TypeofType.cc SynTree/AttrType.cc \
+	ResolvExpr/TypeEnvironment.cc ResolvExpr/CurrentObject.cc \
+	SymTab/Indexer.cc SymTab/Mangler.cc SymTab/Validate.cc \
+	SymTab/FixFunction.cc SymTab/ImplementationType.cc \
+	SymTab/TypeEquality.cc SymTab/Autogen.cc SynTree/Type.cc \
+	SynTree/VoidType.cc SynTree/BasicType.cc \
+	SynTree/PointerType.cc SynTree/ArrayType.cc \
+	SynTree/FunctionType.cc SynTree/ReferenceToType.cc \
+	SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \
 	SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \
 	SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \
@@ -721,4 +722,7 @@
 	ResolvExpr/$(am__dirstamp) \
 	ResolvExpr/$(DEPDIR)/$(am__dirstamp)
+ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT):  \
+	ResolvExpr/$(am__dirstamp) \
+	ResolvExpr/$(DEPDIR)/$(am__dirstamp)
 SymTab/$(am__dirstamp):
 	@$(MKDIR_P) SymTab
@@ -890,4 +894,5 @@
 	-rm -f ResolvExpr/driver_cfa_cpp-CommonType.$(OBJEXT)
 	-rm -f ResolvExpr/driver_cfa_cpp-ConversionCost.$(OBJEXT)
+	-rm -f ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT)
 	-rm -f ResolvExpr/driver_cfa_cpp-FindOpenVars.$(OBJEXT)
 	-rm -f ResolvExpr/driver_cfa_cpp-Occurs.$(OBJEXT)
@@ -1002,4 +1007,5 @@
 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CommonType.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ConversionCost.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-FindOpenVars.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Occurs.Po@am__quote@
@@ -1943,4 +1949,18 @@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-TypeEnvironment.obj `if test -f 'ResolvExpr/TypeEnvironment.cc'; then $(CYGPATH_W) 'ResolvExpr/TypeEnvironment.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/TypeEnvironment.cc'; fi`
 
+ResolvExpr/driver_cfa_cpp-CurrentObject.o: ResolvExpr/CurrentObject.cc
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-CurrentObject.o -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.o `test -f 'ResolvExpr/CurrentObject.cc' || echo '$(srcdir)/'`ResolvExpr/CurrentObject.cc
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='ResolvExpr/CurrentObject.cc' object='ResolvExpr/driver_cfa_cpp-CurrentObject.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.o `test -f 'ResolvExpr/CurrentObject.cc' || echo '$(srcdir)/'`ResolvExpr/CurrentObject.cc
+
+ResolvExpr/driver_cfa_cpp-CurrentObject.obj: ResolvExpr/CurrentObject.cc
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-CurrentObject.obj -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.obj `if test -f 'ResolvExpr/CurrentObject.cc'; then $(CYGPATH_W) 'ResolvExpr/CurrentObject.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/CurrentObject.cc'; fi`
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-CurrentObject.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='ResolvExpr/CurrentObject.cc' object='ResolvExpr/driver_cfa_cpp-CurrentObject.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-CurrentObject.obj `if test -f 'ResolvExpr/CurrentObject.cc'; then $(CYGPATH_W) 'ResolvExpr/CurrentObject.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/CurrentObject.cc'; fi`
+
 SymTab/driver_cfa_cpp-Indexer.o: SymTab/Indexer.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Indexer.o -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Indexer.Tpo -c -o SymTab/driver_cfa_cpp-Indexer.o `test -f 'SymTab/Indexer.cc' || echo '$(srcdir)/'`SymTab/Indexer.cc
Index: src/Parser/InitializerNode.cc
===================================================================
--- src/Parser/InitializerNode.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/Parser/InitializerNode.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -74,30 +74,27 @@
 
 	InitializerNode *moreInit;
-	if  ( get_next() != 0 && ((moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) != 0) )
+	if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
 		moreInit->printOneLine( os );
+	}
 }
 
 Initializer *InitializerNode::build() const {
 	if ( aggregate ) {
+		// steal designators from children
+		std::list< Designation * > designlist;
+		InitializerNode * child = next_init();
+		for ( ; child != nullptr; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) {
+			std::list< Expression * > desList;
+			buildList< Expression, ExpressionNode >( child->designator, desList );
+			designlist.push_back( new Designation( desList ) );
+		} // for
 		std::list< Initializer * > initlist;
 		buildList< Initializer, InitializerNode >( next_init(), initlist );
-
-		std::list< Expression * > designlist;
-
-		if ( designator != 0 ) {
-			buildList< Expression, ExpressionNode >( designator, designlist );
-		} // if
-
 		return new ListInit( initlist, designlist, maybeConstructed );
 	} else {
-		std::list< Expression * > designators;
-
-		if ( designator != 0 )
-			buildList< Expression, ExpressionNode >( designator, designators );
-
-		if ( get_expression() != 0)
-			return new SingleInit( maybeBuild< Expression >( get_expression() ), designators, maybeConstructed );
+		if ( get_expression() != 0) {
+			return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
+		}
 	} // if
-
 	return 0;
 }
Index: src/Parser/TypeData.cc
===================================================================
--- src/Parser/TypeData.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/Parser/TypeData.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -760,5 +760,5 @@
 		if ( cur->has_enumeratorValue() ) {
 			ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
-			member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), list< Expression * >() ) );
+			member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) );
 		} // if
 	} // for
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -604,10 +604,10 @@
 //	    )
 		SymTab::Indexer decls( indexer );
-		PRINT(
-			std::cerr << "============= original indexer" << std::endl;
-			indexer.print( std::cerr );
-			std::cerr << "============= new indexer" << std::endl;
-			decls.print( std::cerr );
-		)
+		// PRINT(
+		// 	std::cerr << "============= original indexer" << std::endl;
+		// 	indexer.print( std::cerr );
+		// 	std::cerr << "============= new indexer" << std::endl;
+		// 	decls.print( std::cerr );
+		// )
 		addToIndexer( have, decls );
 		AssertionSet newNeed;
@@ -1182,4 +1182,43 @@
 	}
 
+	void AlternativeFinder::visit( UntypedInitExpr *initExpr ) {
+		AlternativeFinder finder( indexer, env );
+		finder.findWithAdjustment( initExpr->get_expr() );
+		// handle each option like a cast -- should probably push this info into AltFinder as a kind of expression, both to keep common code close and to have less 'reach-in', but more 'push-in'
+		AltList candidates;
+		std::cerr << "untyped init expr: " << initExpr << std::endl;
+		// O(N^2) checks of d-types with e-types
+		for ( Alternative & alt : finder.get_alternatives() ) {
+			for ( InitAlternative & initAlt : initExpr->get_initAlts() ) {
+				AssertionSet needAssertions, haveAssertions;
+				OpenVarSet openVars;
+				std::cerr << "  " << initAlt.type << " " << initAlt.designation << std::endl;
+				// It's possible that a cast can throw away some values in a multiply-valued expression.  (An example is a
+				// cast-to-void, which casts from one value to zero.)  Figure out the prefix of the subexpression results
+				// that are cast directly.  The candidate is invalid if it has fewer results than there are types to cast
+				// to.
+				int discardedValues = alt.expr->get_result()->size() - initAlt.type->size();
+				if ( discardedValues < 0 ) continue;
+				// xxx - may need to go into tuple types and extract relevant types and use unifyList. Note that currently, this does not
+				// allow casting a tuple to an atomic type (e.g. (int)([1, 2, 3]))
+				// unification run for side-effects
+				unify( initAlt.type, alt.expr->get_result(), alt.env, needAssertions, haveAssertions, openVars, indexer );
+
+				Cost thisCost = castCost( alt.expr->get_result(), initAlt.type, indexer, alt.env );
+				if ( thisCost != Cost::infinity ) {
+					// count one safe conversion for each value that is thrown away
+					thisCost += Cost( 0, 0, discardedValues );
+					candidates.push_back( Alternative( new InitExpr( alt.expr->clone(), initAlt.type->clone(), initAlt.designation->clone() ), alt.env, alt.cost, thisCost ) );
+				}
+			}
+		}
+
+		// findMinCost selects the alternatives with the lowest "cost" members, but has the side effect of copying the
+		// cvtCost member to the cost member (since the old cost is now irrelevant).  Thus, calling findMinCost twice
+		// selects first based on argument cost, then on conversion cost.
+		AltList minArgCost;
+		findMinCost( candidates.begin(), candidates.end(), std::back_inserter( minArgCost ) );
+		findMinCost( minArgCost.begin(), minArgCost.end(), std::back_inserter( alternatives ) );
+	}
 } // namespace ResolvExpr
 
Index: src/ResolvExpr/AlternativeFinder.h
===================================================================
--- src/ResolvExpr/AlternativeFinder.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/ResolvExpr/AlternativeFinder.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -73,4 +73,5 @@
 		virtual void visit( UniqueExpr *unqExpr );
 		virtual void visit( StmtExpr *stmtExpr );
+		virtual void visit( UntypedInitExpr *initExpr );
 		/// Runs a new alternative finder on each element in [begin, end)
 		/// and writes each alternative finder to out.
Index: src/ResolvExpr/CurrentObject.cc
===================================================================
--- src/ResolvExpr/CurrentObject.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
+++ src/ResolvExpr/CurrentObject.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -0,0 +1,525 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// CurrentObject.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Tue Jun 13 15:28:32 2017
+// Last Modified By : Rob Schluntz
+// Last Modified On : Tue Jun 13 15:28:44 2017
+// Update Count     : 2
+//
+
+#include <stack>
+#include <iostream>
+
+#include "CurrentObject.h"
+
+#include "SynTree/Declaration.h"
+#include "SynTree/Initializer.h"
+#include "SynTree/Type.h"
+
+#if 0
+#define PRINT(x) x
+#else
+#define PRINT(x)
+#endif
+
+namespace ResolvExpr {
+	long long int getConstValue( ConstantExpr * constExpr ) {
+		if ( BasicType * basicType = dynamic_cast< BasicType * >( constExpr->get_result() ) ) {
+			if ( basicType->get_kind() == BasicType::Char || basicType->get_kind() == BasicType::SignedChar || basicType->get_kind() == BasicType::UnsignedChar ) {
+				assertf( constExpr->get_constant()->get_value().size() == 3, "constant value with unusual length: %s", constExpr->get_constant()->get_value().c_str() );
+				return constExpr->get_constant()->get_value()[1];
+			} else {
+				return stoll( constExpr->get_constant()->get_value() );
+			}
+		} else {
+			assertf( false, "unhandled type on getConstValue %s", constExpr->get_result() );
+		}
+	}
+
+	struct Indenter {
+		static const int amt = 2;
+		unsigned int indent = 0;
+
+		Indenter & operator+=(int nlevels) { indent += amt*nlevels; return *this; }
+		Indenter & operator-=(int nlevels) { indent -= amt*nlevels; return *this; }
+		Indenter operator+(int nlevels) { Indenter indenter = *this; return indenter += nlevels; }
+		Indenter operator-(int nlevels) { Indenter indenter = *this; return indenter -= nlevels; }
+		Indenter & operator++() { return *this += 1; }
+		Indenter & operator--() { return *this -= 1; }
+	};
+	std::ostream & operator<<( std::ostream & out, Indenter & indent ) {
+		return out << std::string(indent.indent, ' ');
+	}
+
+	class MemberIterator {
+	public:
+		virtual ~MemberIterator() {}
+
+		virtual void setPosition( std::list< Expression * > & designators ) = 0;
+		virtual std::list<InitAlternative> operator*() const = 0;
+		virtual operator bool() const = 0;
+		virtual MemberIterator & bigStep() = 0;
+		virtual MemberIterator & smallStep() = 0;
+		virtual Type * getType() = 0;
+		virtual Type * getNext() = 0;
+
+		virtual void print( std::ostream & out, Indenter indent ) const = 0;
+
+		virtual std::list<InitAlternative> first() const = 0; // should be protected
+	};
+
+	std::ostream & operator<<(std::ostream & out, const MemberIterator & it) {
+		Indenter indenter;
+		it.print( out, indenter );
+		return out;
+	}
+
+	/// create a new MemberIterator that traverses a type correctly
+	MemberIterator * createMemberIterator( Type * type );
+
+	/// iterates "other" types, e.g. basic types, pointer types, etc. which do not change at list initializer entry
+	class SimpleIterator : public MemberIterator {
+	public:
+		SimpleIterator( Type * type ) : type( type ) {}
+
+		virtual void setPosition( std::list< Expression * > & designators ) {
+			assertf( designators.empty(), "simple iterator given non-empty designator..." ); // xxx - might be semantic error
+		}
+
+		virtual std::list<InitAlternative> operator*() const { return first(); }
+		virtual operator bool() const { return type; }
+
+		// big step is the same as small step
+		virtual MemberIterator & bigStep() { return smallStep(); }
+		virtual MemberIterator & smallStep() {
+			type = nullptr;  // type is nullified on increment since SimpleIterators do not have members
+			return *this;
+		}
+
+		virtual void print( std::ostream & out, Indenter indent ) const {
+			out << "SimpleIterator(" << type << ")";
+		}
+
+		virtual Type * getType() { return type; }
+		virtual Type * getNext() { return type; }
+
+	protected:
+		virtual std::list<InitAlternative> first() const {
+			if ( type ) return std::list<InitAlternative>{ { type->clone(), new Designation( {} ) } };
+			else return std::list<InitAlternative>{};
+		}
+	private:
+		Type * type = nullptr;
+	};
+
+	class ArrayIterator : public MemberIterator {
+	public:
+		ArrayIterator( ArrayType * at ) : array( at ) {
+			PRINT( std::cerr << "Creating array iterator: " << at << std::endl; )
+			base = at->get_base();
+			memberIter = createMemberIterator( base );
+			setSize( at->get_dimension() );
+		}
+
+		~ArrayIterator() {
+			delete memberIter;
+		}
+
+	private:
+		void setSize( Expression * expr ) {
+			if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
+				size = getConstValue( constExpr ); // xxx - if not a constant expression, it's not simple to determine how long the array actually is, which is necessary for initialization to be done correctly -- fix this
+				PRINT( std::cerr << "array type with size: " << size << std::endl; )
+			}	else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
+				setSize( castExpr->get_arg() );
+			} else {
+				assertf( false, "unhandled expression in setSize: %s", toString( expr ).c_str() );
+			}
+		}
+
+	public:
+		void setPosition( Expression * expr ) {
+			// need to permit integer-constant-expressions, including: integer constants, enumeration constants, character constants, sizeof expressions, _Alignof expressions, cast expressions
+			if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
+				index = getConstValue( constExpr );
+			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
+				setPosition( castExpr->get_arg() );
+			} else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
+				assertf( dynamic_cast<EnumInstType *> ( varExpr->get_result() ), "ArrayIterator given variable that isn't an enum constant", toString( expr ).c_str() );
+				index = 0; // xxx - get actual value of enum constant
+			} else if ( dynamic_cast< SizeofExpr * >( expr ) || dynamic_cast< AlignofExpr * >( expr ) ) {
+				index = 0; // xxx - get actual sizeof/alignof value?
+			} else {
+				assertf( false, "bad designator given to ArrayIterator: %s", toString( expr ).c_str() );
+			}
+		}
+
+		virtual void setPosition( std::list< Expression * > & designators ) {
+			if ( ! designators.empty() ) {
+				setPosition( designators.front() );
+				designators.pop_front();
+				memberIter->setPosition( designators );
+			}
+		}
+
+		virtual std::list<InitAlternative> operator*() const {
+			return first();
+		}
+
+		virtual operator bool() const { return index < size; }
+
+		virtual MemberIterator & bigStep() {
+			PRINT( std::cerr << "bigStep in ArrayIterator (" << index << "/" << size << ")" << std::endl; )
+			++index;
+			delete memberIter;
+			if ( index < size ) memberIter = createMemberIterator( base );
+			else memberIter = nullptr;
+			return *this;
+		}
+
+		virtual MemberIterator & smallStep() {
+			PRINT( std::cerr << "smallStep in ArrayIterator (" << index << "/" << size << ")" << std::endl; )
+			if ( memberIter ) {
+				PRINT( std::cerr << "has member iter: " << *memberIter << std::endl; )
+				memberIter->smallStep();
+				if ( *memberIter ) {
+					PRINT( std::cerr << "has valid member iter" << std::endl; )
+					return *this;
+				}
+			}
+			return bigStep();
+		}
+
+		virtual Type * getType() { return array; }
+		virtual Type * getNext() { return base; }
+
+		virtual std::list<InitAlternative> first() const {
+			PRINT( std::cerr << "first in ArrayIterator (" << index << "/" << size << ")" << std::endl; )
+			if ( memberIter && *memberIter ) {
+				std::list<InitAlternative> ret = memberIter->first();
+				for ( InitAlternative & alt : ret ) {
+					alt.designation->get_designators().push_front( new ConstantExpr( Constant::from_ulong( index ) ) );
+				}
+				return ret;
+			}
+			return std::list<InitAlternative>();
+		}
+
+		virtual void print( std::ostream & out, Indenter indent ) const {
+			out << "ArrayIterator(Array of " << base << ")";
+			if ( memberIter ) {
+				Indenter childIndent = indent+1;
+				out << std::endl << childIndent;
+				memberIter->print( out, childIndent );
+			}
+		}
+
+	private:
+		ArrayType * array = nullptr;
+		Type * base = nullptr;
+		size_t index = 0;
+		size_t size = 0;
+		MemberIterator * memberIter = nullptr;
+	};
+
+	class AggregateIterator : public MemberIterator {
+	public:
+		typedef std::list<Declaration *>::iterator iterator;
+		const char * kind = ""; // for debug
+		ReferenceToType * inst = nullptr;
+		AggregateDecl * decl = nullptr;
+		iterator curMember;
+		bool atbegin = true; // false at first {small,big}Step -- this struct type is only added to the possibilities at the beginning
+		Type * curType = nullptr;
+		MemberIterator * memberIter = nullptr;
+
+		AggregateIterator( const char * kind, ReferenceToType * inst, AggregateDecl * decl ) : kind( kind ), inst( inst ), decl( decl ), curMember( decl->get_members().begin() ) {
+			init();
+		}
+
+		virtual ~AggregateIterator() {
+			delete memberIter;
+		}
+
+		bool init() {
+			PRINT( std::cerr << "--init()--" << std::endl; )
+			if ( curMember != decl->get_members().end() ) {
+				if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( *curMember ) ) {
+					PRINT( std::cerr << "incremented to field: " << field << std::endl; )
+					curType = field->get_type();
+					memberIter = createMemberIterator( curType );
+					return true;
+				}
+			}
+			return false;
+		}
+
+		virtual std::list<InitAlternative> operator*() const {
+			if (memberIter && *memberIter) {
+				std::list<InitAlternative> ret = memberIter->first();
+				for ( InitAlternative & alt : ret ) {
+					PRINT( std::cerr << "iterating and adding designators" << std::endl; )
+					alt.designation->get_designators().push_front( new VariableExpr( safe_dynamic_cast< ObjectDecl * >( *curMember ) ) );
+				}
+				return ret;
+			}
+			return std::list<InitAlternative>();
+		}
+
+		virtual void setPosition( std::list< Expression * > & designators ) {
+			if ( ! designators.empty() ) {
+				if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( designators.front() ) ) {
+					for ( curMember = decl->get_members().begin(); curMember != decl->get_members().end(); ++curMember ) {
+						if ( *curMember == varExpr->get_var() ) {
+							designators.pop_front();
+							delete memberIter;
+							memberIter = createMemberIterator( varExpr->get_result() );
+							curType = varExpr->get_result();
+							atbegin = curMember == decl->get_members().begin() && designators.empty(); // xxx - is this right??
+							memberIter->setPosition( designators );
+							return;
+						} // if
+					} // for
+					assertf( false, "could not find member in %s: %s", kind, toString( varExpr ).c_str() );
+				} else {
+					assertf( false, "bad designator given to %s: %s", kind, toString( designators.front() ).c_str() );
+				} // if
+			} // if
+		}
+
+		virtual MemberIterator & smallStep() {
+			PRINT( std::cerr << "smallStep in " << kind << std::endl; )
+			atbegin = false;
+			if ( memberIter ) {
+				PRINT( std::cerr << "has member iter, incrementing..." << std::endl; )
+				memberIter->smallStep();
+				if ( *memberIter ) {
+					PRINT( std::cerr << "success!" << std::endl; )
+					return *this;
+				}
+			}
+			return bigStep();
+		}
+
+		virtual Type * getType() { return inst; }
+		virtual Type * getNext() {
+			if ( memberIter && *memberIter ) return memberIter->getType(); // xxx - ??? recursive call???
+			return nullptr;
+		}
+
+		virtual std::list<InitAlternative> first() const {
+			std::list<InitAlternative> ret;
+			PRINT( std::cerr << "first " << kind << std::endl; )
+			if ( memberIter && *memberIter ) { // might not need *memberIter??
+				PRINT( std::cerr << "adding children" << std::endl; )
+				ret = memberIter->first();
+				for ( InitAlternative & alt : ret ) {
+					PRINT( std::cerr << "iterating and adding designators" << std::endl; )
+					alt.designation->get_designators().push_front( new VariableExpr( safe_dynamic_cast< ObjectDecl * >( *curMember ) ) );
+				}
+			}
+			// if ( curMember == std::next( decl->get_members().begin(), 1 ) ) { // xxx - this never triggers because curMember is incremented immediately on construction
+			if ( atbegin ) { // xxx - this never triggers because curMember is incremented immediately on construction
+				// xxx - what about case of empty struct??
+				// only add self if at the very beginning of the structure
+				PRINT( std::cerr << "adding self" << std::endl; )
+				ret.push_front( { inst->clone(), new Designation( {} ) } );
+			}
+			return ret;
+		}
+
+		virtual void print( std::ostream & out, Indenter indent ) const {
+			out << kind << "(" << decl->get_name() << ")";
+			if ( memberIter ) {
+				Indenter childIndent = indent+1;
+				out << std::endl << childIndent;
+				memberIter->print( out, childIndent );
+			}
+		}
+	};
+
+	class UnionIterator : public AggregateIterator {
+	public:
+		UnionIterator( UnionInstType * inst ) : AggregateIterator( "UnionIterator", inst, inst->get_baseUnion() ) {}
+
+		virtual operator bool() const { return (memberIter && *memberIter); }
+		virtual MemberIterator & bigStep() {
+			// unions only initialize one member
+			PRINT( std::cerr << "bigStep in " << kind << std::endl; )
+			atbegin = false;
+			delete memberIter;
+			memberIter = nullptr;
+			curType = nullptr;
+			curMember = decl->get_members().end();
+			return *this;
+		}
+		virtual std::list<InitAlternative> first() const { return std::list<InitAlternative>{}; }
+	};
+
+	class StructIterator : public AggregateIterator {
+	public:
+		StructIterator( StructInstType * inst ) : AggregateIterator( "StructIterator", inst, inst->get_baseStruct() ) {}
+
+		virtual operator bool() const { return curMember != decl->get_members().end() || (memberIter && *memberIter); }
+
+		virtual MemberIterator & bigStep() {
+			PRINT( std::cerr << "bigStep in " << kind << std::endl; )
+			atbegin = false;
+			delete memberIter;
+			memberIter = nullptr;
+			curType = nullptr;
+			for ( ; curMember != decl->get_members().end(); ) {
+				++curMember;
+				if ( init() ) {
+					return *this;
+				}
+			}
+			return *this;
+		}
+	};
+
+	MemberIterator * createMemberIterator( Type * type ) {
+		if ( ReferenceToType * aggr = dynamic_cast< ReferenceToType * >( type ) ) {
+			if ( StructInstType * sit = dynamic_cast< StructInstType * >( aggr ) ) {
+				return new StructIterator( sit );
+			} else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( aggr ) ) {
+				return new UnionIterator( uit );
+			} else {
+				assertf( false, "some other reftotype" );
+			}
+		} else if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
+			return new ArrayIterator( at );
+		} else {
+			return new SimpleIterator( type );
+		}
+	}
+
+	CurrentObject::CurrentObject() {}
+	CurrentObject::CurrentObject( Type * type ) {
+		objStack.push( new SimpleIterator( type ) );
+	}
+
+
+	void CurrentObject::setNext( Designation * designation ) {
+		assertf( ! objStack.empty(), "obj stack empty in setNext" );
+		PRINT( std::cerr << "____setNext" << designation << std::endl; )
+		objStack.top()->setPosition( designation->get_designators() );
+	}
+
+	Designation * CurrentObject::findNext( Designation * designation ) {
+		typedef std::list< Expression * > DesignatorChain;
+		PRINT( std::cerr << "___findNext" << std::endl; )
+		// find all the d's
+		std::list<DesignatorChain> desigAlts{ { } }, newDesigAlts;
+		std::list<Type *> curTypes { (objStack.top())->getType() }, newTypes;
+		for ( Expression * expr : designation->get_designators() ) {
+			PRINT( std::cerr << "____untyped: " << expr << std::endl; )
+			std::list<DesignatorChain>::iterator dit = desigAlts.begin();
+			if ( NameExpr * nexpr = dynamic_cast<NameExpr *>(expr) ) {
+				for ( Type * t : curTypes ) {
+					assert( dit != desigAlts.end() );
+					DesignatorChain & d = *dit;
+					PRINT( std::cerr << "____actual: " << t << std::endl; )
+					ReferenceToType * refType = dynamic_cast<ReferenceToType *>(t);
+					std::list<Declaration *> members;
+					if ( refType ) {
+						refType->lookup( nexpr->get_name(), members ); // concatenate identical field name
+						// xxx - need to also include anonymous members in this somehow...
+						for ( Declaration * mem: members ) {
+							if ( ObjectDecl * field = dynamic_cast<ObjectDecl *>(mem) ) {
+								PRINT( std::cerr << "____alt: " << field->get_type() << std::endl; )
+								DesignatorChain newD = d;
+								newD.push_back( new VariableExpr( field ) );
+								newDesigAlts.push_back( newD );
+								newTypes.push_back( field->get_type() );
+							} // if
+						} // for
+					} // if
+					++dit;
+				} // for
+			} else {
+				for ( Type * t : curTypes ) {
+					assert( dit != desigAlts.end() );
+					DesignatorChain & d = *dit;
+					if ( ArrayType * at = dynamic_cast< ArrayType * > ( t ) ) {
+						PRINT( std::cerr << "____alt: " << at->get_base() << std::endl; )
+						d.push_back( expr );
+						newDesigAlts.push_back( d );
+						newTypes.push_back( at->get_base() );
+					}
+					++dit;
+				} // for
+			} // if
+			desigAlts = newDesigAlts;
+			newDesigAlts.clear();
+			curTypes = newTypes;
+			newTypes.clear();
+			assertf( desigAlts.size() == curTypes.size(), "Designator alternatives (%d) and current types (%d) out of sync", desigAlts.size(), curTypes.size() );
+		} // for
+		if ( desigAlts.size() > 1 ) {
+			throw SemanticError( toString("Too many alternatives (", desigAlts.size(), ") for designation: "), designation );
+		} else if ( desigAlts.size() == 0 ) {
+			throw SemanticError( "No reasonable alternatives for designation: ", designation );
+		}
+		DesignatorChain & d = desigAlts.back();
+		PRINT( for ( Expression * expr : d ) {
+			std::cerr << "____desig: " << expr << std::endl;
+		} ) // for
+		assertf( ! curTypes.empty(), "empty designator chosen");
+
+		// set new designators
+		assertf( ! objStack.empty(), "empty object stack when setting designation" );
+		Designation * actualDesignation = new Designation( d );
+		objStack.top()->setPosition( d ); // destroys d
+		return actualDesignation;
+	}
+
+	void CurrentObject::increment() {
+		PRINT( std::cerr << "____increment" << std::endl; )
+		if ( ! objStack.empty() ) {
+			PRINT( std::cerr << *objStack.top() << std::endl; )
+			objStack.top()->smallStep();
+		}
+	}
+
+	void CurrentObject::enterListInit() {
+		PRINT( std::cerr << "____entering list init" << std::endl; )
+		assertf( ! objStack.empty(), "empty obj stack entering list init" );
+		Type * type = objStack.top()->getNext();
+		if ( type ) {
+			// xxx - record types.front()?
+			objStack.push( createMemberIterator( type ) );
+		} else {
+			assertf( false, "not sure about this case..." );
+		}
+	}
+
+	void CurrentObject::exitListInit() {
+		PRINT( std::cerr << "____exiting list init" << std::endl; )
+		assertf( ! objStack.empty(), "objstack empty" );
+		delete objStack.top();
+		objStack.pop();
+		if ( ! objStack.empty() ) {
+			PRINT( std::cerr << *objStack.top() << std::endl; )
+			objStack.top()->bigStep();
+		}
+	}
+
+	std::list< InitAlternative > CurrentObject::getOptions() {
+		PRINT( std::cerr << "____getting current options" << std::endl; )
+		assertf( ! objStack.empty(), "objstack empty in getOptions" );
+		return **objStack.top();
+	}
+} // namespace ResolvExpr
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/ResolvExpr/CurrentObject.h
===================================================================
--- src/ResolvExpr/CurrentObject.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
+++ src/ResolvExpr/CurrentObject.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -0,0 +1,57 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// CurrentObject.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Thu Jun  8 11:07:25 2017
+// Last Modified By : Rob Schluntz
+// Last Modified On : Thu Jun  8 11:07:41 2017
+// Update Count     : 2
+//
+
+#ifndef CURRENT_OBJECT_H
+#define CURRENT_OBJECT_H
+
+#include <stack>
+
+#include "SynTree/SynTree.h"
+#include "SynTree/Expression.h"
+
+namespace ResolvExpr {
+	class MemberIterator;
+
+	class CurrentObject {
+	public:
+		CurrentObject();
+		CurrentObject( Type * type );
+
+		/// resolves unresolved designation
+		Designation * findNext( Designation * designation );
+		/// sets current position using resolved designation
+		void setNext( Designation * designation );
+		/// steps to next sub-object of current-object
+		void increment();
+		/// sets new current-object for the duration of this brace-enclosed initializer-list
+		void enterListInit();
+		/// restores previous current-object
+		void exitListInit();
+		/// produces a list of alternatives (Type *, Designation *) for the current sub-object's initializer
+		std::list< InitAlternative > getOptions();
+
+	private:
+		std::stack< MemberIterator * > objStack;
+	};
+} // namespace ResolvExpr
+
+#endif // CURRENT_OBJECT_H
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
+
Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/ResolvExpr/Resolver.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -14,20 +14,26 @@
 //
 
+#include <iostream>
+
+#include "Alternative.h"
+#include "AlternativeFinder.h"
+#include "CurrentObject.h"
+#include "RenameVars.h"
 #include "Resolver.h"
-#include "AlternativeFinder.h"
-#include "Alternative.h"
-#include "RenameVars.h"
 #include "ResolveTypeof.h"
 #include "typeops.h"
+
+#include "SynTree/Expression.h"
+#include "SynTree/Initializer.h"
 #include "SynTree/Statement.h"
 #include "SynTree/Type.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Initializer.h"
+
+#include "SymTab/Autogen.h"
 #include "SymTab/Indexer.h"
-#include "SymTab/Autogen.h"
+
 #include "Common/utility.h"
+
 #include "InitTweak/InitTweak.h"
 
-#include <iostream>
 using namespace std;
 
@@ -39,5 +45,5 @@
 			if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) {
 				functionReturn = res->functionReturn;
-				initContext = res->initContext;
+				currentObject = res->currentObject;
 				inEnumDecl = res->inEnumDecl;
 			}
@@ -79,5 +85,5 @@
 
 		Type * functionReturn = nullptr;
-		Type *initContext = nullptr;
+		CurrentObject currentObject = nullptr;
 		bool inEnumDecl = false;
 	};
@@ -186,17 +192,16 @@
 		// each value of initContext is retained, so the type on the first analysis is preserved and used for selecting
 		// the RHS.
-		Type *temp = initContext;
-		initContext = new_type;
-		if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
+		ValueGuard<CurrentObject> temp( currentObject );
+		currentObject = CurrentObject( objectDecl->get_type() );
+		if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) {
 			// enumerator initializers should not use the enum type to initialize, since
 			// the enum type is still incomplete at this point. Use signed int instead.
-			initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
+			currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
 		}
 		Parent::visit( objectDecl );
-		if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
+		if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) {
 			// delete newly created signed int type
-			delete initContext;
-		}
-		initContext = temp;
+			// delete currentObject.getType();
+		}
 	}
 
@@ -315,5 +320,5 @@
 
 	void Resolver::visit( SwitchStmt *switchStmt ) {
-		ValueGuard< Type * > oldInitContext( initContext );
+		ValueGuard< CurrentObject > oldCurrentObject( currentObject );
 		Expression *newExpr;
 		newExpr = findIntegralExpression( switchStmt->get_condition(), *this );
@@ -321,5 +326,5 @@
 		switchStmt->set_condition( newExpr );
 
-		initContext = newExpr->get_result();
+		currentObject = CurrentObject( newExpr->get_result() );
 		Parent::visit( switchStmt );
 	}
@@ -327,6 +332,7 @@
 	void Resolver::visit( CaseStmt *caseStmt ) {
 		if ( caseStmt->get_condition() ) {
-			assert( initContext );
-			CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initContext->clone() );
+			std::list< InitAlternative > initAlts = currentObject.getOptions();
+			assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." );
+			CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initAlts.front().type->clone() );
 			Expression * newExpr = findSingleExpression( castExpr, *this );
 			castExpr = safe_dynamic_cast< CastExpr * >( newExpr );
@@ -369,206 +375,123 @@
 	}
 
+	template< typename Aggr >
+	void lookupDesignation( Aggr * aggr, const std::list< Expression > & designators ) {
+
+	}
+
 	void Resolver::visit( SingleInit *singleInit ) {
-		if ( singleInit->get_value() ) {
-			// // find all the d's
-			// std::list<Expression *> &designators = singleInit->get_designators();
-			// std::list<Type *> types1{ initContext }, types2;
-			// for ( Expression * expr: designators ) {
-			// 	cerr << expr << endl;
-			// 	if ( NameExpr * nexpr = dynamic_cast<NameExpr *>( expr ) ) {
-			// 		for ( Type * type: types1 ) {
-			// 			cerr << type << endl;
-			// 			ReferenceToType * fred = dynamic_cast<ReferenceToType *>(type);
-			// 			std::list<Declaration *> members;
-			// 			if ( fred ) {
-			// 				fred->lookup( nexpr->get_name(), members ); // concatenate identical field name
-			// 				for ( Declaration * mem: members ) {
-			// 					if ( DeclarationWithType * dwt = dynamic_cast<DeclarationWithType *>(mem) ) {
-			// 						types2.push_back( dwt->get_type() );
-			// 					} // if
-			// 				} // for
-			// 			} // if
-			// 		} // for
-			// 		types1 = types2;
-			// 		types2.clear();
-			// 	} // if
-			// } // for
-			// // for ( Type * type: types1 ) {
-			// // 	cerr << type << endl;
-			// // } // for
-
-			// // O(N^2) checks of d-types with f-types
-			// // find the minimum cost
-			CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
-			Expression *newExpr = findSingleExpression( castExpr, *this );
-			delete castExpr;
-			singleInit->set_value( newExpr );
-
-			// check if initializing type is char[]
-			if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
-				if ( isCharType( at->get_base() ) ) {
-					// check if the resolved type is char *
-					if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
-						if ( isCharType( pt->get_base() ) ) {
-							// strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
-							CastExpr *ce = dynamic_cast< CastExpr * >( newExpr );
-							singleInit->set_value( ce->get_arg() );
-							ce->set_arg( NULL );
-							delete ce;
-						}
-					}
-				}
-			}
-		} // if
-	}
-
-	template< typename AggrInst >
-	TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) {
-		assert( inst );
-		assert( inst->get_baseParameters() );
-		std::list< TypeDecl * > baseParams = *inst->get_baseParameters();
-		std::list< Expression * > typeSubs = inst->get_parameters();
-		TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() );
-		return subs;
-	}
-
-	ReferenceToType * isStructOrUnion( Type * type ) {
-		if ( StructInstType * sit = dynamic_cast< StructInstType * >( type ) ) {
-			return sit;
-		} else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( type ) ) {
-			return uit;
-		}
-		return nullptr;
-	}
-
-	void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd, TypeSubstitution sub ) {
-		DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl );
-		assert( dt );
-		// need to substitute for generic types, so that casts are to concrete types
-		initContext = dt->get_type()->clone();
-		sub.apply( initContext );
-
-		try {
-			if ( init == initEnd ) return; // stop when there are no more initializers
-			(*init)->accept( *this );
-			++init; // made it past an initializer
-		} catch( SemanticError & ) {
-			// need to delve deeper, if you can
-			if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
-				resolveAggrInit( type, init, initEnd );
-			} else {
-				// member is not an aggregate type, so can't go any deeper
-
-				// might need to rethink what is being thrown
-				throw;
-			} // if
-		}
-	}
-
-	void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) {
-		if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) {
-			TypeSubstitution sub = makeGenericSubstitutuion( sit );
-			StructDecl * st = sit->get_baseStruct();
-			if(st->get_members().empty()) return;
-			// want to resolve each initializer to the members of the struct,
-			// but if there are more initializers than members we should stop
-			list< Declaration * >::iterator it = st->get_members().begin();
-			for ( ; it != st->get_members().end(); ++it) {
-				resolveSingleAggrInit( *it, init, initEnd, sub );
-			}
-		} else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
-			TypeSubstitution sub = makeGenericSubstitutuion( uit );
-			UnionDecl * un = uit->get_baseUnion();
-			if(un->get_members().empty()) return;
-			// only resolve to the first member of a union
-			resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub );
-		} // if
-	}
+		UntypedInitExpr * untyped = new UntypedInitExpr( singleInit->get_value(), currentObject.getOptions() );
+		Expression * newExpr = findSingleExpression( untyped, *this );
+		InitExpr * initExpr = safe_dynamic_cast< InitExpr * >( newExpr );
+		singleInit->set_value( new CastExpr( initExpr->get_expr()->clone(), initExpr->get_result()->clone() ) );
+		currentObject.setNext( initExpr->get_designation() );
+		currentObject.increment();
+		delete initExpr;
+
+		// // check if initializing type is char[]
+		// if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
+		// 	if ( isCharType( at->get_base() ) ) {
+		// 		// check if the resolved type is char *
+		// 		if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
+		// 			if ( isCharType( pt->get_base() ) ) {
+		// 				// strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
+		// 				CastExpr *ce = dynamic_cast< CastExpr * >( newExpr );
+		// 				singleInit->set_value( ce->get_arg() );
+		// 				ce->set_arg( NULL );
+		// 				delete ce;
+		// 			}
+		// 		}
+		// 	}
+		// }
+	}
+
+	// template< typename AggrInst >
+	// TypeSubstitution makeGenericSubstitution( AggrInst * inst ) {
+	// 	assert( inst );
+	// 	assert( inst->get_baseParameters() );
+	// 	std::list< TypeDecl * > baseParams = *inst->get_baseParameters();
+	// 	std::list< Expression * > typeSubs = inst->get_parameters();
+	// 	TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() );
+	// 	return subs;
+	// }
+
+	// ReferenceToType * isStructOrUnion( Type * type ) {
+	// 	if ( StructInstType * sit = dynamic_cast< StructInstType * >( type ) ) {
+	// 		return sit;
+	// 	} else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( type ) ) {
+	// 		return uit;
+	// 	}
+	// 	return nullptr;
+	// }
+
+	// void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd, TypeSubstitution sub ) {
+	// 	ObjectDecl * obj = dynamic_cast< ObjectDecl * >( dcl );
+	// 	assert( obj );
+	// 	// need to substitute for generic types, so that casts are to concrete types
+	// 	currentObject = obj->clone();  // xxx - delete this
+	// 	sub.apply( currentObject );
+
+	// 	try {
+	// 		if ( init == initEnd ) return; // stop when there are no more initializers
+	// 		(*init)->accept( *this );
+	// 		++init; // made it past an initializer
+	// 	} catch( SemanticError & ) {
+	// 		// need to delve deeper, if you can
+	// 		if ( ReferenceToType * type = isStructOrUnion( currentObject->get_type() ) ) {
+	// 			resolveAggrInit( type, init, initEnd );
+	// 		} else {
+	// 			// member is not an aggregate type, so can't go any deeper
+
+	// 			// might need to rethink what is being thrown
+	// 			throw;
+	// 		} // if
+	// 	}
+	// }
+
+	// void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) {
+	// 	if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) {
+	// 		TypeSubstitution sub = makeGenericSubstitution( sit );
+	// 		StructDecl * st = sit->get_baseStruct();
+	// 		if(st->get_members().empty()) return;
+	// 		// want to resolve each initializer to the members of the struct,
+	// 		// but if there are more initializers than members we should stop
+	// 		list< Declaration * >::iterator it = st->get_members().begin();
+	// 		for ( ; it != st->get_members().end(); ++it) {
+	// 			resolveSingleAggrInit( *it, init, initEnd, sub );
+	// 		}
+	// 	} else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
+	// 		TypeSubstitution sub = makeGenericSubstitution( uit );
+	// 		UnionDecl * un = uit->get_baseUnion();
+	// 		if(un->get_members().empty()) return;
+	// 		// only resolve to the first member of a union
+	// 		resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub );
+	// 	} // if
+	// }
 
 	void Resolver::visit( ListInit * listInit ) {
-		InitIterator iter = listInit->begin();
-		InitIterator end = listInit->end();
-
-		if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
-			// resolve each member to the base type of the array
-			for ( ; iter != end; ++iter ) {
-				initContext = at->get_base();
-				(*iter)->accept( *this );
-			} // for
-		} else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
-			for ( Type * t : *tt ) {
-				if ( iter == end ) break;
-				initContext = t;
-				(*iter++)->accept( *this );
-			}
-		} else if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
-			resolveAggrInit( type, iter, end );
-		} else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
-			Type * base = tt->get_baseType()->get_base();
-			if ( base ) {
-				// know the implementation type, so try using that as the initContext
-				initContext = base;
-				visit( listInit );
-			} else {
-				// missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
-				Parent::visit( listInit );
-			}
-		} else {
-			assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
-			        || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) );
-			// basic types are handled here
-			Parent::visit( listInit );
-		}
-
-#if 0
-		if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) {
-			std::list<Initializer *>::iterator iter( listInit->begin_initializers() );
-			for ( ; iter != listInit->end_initializers(); ++iter ) {
-				initContext = at->get_base();
-				(*iter)->accept( *this );
-			} // for
-		} else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) {
-			StructDecl *baseStruct = st->get_baseStruct();
-			std::list<Declaration *>::iterator iter1( baseStruct->get_members().begin() );
-			std::list<Initializer *>::iterator iter2( listInit->begin_initializers() );
-			for ( ; iter1 != baseStruct->get_members().end() && iter2 != listInit->end_initializers(); ++iter2 ) {
-				if ( (*iter2)->get_designators().empty() ) {
-					DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *iter1 );
-					initContext = dt->get_type();
-					(*iter2)->accept( *this );
-					++iter1;
-				} else {
-					StructDecl *st = baseStruct;
-					iter1 = st->get_members().begin();
-					std::list<Expression *>::iterator iter3( (*iter2)->get_designators().begin() );
-					for ( ; iter3 != (*iter2)->get_designators().end(); ++iter3 ) {
-						NameExpr *key = dynamic_cast<NameExpr *>( *iter3 );
-						assert( key );
-						for ( ; iter1 != st->get_members().end(); ++iter1 ) {
-							if ( key->get_name() == (*iter1)->get_name() ) {
-								(*iter1)->print( cout );
-								cout << key->get_name() << endl;
-								ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
-								assert( fred );
-								StructInstType *mary = dynamic_cast<StructInstType*>( fred->get_type() );
-								assert( mary );
-								st = mary->get_baseStruct();
-								iter1 = st->get_members().begin();
-								break;
-							} // if
-						}  // for
-					} // for
-					ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
-					assert( fred );
-					initContext = fred->get_type();
-					(*listInit->begin_initializers())->accept( *this );
-				} // if
-			} // for
-		} else if ( UnionInstType *st = dynamic_cast<UnionInstType*>(initContext) ) {
-			DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *st->get_baseUnion()->get_members().begin() );
-			initContext = dt->get_type();
-			(*listInit->begin_initializers())->accept( *this );
-		} // if
-#endif
+		currentObject.enterListInit();
+		// xxx - fix this so that the list isn't copied, iterator should be used to change current element
+		std::list<Designation *> newDesignations;
+		for ( auto p : group_iterate(listInit->get_designations(), listInit->get_initializers()) ) {
+			Designation * des = std::get<0>(p);
+			Initializer * init = std::get<1>(p);
+			newDesignations.push_back( currentObject.findNext( des ) );
+			init->accept( *this );
+		}
+		listInit->get_designations() = newDesignations; // xxx - memory management
+		currentObject.exitListInit();
+
+		// } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
+		// 	Type * base = tt->get_baseType()->get_base();
+		// 	if ( base ) {
+		// 		// know the implementation type, so try using that as the initContext
+		// 		ObjectDecl tmpObj( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, base->clone(), nullptr );
+		// 		currentObject = &tmpObj;
+		// 		visit( listInit );
+		// 	} else {
+		// 		// missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
+		// 		Parent::visit( listInit );
+		// 	}
+		// } else {
 	}
 
Index: src/ResolvExpr/module.mk
===================================================================
--- src/ResolvExpr/module.mk	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/ResolvExpr/module.mk	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -6,5 +6,5 @@
 ## file "LICENCE" distributed with Cforall.
 ##
-## module.mk -- 
+## module.mk --
 ##
 ## Author           : Richard C. Bilson
@@ -31,3 +31,4 @@
        ResolvExpr/PolyCost.cc \
        ResolvExpr/Occurs.cc \
-       ResolvExpr/TypeEnvironment.cc
+       ResolvExpr/TypeEnvironment.cc \
+       ResolvExpr/CurrentObject.cc
Index: src/SymTab/Autogen.h
===================================================================
--- src/SymTab/Autogen.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SymTab/Autogen.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -25,21 +25,21 @@
 
 namespace SymTab {
-    /// Generates assignment operators, constructors, and destructor for aggregate types as required
-    void autogenerateRoutines( std::list< Declaration * > &translationUnit );
+	/// Generates assignment operators, constructors, and destructor for aggregate types as required
+	void autogenerateRoutines( std::list< Declaration * > &translationUnit );
 
-    /// returns true if obj's name is the empty string and it has a bitfield width
-    bool isUnnamedBitfield( ObjectDecl * obj );
+	/// returns true if obj's name is the empty string and it has a bitfield width
+	bool isUnnamedBitfield( ObjectDecl * obj );
 
-    /// size_t type - set when size_t typedef is seen. Useful in a few places,
-    /// such as in determining array dimension type
-    extern Type * SizeType;
+	/// size_t type - set when size_t typedef is seen. Useful in a few places,
+	/// such as in determining array dimension type
+	extern Type * SizeType;
 
-    /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
-    template< typename OutputIterator >
+	/// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
+	template< typename OutputIterator >
 	Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
 
-    /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
-    /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
-    template< typename OutputIterator >
+	/// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
+	/// optionally returns a statement which must be inserted prior to the containing loop, if there is one
+	template< typename OutputIterator >
 	Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
 	// want to be able to generate assignment, ctor, and dtor generically,
@@ -50,16 +50,15 @@
 	dstParam = new AddressExpr( dstParam );
 	if ( addCast ) {
-	    // cast to T* with qualifiers removed, so that qualified objects can be constructed
-	    // and destructed with the same functions as non-qualified objects.
-	    // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
-	    // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
-	    // remove lvalue as a qualifier, this can change to
-	    //   type->get_qualifiers() = Type::Qualifiers();
-	    assert( type );
-	    Type * castType = type->clone();
-//			castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
-	    castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
-	    castType->set_lvalue( true ); // xxx - might not need this
-	    dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
+		// cast to T* with qualifiers removed, so that qualified objects can be constructed
+		// and destructed with the same functions as non-qualified objects.
+		// unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
+		// must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
+		// remove lvalue as a qualifier, this can change to
+		//   type->get_qualifiers() = Type::Qualifiers();
+		assert( type );
+		Type * castType = type->clone();
+		castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
+		castType->set_lvalue( true ); // xxx - might not need this
+		dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
 	}
 	fExpr->get_args().push_back( dstParam );
@@ -75,103 +74,103 @@
 
 	return listInit;
-    }
-
-    /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
-    /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
-    template< typename OutputIterator >
-	void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
-	static UniqueName indexName( "_index" );
-
-	// for a flexible array member nothing is done -- user must define own assignment
-	if ( ! array->get_dimension() ) return ;
-
-	Expression * begin, * end, * update, * cmp;
-	if ( forward ) {
-	    // generate: for ( int i = 0; i < N; ++i )
-	    begin = new ConstantExpr( Constant::from_int( 0 ) );
-	    end = array->get_dimension()->clone();
-	    cmp = new NameExpr( "?<?" );
-	    update = new NameExpr( "++?" );
-	} else {
-	    // generate: for ( int i = N-1; i >= 0; --i )
-	    begin = new UntypedExpr( new NameExpr( "?-?" ) );
-	    ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
-	    ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant::from_int( 1 ) ) );
-	    end = new ConstantExpr( Constant::from_int( 0 ) );
-	    cmp = new NameExpr( "?>=?" );
-	    update = new NameExpr( "--?" );
 	}
 
-	ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
+	/// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
+	/// If forward is true, loop goes from 0 to N-1, else N-1 to 0
+	template< typename OutputIterator >
+	void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
+		static UniqueName indexName( "_index" );
 
-	UntypedExpr *cond = new UntypedExpr( cmp );
-	cond->get_args().push_back( new VariableExpr( index ) );
-	cond->get_args().push_back( end );
+		// for a flexible array member nothing is done -- user must define own assignment
+		if ( ! array->get_dimension() ) return ;
 
-	UntypedExpr *inc = new UntypedExpr( update );
-	inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
+		Expression * begin, * end, * update, * cmp;
+		if ( forward ) {
+			// generate: for ( int i = 0; i < N; ++i )
+			begin = new ConstantExpr( Constant::from_int( 0 ) );
+			end = array->get_dimension()->clone();
+			cmp = new NameExpr( "?<?" );
+			update = new NameExpr( "++?" );
+		} else {
+			// generate: for ( int i = N-1; i >= 0; --i )
+			begin = new UntypedExpr( new NameExpr( "?-?" ) );
+			((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
+			((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant::from_int( 1 ) ) );
+			end = new ConstantExpr( Constant::from_int( 0 ) );
+			cmp = new NameExpr( "?>=?" );
+			update = new NameExpr( "--?" );
+		}
 
-	UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
-	dstIndex->get_args().push_back( dstParam );
-	dstIndex->get_args().push_back( new VariableExpr( index ) );
-	dstParam = dstIndex;
+		ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin ) );
 
-	// srcParam must keep track of the array indices to build the
-	// source parameter and/or array list initializer
-	srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
+		UntypedExpr *cond = new UntypedExpr( cmp );
+		cond->get_args().push_back( new VariableExpr( index ) );
+		cond->get_args().push_back( end );
 
-	// for stmt's body, eventually containing call
-	CompoundStmt * body = new CompoundStmt( noLabels );
-	Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
+		UntypedExpr *inc = new UntypedExpr( update );
+		inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
 
-	// block containing for stmt and index variable
-	std::list<Statement *> initList;
-	CompoundStmt * block = new CompoundStmt( noLabels );
-	block->get_kids().push_back( new DeclStmt( noLabels, index ) );
-	if ( listInit ) block->get_kids().push_back( listInit );
-	block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
+		UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
+		dstIndex->get_args().push_back( dstParam );
+		dstIndex->get_args().push_back( new VariableExpr( index ) );
+		dstParam = dstIndex;
 
-	*out++ = block;
-    }
+		// srcParam must keep track of the array indices to build the
+		// source parameter and/or array list initializer
+		srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
 
-    template< typename OutputIterator >
+		// for stmt's body, eventually containing call
+		CompoundStmt * body = new CompoundStmt( noLabels );
+		Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
+
+		// block containing for stmt and index variable
+		std::list<Statement *> initList;
+		CompoundStmt * block = new CompoundStmt( noLabels );
+		block->get_kids().push_back( new DeclStmt( noLabels, index ) );
+		if ( listInit ) block->get_kids().push_back( listInit );
+		block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
+
+		*out++ = block;
+	}
+
+	template< typename OutputIterator >
 	Statement * genCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
-	if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
-	    genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
-	    return 0;
-	} else {
-	    return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
+		if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
+			genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
+			return 0;
+		} else {
+			return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
+		}
 	}
-    }
 
-    /// inserts into out a generated call expression to function fname with arguments dstParam
-    /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
-    /// object being constructed. The function wraps constructor and destructor calls in an
-    /// ImplicitCtorDtorStmt node.
-    template< typename OutputIterator >
+	/// inserts into out a generated call expression to function fname with arguments dstParam
+	/// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
+	/// object being constructed. The function wraps constructor and destructor calls in an
+	/// ImplicitCtorDtorStmt node.
+	template< typename OutputIterator >
 	void genImplicitCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) {
-	ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
-	assert( obj );
-	// unnamed bit fields are not copied as they cannot be accessed
-	if ( isUnnamedBitfield( obj ) ) return;
+		ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
+		assert( obj );
+		// unnamed bit fields are not copied as they cannot be accessed
+		if ( isUnnamedBitfield( obj ) ) return;
 
-	bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
-	std::list< Statement * > stmts;
-	genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
+		bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
+		std::list< Statement * > stmts;
+		genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
 
-	// currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
-	assert( stmts.size() <= 1 );
-	if ( stmts.size() == 1 ) {
-	    Statement * callStmt = stmts.front();
-	    if ( addCast ) {
-		// implicitly generated ctor/dtor calls should be wrapped
-		// so that later passes are aware they were generated.
-		// xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
-		// because this causes the address to be taken at codegen, which is illegal in C.
-		callStmt = new ImplicitCtorDtorStmt( callStmt );
-	    }
-	    *out++ = callStmt;
+		// currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
+		assert( stmts.size() <= 1 );
+		if ( stmts.size() == 1 ) {
+			Statement * callStmt = stmts.front();
+			if ( addCast ) {
+				// implicitly generated ctor/dtor calls should be wrapped
+				// so that later passes are aware they were generated.
+				// xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
+				// because this causes the address to be taken at codegen, which is illegal in C.
+				callStmt = new ImplicitCtorDtorStmt( callStmt );
+			}
+			*out++ = callStmt;
+		}
 	}
-    }
 } // namespace SymTab
 #endif // AUTOGEN_H
Index: src/SynTree/Expression.cc
===================================================================
--- src/SynTree/Expression.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Expression.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -92,5 +92,4 @@
 
 	Declaration *decl = get_var();
-	// if ( decl != 0) decl->print(os, indent + 2);
 	if ( decl != 0) decl->printShort(os, indent + 2);
 	os << std::endl;
@@ -657,4 +656,46 @@
 }
 
+InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
+InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
+InitAlternative::~InitAlternative() {
+	delete type;
+	delete designation;
+}
+
+UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
+UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
+UntypedInitExpr::~UntypedInitExpr() {
+	delete expr;
+}
+
+void UntypedInitExpr::print( std::ostream & os, int indent ) const {
+	os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );
+	expr->print( os, indent+2 );
+	if ( ! initAlts.empty() ) {
+		for ( const InitAlternative & alt : initAlts ) {
+			os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
+			alt.type->print( os, indent+2 );
+			alt.designation->print( os, indent+2 );
+		}
+	}
+}
+
+InitExpr::InitExpr( Expression * expr, Type * type, Designation * designation ) : expr( expr ), designation( designation ) {
+	set_result( type );
+}
+InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
+InitExpr::~InitExpr() {
+	delete expr;
+	delete designation;
+}
+
+void InitExpr::print( std::ostream & os, int indent ) const {
+	os << "Init Expression" << std::endl << std::string( indent+2, ' ' );
+	expr->print( os, indent+2 );
+	os << std::string( indent+2, ' ' ) << "with designation: ";
+	designation->print( os, indent+2 );
+}
+
+
 std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
 	if ( expr ) {
Index: src/SynTree/Expression.h
===================================================================
--- src/SynTree/Expression.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Expression.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -744,4 +744,56 @@
 };
 
+struct InitAlternative {
+public:
+	Type * type = nullptr;
+	Designation * designation = nullptr;
+	InitAlternative( Type * type, Designation * designation );
+	InitAlternative( const InitAlternative & other );
+	InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
+	~InitAlternative();
+};
+
+class UntypedInitExpr : public Expression {
+public:
+	UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
+	UntypedInitExpr( const UntypedInitExpr & other );
+	~UntypedInitExpr();
+
+	Expression * get_expr() const { return expr; }
+	UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
+
+	std::list<InitAlternative> & get_initAlts() { return initAlts; }
+
+	virtual UntypedInitExpr * clone() const { return new UntypedInitExpr( * this ); }
+	virtual void accept( Visitor & v ) { v.visit( this ); }
+	virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
+	virtual void print( std::ostream & os, int indent = 0 ) const;
+private:
+	Expression * expr;
+	std::list<InitAlternative> initAlts;
+};
+
+class InitExpr : public Expression {
+public:
+	InitExpr( Expression * expr, Type * type, Designation * designation );
+	InitExpr( const InitExpr & other );
+	~InitExpr();
+
+	Expression * get_expr() const { return expr; }
+	InitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
+
+	Designation * get_designation() const { return designation; }
+	InitExpr * set_designation( Designation * newValue ) { designation = newValue; return this; }
+
+	virtual InitExpr * clone() const { return new InitExpr( * this ); }
+	virtual void accept( Visitor & v ) { v.visit( this ); }
+	virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
+	virtual void print( std::ostream & os, int indent = 0 ) const;
+private:
+	Expression * expr;
+	Designation * designation;
+};
+
+
 std::ostream & operator<<( std::ostream & out, const Expression * expr );
 
Index: src/SynTree/Initializer.cc
===================================================================
--- src/SynTree/Initializer.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Initializer.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -19,75 +19,74 @@
 #include "Common/utility.h"
 
+Designation::Designation( const std::list< Expression * > & designators ) : designators( designators ) {}
+Designation::Designation( const Designation & other ) : BaseSyntaxNode( other ) {
+	// std::cerr << "cloning designation" << std::endl;
+	cloneAll( other.designators, designators );
+	// std::cerr << "finished cloning designation" << std::endl;
+}
+
+Designation::~Designation() {
+	// std::cerr << "destroying designation" << std::endl;
+	deleteAll( designators );
+	// std::cerr << "finished destroying designation" << std::endl;
+}
+
+void Designation::print( std::ostream &os, int indent ) const {
+	if ( ! designators.empty() ) {
+		os << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;
+		for ( std::list < Expression * >::const_iterator i = designators.begin(); i != designators.end(); i++ ) {
+			os << std::string(indent + 4, ' ' );
+			( *i )->print(os, indent + 4 );
+		}
+		os << std::endl;
+	} // if
+}
+
 Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
 Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ), maybeConstructed( other.maybeConstructed ) {
 }
-
-
 Initializer::~Initializer() {}
 
-std::string Initializer::designator_name( Expression *des ) {
-	if ( NameExpr *n = dynamic_cast<NameExpr *>(des) )
-		return n->get_name();
-	else
-		throw 0;
-}
-
-// void Initializer::print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent ) {}
-
-SingleInit::SingleInit( Expression *v, const std::list< Expression *> &_designators, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ), designators( _designators ) {
+SingleInit::SingleInit( Expression *v, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ) {
 }
 
 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) {
-	cloneAll(other.designators, designators );
 }
 
 SingleInit::~SingleInit() {
 	delete value;
-	deleteAll(designators);
 }
 
-void SingleInit::print( std::ostream &os, int indent ) {
-	os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
+void SingleInit::print( std::ostream &os, int indent ) const {
+	os << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
 	os << std::string(indent+4, ' ' );
 	value->print( os, indent+4 );
-
-	if ( ! designators.empty() ) {
-		os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;
-		for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) {
-			os << std::string(indent + 4, ' ' );
-			( *i )->print(os, indent + 4 );
-		}
-	} // if
 }
 
-ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed )
-	: Initializer( maybeConstructed ), initializers( _initializers ), designators( _designators ) {
+
+ListInit::ListInit( const std::list<Initializer*> &initializers, const std::list<Designation *> &designations, bool maybeConstructed )
+	: Initializer( maybeConstructed ), initializers( initializers ), designations( designations ) {
 }
 
 ListInit::ListInit( const ListInit & other ) : Initializer( other ) {
 	cloneAll( other.initializers, initializers );
-	cloneAll( other.designators, designators );
+	cloneAll( other.designations, designations );
 }
-
 
 ListInit::~ListInit() {
 	deleteAll( initializers );
-	deleteAll( designators );
+	deleteAll( designations );
 }
 
-void ListInit::print( std::ostream &os, int indent ) {
-	os << std::endl << std::string(indent, ' ') << "Compound initializer:  ";
-	if ( ! designators.empty() ) {
-		os << std::string(indent + 2, ' ' ) << "designated by: [";
-		for ( std::list < Expression * >::iterator i = designators.begin();
-			  i != designators.end(); i++ ) {
-			( *i )->print(os, indent + 4 );
-		} // for
+void ListInit::print( std::ostream &os, int indent ) const {
+	os << std::string(indent, ' ') << "Compound initializer:  " << std::endl;
+	for ( Designation * d : designations ) {
+		d->print( os, indent + 2 );
+	}
 
-		os << std::string(indent + 2, ' ' ) << "]";
-	} // if
-
-	for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ )
-		(*i)->print( os, indent + 2 );
+	for ( const Initializer * init : initializers ) {
+		init->print( os, indent + 2 );
+		os << std::endl;
+	}
 }
 
@@ -103,5 +102,5 @@
 }
 
-void ConstructorInit::print( std::ostream &os, int indent ) {
+void ConstructorInit::print( std::ostream &os, int indent ) const {
 	os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl;
 	if ( ctor ) {
@@ -124,6 +123,19 @@
 }
 
-std::ostream & operator<<( std::ostream & out, Initializer * init ) {
-	init->print( out );
+std::ostream & operator<<( std::ostream & out, const Initializer * init ) {
+	if ( init ) {
+		init->print( out );
+	} else {
+		out << "nullptr";
+	}
+	return out;
+}
+
+std::ostream & operator<<( std::ostream & out, const Designation * des ) {
+	if ( des ) {
+		des->print( out );
+	} else {
+		out << "nullptr";
+	}
 	return out;
 }
Index: src/SynTree/Initializer.h
===================================================================
--- src/SynTree/Initializer.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Initializer.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -25,26 +25,29 @@
 #include "Visitor.h"
 
-const std::list<Expression*> noDesignators;
+// Designation: list of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an object being initialized.
+class Designation : public BaseSyntaxNode {
+public:
+	Designation( const std::list< Expression * > & designators );
+	Designation( const Designation & other );
+	virtual ~Designation();
+
+	std::list< Expression * > & get_designators() { return designators; }
+
+	virtual Designation * clone() const { return new Designation( *this ); };
+	virtual void accept( Visitor &v ) { v.visit( this ); }
+	virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
+	virtual void print( std::ostream &os, int indent = 0 ) const;
+private:
+	std::list< Expression * > designators;
+};
+
+const std::list<Designation *> noDesignators;
 
 // Initializer: base class for object initializers (provide default values)
 class Initializer : public BaseSyntaxNode {
   public:
-	//	Initializer( std::string _name = std::string(""), int _pos = 0 );
 	Initializer( bool maybeConstructed );
 	Initializer( const Initializer & other );
 	virtual ~Initializer();
-
-	static std::string designator_name( Expression *designator );
-
-	//	void set_name( std::string newValue ) { name = newValue; }
-	//	std::string get_name() const { return name; }
-
-	//	void set_pos( int newValue ) { pos = newValue; }
-	//	int get_pos() const { return pos; }
-	virtual void set_designators( std::list<Expression *> & ) { assert(false); }
-	virtual std::list<Expression *> &get_designators() {
-		assert(false);
-		std::list<Expression *> *ret = 0; return *ret;	// never reached
-	}
 
 	bool get_maybeConstructed() { return maybeConstructed; }
@@ -53,8 +56,6 @@
 	virtual void accept( Visitor &v ) = 0;
 	virtual Initializer *acceptMutator( Mutator &m ) = 0;
-	virtual void print( std::ostream &os, int indent = 0 ) = 0;
+	virtual void print( std::ostream &os, int indent = 0 ) const = 0;
   private:
-	//	std::string name;
-	//	int pos;
 	bool maybeConstructed;
 };
@@ -63,5 +64,5 @@
 class SingleInit : public Initializer {
   public:
-	SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
+	SingleInit( Expression *value, bool maybeConstructed = false );
 	SingleInit( const SingleInit &other );
 	virtual ~SingleInit();
@@ -70,15 +71,11 @@
 	void set_value( Expression *newValue ) { value = newValue; }
 
-	std::list<Expression *> &get_designators() { return designators; }
-	void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
-
 	virtual SingleInit *clone() const { return new SingleInit( *this); }
 	virtual void accept( Visitor &v ) { v.visit( this ); }
 	virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
-	virtual void print( std::ostream &os, int indent = 0 );
+	virtual void print( std::ostream &os, int indent = 0 ) const;
   private:
 	//Constant *value;
 	Expression *value;	// has to be a compile-time constant
-	std::list< Expression * > designators;
 };
 
@@ -88,24 +85,25 @@
   public:
 	ListInit( const std::list<Initializer*> &initializers,
-			  const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
+			  const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
 	ListInit( const ListInit & other );
 	virtual ~ListInit();
 
-	void set_designators( std::list<Expression *> &newValue ) { designators = newValue; }
-	std::list<Expression *> &get_designators() { return designators; }
-	void set_initializers( std::list<Initializer*> &newValue ) { initializers = newValue; }
-	std::list<Initializer*> &get_initializers() { return initializers; }
+	std::list<Designation *> & get_designations() { return designations; }
+	std::list<Initializer *> & get_initializers() { return initializers; }
 
 	typedef std::list<Initializer*>::iterator iterator;
+	typedef std::list<Initializer*>::const_iterator const_iterator;
 	iterator begin() { return initializers.begin(); }
 	iterator end() { return initializers.end(); }
+	const_iterator begin() const { return initializers.begin(); }
+	const_iterator end() const { return initializers.end(); }
 
 	virtual ListInit *clone() const { return new ListInit( *this ); }
 	virtual void accept( Visitor &v ) { v.visit( this ); }
 	virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
-	virtual void print( std::ostream &os, int indent = 0 );
+	virtual void print( std::ostream &os, int indent = 0 ) const;
   private:
-	std::list<Initializer*> initializers;  // order *is* important
-	std::list<Expression *> designators;
+	std::list<Initializer *> initializers;  // order *is* important
+	std::list<Designation *> designations;  // order/length is consistent with initializers
 };
 
@@ -130,5 +128,5 @@
 	virtual void accept( Visitor &v ) { v.visit( this ); }
 	virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
-	virtual void print( std::ostream &os, int indent = 0 );
+	virtual void print( std::ostream &os, int indent = 0 ) const;
 
   private:
@@ -140,5 +138,6 @@
 };
 
-std::ostream & operator<<( std::ostream & out, Initializer * init );
+std::ostream & operator<<( std::ostream & out, const Initializer * init );
+std::ostream & operator<<( std::ostream & out, const Designation * des );
 
 #endif // INITIALIZER_H
Index: src/SynTree/Mutator.cc
===================================================================
--- src/SynTree/Mutator.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Mutator.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -433,4 +433,20 @@
 }
 
+Expression *Mutator::mutate( UntypedInitExpr * initExpr ) {
+	initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
+	initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
+	initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
+	// not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
+	return initExpr;
+}
+
+Expression *Mutator::mutate( InitExpr * initExpr ) {
+	initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
+	initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
+	initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
+	initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
+	return initExpr;
+}
+
 
 Type *Mutator::mutate( VoidType *voidType ) {
@@ -535,4 +551,9 @@
 
 
+Designation *Mutator::mutate( Designation * designation ) {
+	mutateAll( designation->get_designators(), *this );
+	return designation;
+}
+
 Initializer *Mutator::mutate( SingleInit *singleInit ) {
 	singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
@@ -541,5 +562,5 @@
 
 Initializer *Mutator::mutate( ListInit *listInit ) {
-	mutateAll( listInit->get_designators(), *this );
+	mutateAll( listInit->get_designations(), *this );
 	mutateAll( listInit->get_initializers(), *this );
 	return listInit;
Index: src/SynTree/Mutator.h
===================================================================
--- src/SynTree/Mutator.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Mutator.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -85,4 +85,6 @@
 	virtual Expression* mutate( StmtExpr * stmtExpr );
 	virtual Expression* mutate( UniqueExpr * uniqueExpr );
+	virtual Expression* mutate( UntypedInitExpr * initExpr );
+	virtual Expression* mutate( InitExpr * initExpr );
 
 	virtual Type* mutate( VoidType *basicType );
@@ -103,4 +105,5 @@
 	virtual Type* mutate( OneType *oneType );
 
+	virtual Designation* mutate( Designation *designation );
 	virtual Initializer* mutate( SingleInit *singleInit );
 	virtual Initializer* mutate( ListInit *listInit );
Index: src/SynTree/SynTree.h
===================================================================
--- src/SynTree/SynTree.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/SynTree.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -93,4 +93,6 @@
 class StmtExpr;
 class UniqueExpr;
+class UntypedInitExpr;
+class InitExpr;
 
 class Type;
@@ -113,4 +115,5 @@
 class OneType;
 
+class Designation;
 class Initializer;
 class SingleInit;
Index: src/SynTree/Visitor.cc
===================================================================
--- src/SynTree/Visitor.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Visitor.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -340,4 +340,16 @@
 }
 
+void Visitor::visit( UntypedInitExpr * initExpr ) {
+	maybeAccept( initExpr->get_result(), *this );
+	maybeAccept( initExpr->get_expr(), *this );
+	// not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
+}
+
+void Visitor::visit( InitExpr * initExpr ) {
+	maybeAccept( initExpr->get_result(), *this );
+	maybeAccept( initExpr->get_expr(), *this );
+	maybeAccept( initExpr->get_designation(), *this );
+}
+
 
 void Visitor::visit( VoidType *voidType ) {
@@ -424,4 +436,7 @@
 }
 
+void Visitor::visit( Designation * designation ) {
+	acceptAll( designation->get_designators(), *this );
+}
 
 void Visitor::visit( SingleInit *singleInit ) {
@@ -430,5 +445,5 @@
 
 void Visitor::visit( ListInit *listInit ) {
-	acceptAll( listInit->get_designators(), *this );
+	acceptAll( listInit->get_designations(), *this );
 	acceptAll( listInit->get_initializers(), *this );
 }
Index: src/SynTree/Visitor.h
===================================================================
--- src/SynTree/Visitor.h	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/SynTree/Visitor.h	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -88,4 +88,6 @@
 	virtual void visit( StmtExpr * stmtExpr );
 	virtual void visit( UniqueExpr * uniqueExpr );
+	virtual void visit( UntypedInitExpr * initExpr );
+	virtual void visit( InitExpr * initExpr );
 
 	virtual void visit( VoidType *basicType );
@@ -106,4 +108,5 @@
 	virtual void visit( OneType *oneType );
 
+	virtual void visit( Designation *designation );
 	virtual void visit( SingleInit *singleInit );
 	virtual void visit( ListInit *listInit );
Index: src/Tuples/TupleExpansion.cc
===================================================================
--- src/Tuples/TupleExpansion.cc	(revision 2a7b3ca400fe85559a7ebbd5d3b09859d5dfc4da)
+++ src/Tuples/TupleExpansion.cc	(revision 579263a52ab065d42a5208e15e3d707dd0d03798)
@@ -192,5 +192,5 @@
 			}
 			ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ),
-													new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ), noDesignators ) );
+													new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ) ) );
 			addDeclaration( finished );
 			// (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N))
