Index: src/SymTab/IdTable.cc
===================================================================
--- src/SymTab/IdTable.cc	(revision 4aa08588a147bfd3d681c5a511cd5d23bdc6db71)
+++ src/SymTab/IdTable.cc	(revision b0be06ac6a8827cfc7fbc52dee30e7ed931d8fcd)
@@ -10,6 +10,6 @@
 // Created On       : Sun May 17 17:04:02 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Wed Aug 19 15:47:58 2015
-// Update Count     : 38
+// Last Modified On : Wed Oct 07 12:21:13 2015
+// Update Count     : 73
 //
 
@@ -37,4 +37,5 @@
 			for ( InnerTableType::iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
 				std::stack< DeclEntry >& entry = inner->second;
+				// xxx - should be while?
 				if ( ! entry.empty() && entry.top().second == scopeLevel ) {
 					entry.pop();
@@ -65,37 +66,46 @@
 
 		if ( it == declTable.end() ) {
+			// first time this name mangling has been defined
 			declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
 		} else {
 			std::stack< DeclEntry >& entry = it->second;
 			if ( ! entry.empty() && entry.top().second == scopeLevel ) {
-				// typesCompatible doesn't really do the right thing here. When checking compatibility of function types,
-				// we should ignore outermost pointer qualifiers, except _Atomic?
+				// if we're giving the same name mangling to things of
+				//  different types then there is something wrong
+				Declaration *old = entry.top().first;
+				assert( (dynamic_cast<ObjectDecl*>( decl ) && dynamic_cast<ObjectDecl*>( old ) )
+				  || (dynamic_cast<FunctionDecl*>( decl ) && dynamic_cast<FunctionDecl*>( old ) ) );
 
-				if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) {
+				if ( LinkageSpec::isOverridable( old->get_linkage() ) ) {
+					// new definition shadows the autogenerated one, even at the same scope
+					declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
+				} else if ( decl->get_linkage() != LinkageSpec::C || ResolvExpr::typesCompatible( decl->get_type(), entry.top().first->get_type(), Indexer() ) ) {
+					// typesCompatible doesn't really do the right thing here. When checking compatibility of function types,
+					// we should ignore outermost pointer qualifiers, except _Atomic?
 					FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( decl );
-					FunctionDecl *old = dynamic_cast< FunctionDecl* >( entry.top().first );
-					if ( LinkageSpec::isOverridable( old->get_linkage() ) ) {
-						// new definition shadows the autogenerated one, even at the same scope
-						declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
-					} else if ( newentry && old && newentry->get_statements() && old->get_statements() ) {
-						throw SemanticError( "duplicate function definition for 1 ", decl );
+					FunctionDecl *oldentry = dynamic_cast< FunctionDecl* >( old );
+					if ( newentry && oldentry ) {
+						if ( newentry->get_statements() && oldentry->get_statements() ) {
+							throw SemanticError( "duplicate function definition for 1 ", decl );
+						} // if
 					} else {
 						// two objects with the same mangled name defined in the same scope.
-						// both objects must be marked extern for this to be okay
+						// both objects must be marked extern or both must be intrinsic for this to be okay
+						// xxx - perhaps it's actually if either is intrinsic then this is okay?
+						//       might also need to be same storage class?
 						ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( decl );
-						ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( entry.top().first );
-						if ( newobj && oldobj && newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {
-							throw SemanticError( "duplicate definition for ", decl );
+						ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( old );
+						if (newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {
+							throw SemanticError( "duplicate definition for 3 ", decl );
 						} // if
 					} // if
 				} else {
-					// C definitions with the same name but incompatible types
-					throw SemanticError( "duplicate definition for 2 ", decl );
+					throw SemanticError( "duplicate definition for ", decl );
 				} // if
 			} else {
+				// new scope level - shadow existing definition
 				declTable[ manglename ].push( DeclEntry( decl, scopeLevel ) );
 			} // if
 		} // if
-		// ensure the set of routines with C linkage cannot be overloaded
 		// this ensures that no two declarations with the same unmangled name both have C linkage
 		for ( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
