Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/CodeGenerator.cc	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -89,5 +89,5 @@
 	}
 
-	CodeGenerator::CodeGenerator( std::ostream & os, bool pretty ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ) {}
+	CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ) {}
 
 	CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )
@@ -136,5 +136,5 @@
 		functionDecl->get_funcSpec().print( output );
 
-		output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty );
+		output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty, genC );
 
 		asmName( functionDecl );
@@ -147,5 +147,6 @@
 
 	void CodeGenerator::visit( ObjectDecl * objectDecl ) {
-		if (objectDecl->get_name().empty()) {
+		if (objectDecl->get_name().empty() && genC ) {
+			// only generate an anonymous name when generating C code, otherwise it clutters the output too much
 			static UniqueName name = { "__anonymous_object" };
 			objectDecl->set_name( name.newName() );
@@ -156,5 +157,5 @@
 
 		handleStorageClass( objectDecl );
-		output << genType( objectDecl->get_type(), mangleName( objectDecl ), pretty );
+		output << genType( objectDecl->get_type(), mangleName( objectDecl ), pretty, genC );
 
 		asmName( objectDecl );
@@ -171,12 +172,18 @@
 	}
 
-	void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {
+	void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) {
 		genAttributes( aggDecl->get_attributes() );
 
+		if( ! aggDecl->get_parameters().empty() && ! genC ) {
+			// assertf( ! genC, "Aggregate type parameters should not reach code generation." );
+			output << "forall(";
+			genCommaList( aggDecl->get_parameters().begin(), aggDecl->get_parameters().end() );
+			output << ")" << endl;
+		}
+
+		output << kind;
 		if ( aggDecl->get_name() != "" )
 			output << aggDecl->get_name();
 
-		// std::list< Declaration * > & memb = aggDecl->get_members();
-		// if ( ! memb.empty() ) {
 		if ( aggDecl->has_body() ) {
 			std::list< Declaration * > & memb = aggDecl->get_members();
@@ -198,12 +205,10 @@
 	void CodeGenerator::visit( StructDecl * structDecl ) {
 		extension( structDecl );
-		output << "struct ";
-		handleAggregate( structDecl );
+		handleAggregate( structDecl, "struct " );
 	}
 
 	void CodeGenerator::visit( UnionDecl * unionDecl ) {
 		extension( unionDecl );
-		output << "union ";
-		handleAggregate( unionDecl );
+		handleAggregate( unionDecl, "union " );
 	}
 
@@ -242,17 +247,26 @@
 
 	void CodeGenerator::visit( TypedefDecl * typeDecl ) {
-		assert( false && "Typedefs are removed and substituted in earlier passes." );
-		//output << "typedef ";
-		//output << genType( typeDecl->get_base(), typeDecl->get_name(), pretty );
+		assertf( ! genC, "Typedefs are removed and substituted in earlier passes." );
+		output << "typedef ";
+		output << genType( typeDecl->get_base(), typeDecl->get_name(), pretty, genC ) << endl;
 	}
 
 	void CodeGenerator::visit( TypeDecl * typeDecl ) {
-		// really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
-		// still to be done
-		extension( typeDecl );
-		output << "extern unsigned long " << typeDecl->get_name();
-		if ( typeDecl->get_base() ) {
-			output << " = sizeof( " << genType( typeDecl->get_base(), "", pretty ) << " )";
-		} // if
+		if ( genC ) {
+			// really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
+			// still to be done
+			extension( typeDecl );
+			output << "extern unsigned long " << typeDecl->get_name();
+			if ( typeDecl->get_base() ) {
+				output << " = sizeof( " << genType( typeDecl->get_base(), "", pretty, genC ) << " )";
+			} // if
+		} else {
+			output << typeDecl->typeString() << " " << typeDecl->get_name();
+			if ( ! typeDecl->get_assertions().empty() ) {
+				output << " | { ";
+				genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() );
+				output << " }";
+			}
+		}
 	}
 
@@ -293,5 +307,7 @@
 
 	void CodeGenerator::visit( ConstructorInit * init ){
-		assertf( false, "ConstructorInit nodes should not make it to CodeGen." );
+		assertf( ! genC, "ConstructorInit nodes should not reach code generation." );
+		// xxx - generate something reasonable for constructor/destructor pairs
+		output << "<ctorinit>";
 	}
 
@@ -547,5 +563,5 @@
 			// at least one result type of cast, but not an lvalue
 			output << "(";
-			output << genType( castExpr->get_result(), "", pretty );
+			output << genType( castExpr->get_result(), "", pretty, genC );
 			output << ")";
 		} else {
@@ -558,5 +574,9 @@
 
 	void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {
-		assert( false );
+		assertf( ! genC, "UntypedMemberExpr should not reach code generation." );
+		extension( memberExpr );
+		memberExpr->get_aggregate()->accept( *this );
+		output << ".";
+		memberExpr->get_member()->accept( *this );
 	}
 
@@ -587,5 +607,5 @@
 		output << "sizeof(";
 		if ( sizeofExpr->get_isType() ) {
-			output << genType( sizeofExpr->get_type(), "", pretty );
+			output << genType( sizeofExpr->get_type(), "", pretty, genC );
 		} else {
 			sizeofExpr->get_expr()->accept( *this );
@@ -599,5 +619,5 @@
 		output << "__alignof__(";
 		if ( alignofExpr->get_isType() ) {
-			output << genType( alignofExpr->get_type(), "", pretty );
+			output << genType( alignofExpr->get_type(), "", pretty, genC );
 		} else {
 			alignofExpr->get_expr()->accept( *this );
@@ -607,5 +627,9 @@
 
 	void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {
-		assert( false && "UntypedOffsetofExpr should not reach code generation." );
+		assertf( ! genC, "UntypedOffsetofExpr should not reach code generation." );
+		output << "offsetof(";
+		output << genType( offsetofExpr->get_type(), "", pretty, genC );
+		output << ", " << offsetofExpr->get_member();
+		output << ")";
 	}
 
@@ -613,5 +637,5 @@
 		// use GCC builtin
 		output << "__builtin_offsetof(";
-		output << genType( offsetofExpr->get_type(), "", pretty );
+		output << genType( offsetofExpr->get_type(), "", pretty, genC );
 		output << ", " << mangleName( offsetofExpr->get_member() );
 		output << ")";
@@ -619,5 +643,6 @@
 
 	void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {
-		assert( false && "OffsetPackExpr should not reach code generation." );
+		assertf( ! genC, "OffsetPackExpr should not reach code generation." );
+		output << "__CFA_offsetpack(" << genType( offsetPackExpr->get_type(), "", pretty, genC ) << ")";
 	}
 
@@ -655,9 +680,22 @@
 	}
 
-	void CodeGenerator::visit( UntypedTupleExpr * tupleExpr ) { assertf( false, "UntypedTupleExpr should not make it to Code Gen" ); }
-
-	void CodeGenerator::visit( TupleExpr * tupleExpr ) { assertf( false, "TupleExpr should not make it to Code Gen" ); }
-
-	void CodeGenerator::visit( TypeExpr * typeExpr ) {}
+	void CodeGenerator::visit( UntypedTupleExpr * tupleExpr ) {
+		assertf( ! genC, "UntypedTupleExpr should not reach code generation." );
+		output << "[";
+		genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() );
+		output << "]";
+	}
+
+	void CodeGenerator::visit( TupleExpr * tupleExpr ) {
+		assertf( ! genC, "TupleExpr should not reach code generation." );
+		output << "[";
+		genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() );
+		output << "]";
+	}
+
+	void CodeGenerator::visit( TypeExpr * typeExpr ) {
+		assertf( ! genC, "TypeExpr should not reach code generation." );
+		output<< genType( typeExpr->get_type(), "", pretty, genC );
+	}
 
 	void CodeGenerator::visit( AsmExpr * asmExpr ) {
@@ -675,5 +713,5 @@
 	void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) {
 		assert( compLitExpr->get_result() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
-		output << "(" << genType( compLitExpr->get_result(), "", pretty ) << ")";
+		output << "(" << genType( compLitExpr->get_result(), "", pretty, genC ) << ")";
 		compLitExpr->get_initializer()->accept( *this );
 	}
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/CodeGenerator.h	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -30,5 +30,5 @@
 		static int tabsize;
 
-		CodeGenerator( std::ostream &os, bool pretty = false );
+		CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false );
 		CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false );
 		CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false );
