Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 346a0bf2eeb59ac7742dbcb818d4d60e92658178)
+++ src/GenPoly/Box.cc	(revision cc3528fa256fee8ec5d85fea52117f5a7355a2da)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Feb  5 16:45:07 2016
-// Update Count     : 286
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri May 13 13:59:22 2016
+// Update Count     : 295
 //
 
@@ -133,5 +133,5 @@
 			Value *lookup( Key *key, const std::list< TypeExpr* >& params ) const {
  				TypeList typeList( params );
- 				
+
 				// scan scopes for matches to the key
 				for ( typename InnerMap::const_iterator insts = instantiations.find( key ); insts != instantiations.end(); insts = instantiations.findNext( insts, key ) ) {
@@ -160,5 +160,5 @@
 			virtual Declaration *mutate( UnionDecl *unionDecl );
 		};
-		
+
 		/// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call
 		class Pass1 : public PolyMutator {
@@ -208,5 +208,5 @@
 			ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps;  ///< Currently known assignment operators
 			ScopedMap< std::string, DeclarationWithType* > adapters;     ///< Set of adapter functions in the current scope
-			
+
 			DeclarationWithType *retval;
 			bool useRetval;
@@ -226,5 +226,5 @@
 			virtual Type *mutate( PointerType *pointerType );
 			virtual Type *mutate( FunctionType *funcType );
-			
+
 		  private:
 			void addAdapters( FunctionType *functionType );
@@ -297,5 +297,5 @@
 			/// Exits the type-variable scope
 			void endTypeScope();
-			
+
 			ScopedSet< std::string > knownLayouts;          ///< Set of generic type layouts known in the current scope, indexed by sizeofName
 			ScopedSet< std::string > knownOffsets;          ///< Set of non-generic types for which the offset array exists in the current scope, indexed by offsetofName
@@ -351,5 +351,5 @@
 		PolyGenericCalculator polyCalculator;
 		Pass3 pass3;
-		
+
 		layoutBuilder.mutateDeclarationList( translationUnit );
 		mutateTranslationUnit/*All*/( translationUnit, pass1 );
@@ -370,5 +370,5 @@
 		return functionDecl;
 	}
-	
+
 	/// Get a list of type declarations that will affect a layout function
 	std::list< TypeDecl* > takeOtypeOnly( std::list< TypeDecl* > &decls ) {
@@ -380,5 +380,5 @@
 			}
 		}
-		
+
 		return otypeDecls;
 	}
@@ -387,5 +387,5 @@
 	void addOtypeParams( FunctionType *layoutFnType, std::list< TypeDecl* > &otypeParams ) {
 		BasicType sizeAlignType( Type::Qualifiers(), BasicType::LongUnsignedInt );
-		
+
 		for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin(); param != otypeParams.end(); ++param ) {
 			TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param );
@@ -444,5 +444,5 @@
 		return makeCond( ifCond, ifExpr );
 	}
-	
+
 	/// adds an expression to a compound statement
 	void addExpr( CompoundStmt *stmts, Expression *expr ) {
@@ -454,5 +454,5 @@
 		stmts->get_kids().push_back( stmt );
 	}
-	
+
 	Declaration *LayoutFunctionBuilder::mutate( StructDecl *structDecl ) {
 		// do not generate layout function for "empty" tag structs
@@ -467,5 +467,5 @@
 		BasicType *sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
 		PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType );
