Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision 1fbab5a0107bc631a52826378ed50c1187d6284c)
+++ src/InitTweak/FixInit.cc	(revision b2f50823a59f3609d5fa94e5fa9c7de52cc79754)
@@ -232,8 +232,9 @@
 			void handleFirstParam( Expression * firstParam );
 			template< typename... Params >
-			void emit( const Params &... params );
+			void emit( CodeLocation, const Params &... params );
 
 			FunctionDecl * function = 0;
-			std::set< DeclarationWithType * > unhandled, usedUninit;
+			std::set< DeclarationWithType * > unhandled;
+			std::map< DeclarationWithType *, CodeLocation > usedUninit;
 			ObjectDecl * thisParam = 0;
 			bool isCtor = false; // true if current function is a constructor
@@ -336,9 +337,4 @@
 			GenStructMemberCalls warner;
 			acceptAll( translationUnit, warner );
-
-			// visitor doesn't throw so that it can collect all errors
-			if ( ! warner.errors.isEmpty() ) {
-				throw warner.errors;
-			}
 		}
 
@@ -940,8 +936,9 @@
 			ValueGuard< FunctionDecl * > oldFunction( funcDecl );
 			ValueGuard< std::set< DeclarationWithType * > > oldUnhandled( unhandled );
-			ValueGuard< std::set< DeclarationWithType * > > oldUsedUninit( usedUninit );
+			ValueGuard< std::map< DeclarationWithType *, CodeLocation > > oldUsedUninit( usedUninit );
 			ValueGuard< ObjectDecl * > oldThisParam( thisParam );
 			ValueGuard< bool > oldIsCtor( isCtor );
 			ValueGuard< StructDecl * > oldStructDecl( structDecl );
+			errors = SemanticError();  // clear previous errors
 
 			// need to start with fresh sets
@@ -972,8 +969,18 @@
 			// remove the unhandled objects from usedUninit, because a call is inserted
 			// to handle them - only objects that are later constructed are used uninitialized.
-			std::set< DeclarationWithType * > diff;
-			std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ) );
-			for ( DeclarationWithType * member : diff ) {
-				emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" );
+			std::map< DeclarationWithType *, CodeLocation > diff;
+			// need the comparator since usedUninit and unhandled have different types
+			struct comp_t {
+				typedef decltype(usedUninit)::value_type usedUninit_t;
+				typedef decltype(unhandled)::value_type unhandled_t;
+				bool operator()(usedUninit_t x, unhandled_t y) { return x.first < y; }
+				bool operator()(unhandled_t x, usedUninit_t y) { return x < y.first; }
+			} comp;
+			std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ), comp );
+			for ( auto p : diff ) {
+				DeclarationWithType * member = p.first;
+				CodeLocation loc = p.second;
+				// xxx - make error message better by also tracking the location that the object is constructed at?
+				emit( loc, "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" );
 			}
 
@@ -1020,9 +1027,12 @@
 							}
 						} catch ( SemanticError & error ) {
-							emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed",  " and no ", isCtor ? "default constructor" : "destructor", " found" );
+							emit( funcDecl->location, "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed",  " and no ", isCtor ? "default constructor" : "destructor", " found" );
 						}
 					}
 				}
 				leaveScope();
+			}
+			if (! errors.isEmpty()) {
+				throw errors;
 			}
 		}
@@ -1079,5 +1089,5 @@
 							if ( unhandled.count( memberExpr->get_member() ) ) {
 								// emit a warning because a member was used before it was constructed
-								usedUninit.insert( memberExpr->get_member() );
+								usedUninit.insert( { memberExpr->get_member(), memberExpr->location } );
 							}
 						}
@@ -1089,13 +1099,15 @@
 
 		template< typename Visitor, typename... Params >
-		void error( Visitor & v, const Params &... params ) {
-			v.errors.append( toString( params... ) );
+		void error( Visitor & v, CodeLocation loc, const Params &... params ) {
+			SemanticError err( toString( params... ) );
+			err.set_location( loc );
+			v.errors.append( err );
 		}
 
 		template< typename... Params >
-		void GenStructMemberCalls::emit( const Params &... params ) {
+		void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) {
 			// toggle warnings vs. errors here.
 			// warn( params... );
-			error( *this, params... );
+			error( *this, loc, params... );
 		}
 
