Index: translator/SymTab/IdTable.cc
===================================================================
--- translator/SymTab/IdTable.cc	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/IdTable.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -82,7 +82,13 @@
     }
   }
-  for( InnerTableType::const_iterator i = declTable.begin(); i != declTable.end(); ++i ) {
+  // ensure the set of routines with C linkage cannot be overloaded
+  for( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
     if( !i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) {
-      throw SemanticError( "invalid overload of C function ", i->second.top().first );
+	InnerTableType::iterator j = i;
+	for( j++; j != declTable.end(); ++j ) {
+	  if( !j->second.empty() && j->second.top().first->get_linkage() == LinkageSpec::C ) {
+	    throw SemanticError( "invalid overload of C function " );
+	  }
+	}
     }
   }
@@ -103,7 +109,46 @@
 }
 
+DeclarationWithType* IdTable::lookupId( const std::string &id) const {
+   DeclarationWithType* result = 0;
+   int depth = -1;
+
+   OuterTableType::const_iterator outer = table.find( id );
+   if( outer == table.end() ) return 0;
+   const InnerTableType &declTable = outer->second;
+   for( InnerTableType::const_iterator it = declTable.begin(); it != declTable.end(); ++it ) {
+     const std::stack< DeclEntry >& entry = it->second;
+     if( !entry.empty() && entry.top().second > depth ) {
+       result = entry.top().first;
+       depth = entry.top().second;
+     }
+   }
+   return result;
+}
+
 void 
 IdTable::dump( std::ostream &os ) const
 {
+  for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) {
+    for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
+#if 0
+      const std::stack< DeclEntry >& entry = inner->second;
+      if( !entry.empty() ) { // && entry.top().second == scopeLevel ) {
+        os << outer->first << " (" << inner->first << ") (" << entry.top().second << ")" << std::endl;
+      } else {
+        os << outer->first << " (" << inner->first << ") ( entry-empty)" << std::endl;
+      }
+#endif
+#if 0
+      std::stack<DeclEntry> stack = inner->second;
+      os << "dumping a stack" << std::endl;
+      while (!stack.empty()) {
+        DeclEntry d = stack.top();
+        os << outer->first << " (" << inner->first << ") (" << d.second << ") " << std::endl;
+        stack.pop();
+      }
+#endif
+    }
+  }
+#if 0
   for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) {
     for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
@@ -114,4 +159,5 @@
     }
   }
+#endif
 }
 
Index: translator/SymTab/IdTable.h
===================================================================
--- translator/SymTab/IdTable.h	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/IdTable.h	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -1,9 +1,2 @@
-/*
- * This file is part of the Cforall project
- *
- * $Id: IdTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $
- *
- */
-
 #ifndef SYMTAB_IDTABLE_H
 #define SYMTAB_IDTABLE_H
@@ -17,27 +10,25 @@
 
 namespace SymTab {
+    class IdTable {
+      public:
+	IdTable();
+  
+	void enterScope();
+	void leaveScope();
+	void addDecl( DeclarationWithType *decl );
+	void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const;
+	DeclarationWithType* lookupId( const std::string &id) const;
+  
+	void dump( std::ostream &os ) const; // debugging
 
-class IdTable
-{
-public:
-  IdTable();
-  
-  void enterScope();
-  void leaveScope();
-  void addDecl( DeclarationWithType *decl );
-  void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const;
-  
-  void dump( std::ostream &os ) const; // debugging
+      private:
+	typedef std::pair< DeclarationWithType*, int > DeclEntry;
+	typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
+	typedef std::map< std::string, InnerTableType > OuterTableType;
 
- private:
-  typedef std::pair< DeclarationWithType*, int > DeclEntry;
-  typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
-  typedef std::map< std::string, InnerTableType > OuterTableType;
-
-  OuterTableType table;
-  int scopeLevel;
-};
-
+	OuterTableType table;
+	int scopeLevel;
+    };
 } // namespace SymTab
 
-#endif /* #ifndef SYMTAB_IDTABLE_H */
+#endif // SYMTAB_IDTABLE_H
Index: translator/SymTab/Indexer.cc
===================================================================
--- translator/SymTab/Indexer.cc	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/Indexer.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -162,4 +162,8 @@
     }
 
+    DeclarationWithType* Indexer::lookupId( const std::string &id) const {
+	return idTable.lookupId(id);
+    }
+
     NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
 	return typeTable.lookup( id );
@@ -216,4 +220,20 @@
 
     void Indexer::print( std::ostream &os, int indent ) const {
+        using std::cerr;
+        using std::endl;
+
+        cerr << "===idTable===" << endl;
+        idTable.dump( os );
+        cerr << "===typeTable===" << endl;
+        typeTable.dump( os );
+        cerr << "===structTable===" << endl;
+        structTable.dump( os );
+        cerr << "===enumTable===" << endl;
+        enumTable.dump( os );
+        cerr << "===unionTable===" << endl;
+        unionTable.dump( os );
+        cerr << "===contextTable===" << endl;
+        contextTable.dump( os );
+#if 0
 	idTable.dump( os );
 	typeTable.dump( os );
@@ -222,4 +242,5 @@
 	unionTable.dump( os );
 	contextTable.dump( os );
+#endif
     }
 } // namespace SymTab
Index: translator/SymTab/Indexer.h
===================================================================
--- translator/SymTab/Indexer.h	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/Indexer.h	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -39,4 +39,5 @@
 
 	void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
+	DeclarationWithType* lookupId( const std::string &id) const;
 	NamedTypeDecl *lookupType( const std::string &id ) const;
 	StructDecl *lookupStruct( const std::string &id ) const;
@@ -58,3 +59,3 @@
 } // namespace SymTab
 
-#endif /* #ifndef SYMTAB_INDEXER_H */
+#endif // SYMTAB_INDEXER_H
Index: translator/SymTab/Mangler.cc
===================================================================
--- translator/SymTab/Mangler.cc	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/Mangler.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -226,4 +226,7 @@
 	    mangleName << "L";
 	}
+	if ( type->get_isAtomic() ) {
+	    mangleName << "A";
+	}
     }
 } // SymTab
Index: translator/SymTab/Validate.cc
===================================================================
--- translator/SymTab/Validate.cc	(revision ad17ba6a8a138b346278ade9cfca43fa9e7c84e1)
+++ translator/SymTab/Validate.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -278,5 +278,5 @@
 	    ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i );
 	    assert( obj );
-	    obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false ), enumDecl->get_name() ) );
+	    obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );
 	} // for
 	Parent::visit( enumDecl );
