Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 1744e6dcb31d7285202ff1adba2028191f51648e)
+++ src/GenPoly/Box.cc	(revision b1bead1a79d5d9fa8163bf1e0aa465cab6732772)
@@ -755,5 +755,5 @@
 
 		void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
-			assert( arg->has_result() );
+			assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() );
 			if ( isPolyType( param, exprTyVars ) ) {
 				if ( isPolyType( arg->get_result() ) ) {
@@ -1027,7 +1027,6 @@
 						} // if
 						if ( baseType1 || baseType2 ) {
-							Type * baseType = InitTweak::getPointerBase( appExpr->get_result() );
-							assert( baseType );
-							ret->set_result( baseType->clone() );
+							delete ret->get_result();
+							ret->set_result( appExpr->get_result()->clone() );
 							if ( appExpr->get_env() ) {
 								ret->set_env( appExpr->get_env() );
@@ -1041,12 +1040,10 @@
 						assert( appExpr->has_result() );
 						assert( ! appExpr->get_args().empty() );
-						if ( isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { // dereference returns a reference type
+						if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
 							// remove dereference from polymorphic types since they are boxed.
 							Expression *ret = appExpr->get_args().front();
-							// fix expr type to remove reference
+							// fix expr type to remove pointer
 							delete ret->get_result();
-							Type * baseType = InitTweak::getPointerBase( appExpr->get_result() );
-							assert( baseType );
-							ret->set_result( baseType->clone() );
+							ret->set_result( appExpr->get_result()->clone() );
 							if ( appExpr->get_env() ) {
 								ret->set_env( appExpr->get_env() );
@@ -1136,6 +1133,6 @@
 
 			assert( appExpr->get_function()->has_result() );
-			PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
-			FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
+			FunctionType * function = getFunctionType( appExpr->get_function()->get_result() );
+			assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->get_function()->get_result() ).c_str() );
 
 			if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
@@ -1214,6 +1211,6 @@
 							if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
 								assert( appExpr->get_function()->has_result() );
-								PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
-								FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
+								FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
+								assert( function );
 								needs = needsAdapter( function, scopeTyVars );
 							} // if
@@ -1293,5 +1290,6 @@
 				if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
 					std::string adapterName = makeAdapterName( mangleName );
-					paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );
+					// adapter may not be used in body, pass along with unused attribute.
+					paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) );
 					adaptersDone.insert( adaptersDone.begin(), mangleName );
 				}
@@ -1399,5 +1397,7 @@
 			std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
 			std::list< DeclarationWithType *> inferredParams;
-			ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
+			// size/align/offset parameters may not be used in body, pass along with unused attribute.
+			ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
+			                   { new Attribute( "unused" ) } );
 			ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
 			                   new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
@@ -1422,4 +1422,6 @@
 				for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
 //      *assert = (*assert)->acceptMutator( *this );
+					// assertion parameters may not be used in body, pass along with unused attribute.
+					(*assert)->get_attributes().push_back( new Attribute( "unused" ) );
 					inferredParams.push_back( *assert );
 				}