@@ -121,8 +121,9 @@
 		LabelPrinter printLabels;
 		bool pretty = false;  // pretty print
+		bool genC = false;    // true if output has to be C code
 
 		void printDesignators( std::list< Expression * > & );
 		void handleStorageClass( DeclarationWithType *decl );
-		void handleAggregate( AggregateDecl *aggDecl );
+		void handleAggregate( AggregateDecl *aggDecl, const std::string & kind );
 		void handleTypedef( NamedTypeDecl *namedType );
 		std::string mangleName( DeclarationWithType * decl );
Index: src/CodeGen/GenType.cc
===================================================================
--- src/CodeGen/GenType.cc	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/GenType.cc	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -28,5 +28,5 @@
 	class GenType : public Visitor {
 	  public:
-		GenType( const std::string &typeString, bool pretty = false );
+		GenType( const std::string &typeString, bool pretty = false, bool genC = false );
 		std::string get_typeString() const { return typeString; }
 		void set_typeString( const std::string &newValue ) { typeString = newValue; }
@@ -48,16 +48,18 @@
 	  private:
 		void handleQualifiers( Type *type );
+		std::string handleGeneric( ReferenceToType * refType );
 		void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
 
 		std::string typeString;
 		bool pretty = false; // pretty print
+		bool genC = false;   // generating C code?
 	};
 
