Index: src/SymTab/Indexer.cc
===================================================================
--- src/SymTab/Indexer.cc	(revision 956a9c7709f7a1b604cbdfecffd5ca5b7f25c383)
+++ src/SymTab/Indexer.cc	(revision 31e46b8bbd52392f177414b305987b2c9f1bd311)
@@ -526,4 +526,21 @@
 
 		return tables->base.hasIncompatibleCDecl( id, mangleName, scope );
+	}
+
+	bool Indexer::hasCompatibleCDecl( 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 );
+		if ( decls != tables->idTable.end() ) {
+			const MangleTable &mangleTable = decls->second;
+			for ( MangleTable::const_iterator decl = mangleTable.begin(); decl != mangleTable.end(); ++decl ) {
+				// check for C decls with the same name, skipping
+				// those with an incompatible type (by mangleName)
+				if ( decl->second->get_linkage() == LinkageSpec::C && decl->first == mangleName ) return true;
+			}
+		}
+
+		return tables->base.hasCompatibleCDecl( id, mangleName, scope );
 	}
 
@@ -616,18 +633,28 @@
 		} // if
 
+		// 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 ) {
+			// NOTE this is broken in Richard's original code in such a way that it never triggers (it
+			// doesn't check decls that have the same manglename, and all C-linkage decls are defined to
+			// have their name as their manglename, hence the error can never trigger).
+			// The code here is closer to correct, but name mangling would have to be completely
+			// isomorphic to C type-compatibility, which it may not be.
+			if ( hasIncompatibleCDecl( name, mangleName, scope ) ) {
+				throw SemanticError( "conflicting overload of C function ", decl );
+			}
+		} else {
+			// Check that a Cforall declaration doesn't overload any C declaration
+			if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
+				throw SemanticError( "Cforall declaration hides C function ", decl );
+			}
+		}
+
+		// Skip repeat declarations of the same identifier
 		DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );
-		if ( ! existing || ! addedIdConflicts( existing, decl ) ) {
-			// 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
-			  // doesn't check decls that have the same manglename, and all C-linkage decls are defined to
-			  // have their name as their manglename, hence the error can never trigger).
-			  // The code here is closer to correct, but name mangling would have to be completely
-			  // isomorphic to C type-compatibility, which it may not be.
-
-			tables->idTable[ name ][ mangleName ] = decl;
-			++tables->size;
-		}
+		if ( existing && addedIdConflicts( existing, decl ) ) return;
+
+		// add to indexer
+		tables->idTable[ name ][ mangleName ] = decl;
+		++tables->size;
 	}
 
Index: src/SymTab/Indexer.h
===================================================================
--- src/SymTab/Indexer.h	(revision 956a9c7709f7a1b604cbdfecffd5ca5b7f25c383)
+++ src/SymTab/Indexer.h	(revision 31e46b8bbd52392f177414b305987b2c9f1bd311)
@@ -100,4 +100,6 @@
 		/// 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, unsigned long scope ) const;
+		/// returns true if there exists a declaration with C linkage and the given name with the same mangled name
+		bool hasCompatibleCDecl( 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;
Index: src/SymTab/Mangler.cc
===================================================================
--- src/SymTab/Mangler.cc	(revision 956a9c7709f7a1b604cbdfecffd5ca5b7f25c383)
+++ src/SymTab/Mangler.cc	(revision 31e46b8bbd52392f177414b305987b2c9f1bd311)
@@ -282,7 +282,8 @@
 			mangleName << "V";
 		} // if
-		if ( type->get_isRestrict() ) {
-			mangleName << "R";
-		} // if
+		// Removed due to restrict not affecting function compatibility in GCC
+//		if ( type->get_isRestrict() ) {
+//			mangleName << "R";
+//		} // if
 		if ( type->get_isLvalue() ) {
 			mangleName << "L";
