Index: src/SymTab/Indexer.cc
===================================================================
--- src/SymTab/Indexer.cc	(revision b644d6fe698549bdb8735a12df63d8ed6ce9329e)
+++ src/SymTab/Indexer.cc	(revision 09d1ad0b1f50213ed8f7a8749ff1ba2242b2c4a7)
@@ -511,6 +511,7 @@
 	}
 
-	bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const {
+	bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const {
 		if ( ! tables ) return false;
+		if ( tables->scope < scope ) return false;
 
 		IdTable::const_iterator decls = tables->idTable.find( id );
@@ -524,5 +525,5 @@
 		}
 
-		return tables->base.hasIncompatibleCDecl( id, mangleName );
+		return tables->base.hasIncompatibleCDecl( id, mangleName, scope );
 	}
 	
@@ -617,6 +618,6 @@
 		DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );
 		if ( ! existing || ! addedIdConflicts( existing, decl ) ) {
-			// this ensures that no two declarations with the same unmangled name both have C linkage
-			if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName ) ) {
+			// this ensures that no two declarations with the same unmangled name at the same scope both have C linkage
+			if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName, scope ) ) {
 				throw SemanticError( "invalid overload of C function ", decl );
 			} // NOTE this is broken in Richard's original code in such a way that it never triggers (it 
Index: src/SymTab/Indexer.h
===================================================================
--- src/SymTab/Indexer.h	(revision b644d6fe698549bdb8735a12df63d8ed6ce9329e)
+++ src/SymTab/Indexer.h	(revision 09d1ad0b1f50213ed8f7a8749ff1ba2242b2c4a7)
@@ -99,5 +99,5 @@
 		DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
 		/// returns true if there exists a declaration with C linkage and the given name with a different mangled name
-		bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
+		bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
 		// equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
 		NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