-	std::string genType( Type *type, const std::string &baseString, bool pretty ) {
-		GenType gt( baseString, pretty );
+	std::string genType( Type *type, const std::string &baseString, bool pretty, bool genC ) {
+		GenType gt( baseString, pretty, genC );
 		std::ostringstream os;
 
 		if ( ! type->get_attributes().empty() ) {
-			CodeGenerator cg( os, pretty );
+			CodeGenerator cg( os, pretty, genC );
 			cg.genAttributes( type->get_attributes() );
 		} // if
@@ -68,8 +70,8 @@
 
   std::string genPrettyType( Type * type, const std::string & baseString ) {
-  	return genType( type, baseString, true );
+  	return genType( type, baseString, true, false );
   }
 
-	GenType::GenType( const std::string &typeString, bool pretty ) : typeString( typeString ), pretty( pretty ) {}
+	GenType::GenType( const std::string &typeString, bool pretty, bool genC ) : typeString( typeString ), pretty( pretty ), genC( genC ) {}
 
 	void GenType::visit( VoidType *voidType ) {
@@ -112,5 +114,5 @@
 		} // if
 		if ( dimension != 0 ) {
-			CodeGenerator cg( os, pretty );
+			CodeGenerator cg( os, pretty, genC );
 			dimension->accept( cg );
 		} else if ( isVarLen ) {
@@ -166,5 +168,5 @@
 			} // if
 		} else {
-			CodeGenerator cg( os, pretty );
+			CodeGenerator cg( os, pretty, genC );
 			os << "(" ;
 
@@ -184,18 +186,44 @@
 			funcType->get_returnVals().front()->get_type()->accept( *this );
 		} // if
+
+		// add forall
+		if( ! funcType->get_forall().empty() && ! genC ) {
+			// assertf( ! genC, "Aggregate type parameters should not reach code generation." );
+			std::ostringstream os;
+			CodeGenerator cg( os, pretty, genC );
+			os << "forall(";
+			cg.genCommaList( funcType->get_forall().begin(), funcType->get_forall().end() );
+			os << ")" << std::endl;
+			typeString = os.str() + typeString;
+		}
+	}
+
+	std::string GenType::handleGeneric( ReferenceToType * refType ) {
+		if ( ! refType->get_parameters().empty() ) {
+			std::ostringstream os;
+			CodeGenerator cg( os, pretty, genC );
+			os << "(";
+			cg.genCommaList( refType->get_parameters().begin(), refType->get_parameters().end() );
+			os << ") ";
+			return os.str();
+		}
+		return "";
 	}
 
 	void GenType::visit( StructInstType *structInst )  {
-		typeString = "struct " + structInst->get_name() + " " + typeString;
+		typeString = structInst->get_name() + handleGeneric( structInst ) + " " + typeString;
+		if ( genC ) typeString = "struct " + typeString;
 		handleQualifiers( structInst );
 	}
 
 	void GenType::visit( UnionInstType *unionInst ) {
-		typeString = "union " + unionInst->get_name() + " " + typeString;
+		typeString = unionInst->get_name() + handleGeneric( unionInst ) + " " + typeString;
+		if ( genC ) typeString = "union " + typeString;
 		handleQualifiers( unionInst );
 	}
 
 	void GenType::visit( EnumInstType *enumInst ) {
-		typeString = "enum " + enumInst->get_name() + " " + typeString;
+		typeString = enumInst->get_name() + " " + typeString;
+		if ( genC ) typeString = "enum " + typeString;
 		handleQualifiers( enumInst );
 	}