-		
+
 		ObjectDecl *sizeParam = new ObjectDecl( sizeofName( structDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
 		layoutFnType->get_parameters().push_back( sizeParam );
@@ -497,5 +497,5 @@
 				addStmt( layoutDecl->get_statements(), makeAlignTo( derefVar( sizeParam ), new AlignofExpr( memberType->clone() ) ) );
 			}
-			
+
 			// place current size in the current offset index
 			addExpr( layoutDecl->get_statements(), makeOp( "?=?", makeOp( "?[?]", new VariableExpr( offsetParam ), new ConstantExpr( Constant::from_ulong( n_members ) ) ),
@@ -505,5 +505,5 @@
 			// add member size to current size
 			addExpr( layoutDecl->get_statements(), makeOp( "?+=?", derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
-			
+
 			// take max of member alignment and global alignment
 			addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
@@ -515,9 +515,9 @@
 		return structDecl;
 	}
-	
+
 	Declaration *LayoutFunctionBuilder::mutate( UnionDecl *unionDecl ) {
 		// do not generate layout function for "empty" tag unions
 		if ( unionDecl->get_members().empty() ) return unionDecl;
-		
+
 		// get parameters that can change layout, exiting early if none
 		std::list< TypeDecl* > otypeParams = takeOtypeOnly( unionDecl->get_parameters() );
@@ -528,5 +528,5 @@
 		BasicType *sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
 		PointerType *sizeAlignOutType = new PointerType( Type::Qualifiers(), sizeAlignType );
-		
+
 		ObjectDecl *sizeParam = new ObjectDecl( sizeofName( unionDecl->get_name() ), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, sizeAlignOutType, 0 );
 		layoutFnType->get_parameters().push_back( sizeParam );
@@ -545,8 +545,8 @@
 			assert( dwt );
 			Type *memberType = dwt->get_type();
-			
+
 			// take max member size and global size
 			addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
-			
+
 			// take max of member alignment and global alignment
 			addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
@@ -558,5 +558,5 @@
 		return unionDecl;
 	}
-	
+
 	////////////////////////////////////////// Pass1 ////////////////////////////////////////////////////
 
@@ -619,5 +619,5 @@
 			return 0;
 		}
-		
+
 		/// returns T if the given declaration is: (*?=?)(T *, T) for some type T (return not checked, but maybe should be), NULL otherwise
 		/// Only picks assignments where neither parameter is cv-qualified
@@ -631,5 +631,5 @@
 						Type *paramType2 = funType->get_parameters().back()->get_type();
 						if ( paramType2->get_qualifiers() != defaultQualifiers ) return 0;
-						
+
 						if ( PointerType *pointerType = dynamic_cast< PointerType* >( paramType1 ) ) {
 							Type *baseType1 = pointerType->get_base();
@@ -803,5 +803,5 @@
 				passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes );
 			}
-			
+
 			// add type information args for presently unseen types in parameter list
 			for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
@@ -882,5 +882,5 @@
 			assert( env );
 			Type *concrete = replaceWithConcrete( appExpr, polyType );
-			// add out-parameter for return value	
+			// add out-parameter for return value
 			return addRetParam( appExpr, function, concrete, arg );
 		}
@@ -1035,9 +1035,11 @@
 			std::list< DeclarationWithType *>::iterator param = adapterType->get_parameters().begin();
 			std::list< DeclarationWithType *>::iterator realParam = adaptee->get_parameters().begin();
-			param++;		// skip adaptee parameter
+			param++;		// skip adaptee parameter in the adapter type
 			if ( realType->get_returnVals().empty() ) {
+				// void return
 				addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
 				bodyStmt = new ExprStmt( noLabels, adapteeApp );
 			} else if ( isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
+				// return type T
 				if ( (*param)->get_name() == "" ) {
 					(*param)->set_name( "_ret" );
@@ -1366,5 +1368,5 @@
 			return new VariableExpr( functionObj );
 		}
-		
+
 		Statement * Pass1::mutate( ReturnStmt *returnStmt ) {
 			if ( retval && returnStmt->get_expr() ) {
@@ -1886,5 +1888,5 @@
 				}
 			}
-			
+
 			Type *ret = Mutator::mutate( funcType );
 
@@ -1946,5 +1948,5 @@
 			return derefdVar;
 		}
-		
+
 		Expression *PolyGenericCalculator::mutate( MemberExpr *memberExpr ) {
 			// mutate, exiting early if no longer MemberExpr
@@ -2066,6 +2068,6 @@
 				if ( n_members == 0 ) {
 					// all empty structs have the same layout - size 1, align 1
-					makeVar( sizeofName( typeName ), layoutType, new SingleInit( new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
-					makeVar( alignofName( typeName ), layoutType->clone(), new SingleInit( new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
+					makeVar( sizeofName( typeName ), layoutType, new SingleInit( new ConstantExpr( Constant::from_ulong( (unsigned long)1 ) ) ) );
+					makeVar( alignofName( typeName ), layoutType->clone(), new SingleInit( new ConstantExpr( Constant::from_ulong( (unsigned long)1 ) ) ) );
 					// NOTE zero-length arrays are forbidden in C, so empty structs have no offsetof array
 				} else {
@@ -2144,5 +2146,5 @@
 			Type *ty = offsetofExpr->get_type();
 			if ( ! findGeneric( ty ) ) return offsetofExpr;
-			
+
 			if ( StructInstType *structType = dynamic_cast< StructInstType* >( ty ) ) {
 				// replace offsetof expression by index into offset array
