Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 2a4b0884c14643e09650daaeb3a6667b5bff6b48)
+++ src/ResolvExpr/Resolver.cc	(revision d63eeb0d6eeb995b4c8c414f1d4989b0189ef8ca)
@@ -5,11 +5,11 @@
 // file "LICENCE" distributed with Cforall.
 //
-// Resolver.cc -- 
+// Resolver.cc --
 //
 // Author           : Richard C. Bilson
 // Created On       : Sun May 17 12:17:01 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul 24 17:33:54 2015
-// Update Count     : 178
+// Last Modified By : Rob Schluntz
+// Last Modified On : Thu Jan 14 16:45:32 2016
+// Update Count     : 203
 //
 
@@ -33,5 +33,5 @@
 	  public:
 		Resolver() : SymTab::Indexer( false ), switchType( 0 ) {}
-  
+
 		virtual void visit( FunctionDecl *functionDecl );
 		virtual void visit( ObjectDecl *functionDecl );
@@ -54,4 +54,5 @@
 		virtual void visit( SingleInit *singleInit );
 		virtual void visit( ListInit *listInit );
+		virtual void visit( ConstructorInit *ctorInit );
 	  private:
   	typedef std::list< Initializer * >::iterator InitIterator;
@@ -59,4 +60,5 @@
 	  void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & );
 	  void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
+	  void fallbackInit( ConstructorInit * ctorInit );
 
 		std::list< Type * > functionReturn;
@@ -95,5 +97,5 @@
 			return newExpr;
 		}
-  
+
 		Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
 			TypeEnvironment env;
@@ -126,5 +128,5 @@
 			} // if
 		}
-  
+
 		Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
 			TypeEnvironment env;
@@ -159,7 +161,7 @@
 			return newExpr;
 		}
-  
-	}
-  
+
+	}
+
 	void Resolver::visit( ObjectDecl *objectDecl ) {
 		Type *new_type = resolveTypeof( objectDecl->get_type(), *this );
@@ -251,5 +253,5 @@
 			forStmt->set_condition( newExpr );
 		} // if
-		
+
 		if ( forStmt->get_increment() ) {
 			Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this );
@@ -265,5 +267,5 @@
 		delete switchStmt->get_condition();
 		switchStmt->set_condition( newExpr );
-  
+
 		visitor.Visitor::visit( switchStmt );
 	}
@@ -307,5 +309,5 @@
 	bool isCharType( T t ) {
 		if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) {
-			return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 
+			return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar ||
 				bt->get_kind() == BasicType::UnsignedChar;
 		}
@@ -319,5 +321,5 @@
 				string n = ne->get_name();
 				if (n == "0") {
-					initContext = new BasicType(Type::Qualifiers(), 
+					initContext = new BasicType(Type::Qualifiers(),
 												BasicType::SignedInt);
 				} else {
@@ -325,5 +327,5 @@
 					initContext = decl->get_type();
 				}
-			} else if (ConstantExpr * e = 
+			} else if (ConstantExpr * e =
 					   dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
 				Constant *c = e->get_constant();
@@ -349,5 +351,5 @@
 							singleInit->set_value( ce->get_arg() );
 							ce->set_arg( NULL );
-							delete ce;									
+							delete ce;
 						}
 					}
@@ -465,4 +467,44 @@
 #endif
 	}
+
+	// ConstructorInit - fall back on C-style initializer
+	void Resolver::fallbackInit( ConstructorInit * ctorInit ) {
+		// could not find valid constructor, or found an intrinsic constructor
+		// fall back on C-style initializer
+		delete ctorInit->get_ctor();
+		ctorInit->set_ctor( NULL );
+		maybeAccept( ctorInit->get_init(), *this );
+	}
+
+	void Resolver::visit( ConstructorInit *ctorInit ) {
+		TypeEnvironment env;
+		AlternativeFinder finder( *this, env );
+		finder.find( ctorInit->get_ctor() );
+
+		if ( finder.get_alternatives().size() == 0 ) {
+			fallbackInit( ctorInit );
+		} else if ( finder.get_alternatives().size() == 1 ) {
+			Alternative &choice = finder.get_alternatives().front();
+			if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( choice.expr ) ) {
+				if ( VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ) ) {
+					if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
+						// if the constructor that was found is intrinsic, reset to C-style
+						// initializer so that code generation is easy to handle
+						fallbackInit( ctorInit );
+						return;
+					}
+				}
+			}
+			// found a constructor - can get rid of C-style initializer
+			Expression *newExpr = choice.expr->clone();
+			finishExpr( newExpr, choice.env );
+			ctorInit->set_ctor( newExpr );
+			delete ctorInit->get_init();
+			ctorInit->set_init( NULL );
+		} else {
+			// too many constructors found
+			assert(false);
+		}
+	}
 } // namespace ResolvExpr
 