@@ -207,5 +235,5 @@
 
 	void GenType::visit( TupleType * tupleType ) {
-		assertf( pretty, "Tuple types should not make it to Code Gen." );
+		assertf( ! genC, "Tuple types should not reach code generation." );
 		Visitor::visit( tupleType );
 		unsigned int i = 0;
@@ -214,5 +242,5 @@
 		for ( Type * t : *tupleType ) {
 			i++;
-			os << genType( t, "", pretty ) << (i == tupleType->size() ? "" : ", ");
+			os << genType( t, "", pretty, genC ) << (i == tupleType->size() ? "" : ", ");
 		}
 		os << "]";
Index: src/CodeGen/GenType.h
===================================================================
--- src/CodeGen/GenType.h	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/GenType.h	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -21,5 +21,5 @@
 
 namespace CodeGen {
-	std::string genType( Type *type, const std::string &baseString, bool pretty = false );
+	std::string genType( Type *type, const std::string &baseString, bool pretty = false, bool genC = false );
   std::string genPrettyType( Type * type, const std::string & baseString );
 } // namespace CodeGen
Index: src/CodeGen/Generate.cc
===================================================================
--- src/CodeGen/Generate.cc	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/Generate.cc	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -27,6 +27,6 @@
 
 namespace CodeGen {
-	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty ) {
-		CodeGen::CodeGenerator cgv( os, pretty );
+	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC ) {
+		CodeGen::CodeGenerator cgv( os, pretty, generateC );
 		for ( auto & dcl : translationUnit ) {
 			if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) {
Index: src/CodeGen/Generate.h
===================================================================
--- src/CodeGen/Generate.h	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/CodeGen/Generate.h	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -23,6 +23,6 @@
 
 namespace CodeGen {
-	/// Generates code
-	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty );
+	/// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.)
+	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false );
 } // namespace CodeGen
 
Index: src/SynTree/Declaration.h
===================================================================
--- src/SynTree/Declaration.h	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/SynTree/Declaration.h	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -167,9 +167,10 @@
 	std::list< DeclarationWithType* >& get_assertions() { return assertions; }
 
+	virtual std::string typeString() const = 0;
+
 	virtual NamedTypeDecl *clone() const = 0;
 	virtual void print( std::ostream &os, int indent = 0 ) const;
 	virtual void printShort( std::ostream &os, int indent = 0 ) const;
   protected:
-	virtual std::string typeString() const = 0;
   private:
 	Type *base;
@@ -202,9 +203,10 @@
 	TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
 
+	virtual std::string typeString() const;
+
 	virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
 	virtual void accept( Visitor &v ) { v.visit( this ); }
 	virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
   private:
-	virtual std::string typeString() const;
 	Kind kind;
 	bool sized;
@@ -217,9 +219,10 @@
 	TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
 
+	virtual std::string typeString() const;
+
 	virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
 	virtual void accept( Visitor &v ) { v.visit( this ); }
 	virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
   private:
-	virtual std::string typeString() const;
 };
 
Index: src/main.cc
===================================================================
--- src/main.cc	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/main.cc	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -304,15 +304,9 @@
 		GenPoly::box( translationUnit );
 
-		// print tree right before code generation
-		if ( codegenp ) {
-			dump( translationUnit );
-			return 0;
-		} // if
-
 		if ( optind < argc ) {							// any commands after the flags and input file ? => output file name
 			output = new ofstream( argv[ optind ] );
 		} // if
 
-		CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp );
+		CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true );
 
 		CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
@@ -393,5 +387,5 @@
 			break;
 		  case CtorInitFix:
-		  case 'c':
+		  case 'c':										// print after constructors and destructors are replaced
 			ctorinitp = true;
 			break;
@@ -450,10 +444,11 @@
 			validp = true;
 			break;
-		  case 'y':
+		  case 'y':										// dump AST on error
 			errorp = true;
 			break;
-		  case 'z':
+		  case 'z':										// dump as codegen rather than AST
 			codegenp = true;
-			case 'Z':
+			break;
+			case 'Z':									// prettyprint during codegen (i.e. print unmangled names, etc.)
 			prettycodegenp = true;
 			break;
@@ -501,5 +496,10 @@
 	} // if
 
-	printAll( decls, out );
+	// depending on commandline options, either generate code or dump the AST
+	if ( codegenp ) {
+		CodeGen::generate( decls, out, ! noprotop, prettycodegenp );
+	} else {
+		printAll( decls, out );
+	}
 	deleteAll( translationUnit );
 } // dump
Index: src/tests/.expect/memberCtors-ERR1.txt
===================================================================
--- src/tests/.expect/memberCtors-ERR1.txt	(revision cd348e769c5446a359776ba8650346994d942623)
+++ src/tests/.expect/memberCtors-ERR1.txt	(revision e3987770220cef1b5e4d282cd85dfd96949a113f)
@@ -1,2 +1,2 @@
-memberCtors.c:62 error: in void ?{}(struct B *b), field a2 used before being constructed
+memberCtors.c:62 error: in void ?{}(B *b), field a2 used before being constructed
 make: *** [memberCtors-ERR1] Error 1
