Index: translator/SymTab/Indexer.cc
===================================================================
--- translator/SymTab/Indexer.cc	(revision 42dcae7185b7830fd591cd47f895c0a362a6e77d)
+++ translator/SymTab/Indexer.cc	(revision 0b8cd7227c65b28513877765de7302e28eefbb6f)
@@ -1,9 +1,2 @@
-/*
- * This file is part of the Cforall project
- *
- * $Id: Indexer.cc,v 1.12 2005/08/29 20:14:17 rcbilson Exp $
- *
- */
-
 #include "SynTree/Declaration.h"
 #include "SynTree/Type.h"
@@ -15,41 +8,31 @@
 #include "utility.h"
 
-#define debugPrint(x) if( doDebug ) { std::cout << x; }
+#define debugPrint(x) if ( doDebug ) { std::cout << x; }
 
 namespace SymTab {
-
-Indexer::Indexer( bool useDebug )
-  : doDebug( useDebug )
-{
-}
-
-Indexer::~Indexer()
-{
-}
-
-void 
-Indexer::visit( ObjectDecl *objectDecl )
-{
-  maybeAccept( objectDecl->get_type(), *this );
-  maybeAccept( objectDecl->get_init(), *this );
-  maybeAccept( objectDecl->get_bitfieldWidth(), *this );
-  if( objectDecl->get_name() != "" ) {
-    debugPrint( "Adding object " << objectDecl->get_name() << std::endl );
-    idTable.addDecl( objectDecl );
-  }
-}
-
-void 
-Indexer::visit( FunctionDecl *functionDecl )
-{
-  if( functionDecl->get_name() == "" ) return;
-  debugPrint( "Adding function " << functionDecl->get_name() << std::endl );
-  idTable.addDecl( functionDecl );
-  enterScope();
-  maybeAccept( functionDecl->get_functionType(), *this );
-  acceptAll( functionDecl->get_oldDecls(), *this );
-  maybeAccept( functionDecl->get_statements(), *this );
-  leaveScope();
-}
+    Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {}
+
+    Indexer::~Indexer() {}
+
+    void Indexer::visit( ObjectDecl *objectDecl ) {
+	maybeAccept( objectDecl->get_type(), *this );
+	maybeAccept( objectDecl->get_init(), *this );
+	maybeAccept( objectDecl->get_bitfieldWidth(), *this );
+	if ( objectDecl->get_name() != "" ) {
+	    debugPrint( "Adding object " << objectDecl->get_name() << std::endl );
+	    idTable.addDecl( objectDecl );
+	}
+    }
+
+    void Indexer::visit( FunctionDecl *functionDecl ) {
+	if ( functionDecl->get_name() == "" ) return;
+	debugPrint( "Adding function " << functionDecl->get_name() << std::endl );
+	idTable.addDecl( functionDecl );
+	enterScope();
+	maybeAccept( functionDecl->get_functionType(), *this );
+	acceptAll( functionDecl->get_oldDecls(), *this );
+	maybeAccept( functionDecl->get_statements(), *this );
+	leaveScope();
+    }
 
 /********
@@ -72,211 +55,171 @@
  */
 
-void 
-Indexer::visit( TypeDecl *typeDecl )
-{
-  // see A NOTE ON THE ORDER OF TRAVERSAL, above
-  // note that assertions come after the type is added to the symtab, since they aren't part
-  // of the type proper and may depend on the type itself
-  enterScope();
-  acceptAll( typeDecl->get_parameters(), *this );
-  maybeAccept( typeDecl->get_base(), *this );
-  leaveScope();
-  debugPrint( "Adding type " << typeDecl->get_name() << std::endl );
-  typeTable.add( typeDecl );
-  acceptAll( typeDecl->get_assertions(), *this );
-}
-
-void 
-Indexer::visit( TypedefDecl *typeDecl )
-{
-  enterScope();
-  acceptAll( typeDecl->get_parameters(), *this );
-  maybeAccept( typeDecl->get_base(), *this );
-  leaveScope();
-  debugPrint( "Adding typedef " << typeDecl->get_name() << std::endl );
-  typeTable.add( typeDecl );
-}
-
-void 
-Indexer::visit( StructDecl *aggregateDecl )
-{
-  // make up a forward declaration and add it before processing the members
-  StructDecl fwdDecl( aggregateDecl->get_name() );
-  cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
-  debugPrint( "Adding fwd decl for struct " << fwdDecl.get_name() << std::endl );
-  structTable.add( &fwdDecl );
-  
-  enterScope();
-  acceptAll( aggregateDecl->get_parameters(), *this );
-  acceptAll( aggregateDecl->get_members(), *this );
-  leaveScope();
-  
-  debugPrint( "Adding struct " << aggregateDecl->get_name() << std::endl );
-  // this addition replaces the forward declaration
-  structTable.add( aggregateDecl );
-}
-
-void 
-Indexer::visit( UnionDecl *aggregateDecl )
-{
-  // make up a forward declaration and add it before processing the members
-  UnionDecl fwdDecl( aggregateDecl->get_name() );
-  cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
-  debugPrint( "Adding fwd decl for union " << fwdDecl.get_name() << std::endl );
-  unionTable.add( &fwdDecl );
-  
-  enterScope();
-  acceptAll( aggregateDecl->get_parameters(), *this );
-  acceptAll( aggregateDecl->get_members(), *this );
-  leaveScope();
-  
-  debugPrint( "Adding union " << aggregateDecl->get_name() << std::endl );
-  unionTable.add( aggregateDecl );
-}
-
-void 
-Indexer::visit( EnumDecl *aggregateDecl )
-{
-  debugPrint( "Adding enum " << aggregateDecl->get_name() << std::endl );
-  enumTable.add( aggregateDecl );
-  // unlike structs, contexts, and unions, enums inject their members into the
-  // global scope
-  acceptAll( aggregateDecl->get_members(), *this );
-}
-
-void 
-Indexer::visit( ContextDecl *aggregateDecl )
-{
-  enterScope();
-  acceptAll( aggregateDecl->get_parameters(), *this );
-  acceptAll( aggregateDecl->get_members(), *this );
-  leaveScope();
-  
-  debugPrint( "Adding context " << aggregateDecl->get_name() << std::endl );
-  contextTable.add( aggregateDecl );
-}
-
-void 
-Indexer::visit( CompoundStmt *compoundStmt )
-{
-  enterScope();
-  acceptAll( compoundStmt->get_kids(), *this );
-  leaveScope();
-}
-
-void 
-Indexer::visit( ContextInstType *contextInst )
-{
-  acceptAll( contextInst->get_parameters(), *this );
-  acceptAll( contextInst->get_members(), *this );
-}
-
-void 
-Indexer::visit( StructInstType *structInst )
-{
-  if( !structTable.lookup( structInst->get_name() ) ) {
-    debugPrint( "Adding struct " << structInst->get_name() << " from implicit forward declaration" << std::endl );
-    structTable.add( structInst->get_name() );
-  }
-  enterScope();
-  acceptAll( structInst->get_parameters(), *this );
-  leaveScope();
-}
-
-void 
-Indexer::visit( UnionInstType *unionInst )
-{
-  if( !unionTable.lookup( unionInst->get_name() ) ) {
-    debugPrint( "Adding union " << unionInst->get_name() << " from implicit forward declaration" << std::endl );
-    unionTable.add( unionInst->get_name() );
-  }
-  enterScope();
-  acceptAll( unionInst->get_parameters(), *this );
-  leaveScope();
-}
-
-void
-Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const
-{
-  idTable.lookupId( id, list );
-}
-
-NamedTypeDecl *
-Indexer::lookupType( const std::string &id ) const
-{
-  return typeTable.lookup( id );
-}
-
-StructDecl *
-Indexer::lookupStruct( const std::string &id ) const
-{
-  return structTable.lookup( id );
-}
-
-EnumDecl *
-Indexer::lookupEnum( const std::string &id ) const
-{
-  return enumTable.lookup( id );
-}
-
-UnionDecl *
-Indexer::lookupUnion( const std::string &id ) const
-{
-  return unionTable.lookup( id );
-}
-
-ContextDecl *
-Indexer::lookupContext( const std::string &id ) const
-{
-  return contextTable.lookup( id );
-}
-
-void 
-Indexer::enterScope()
-{
-  if( doDebug ) {
-    std::cout << "--- Entering scope" << std::endl;
-  }
-  idTable.enterScope();
-  typeTable.enterScope();
-  structTable.enterScope();
-  enumTable.enterScope();
-  unionTable.enterScope();
-  contextTable.enterScope();
-}
-
-void 
-Indexer::leaveScope()
-{
-  using std::cout;
-  using std::endl;
-  
-  if( doDebug ) {
-    cout << "--- Leaving scope containing" << endl;
-    idTable.dump( cout );
-    typeTable.dump( cout );
-    structTable.dump( cout );
-    enumTable.dump( cout );
-    unionTable.dump( cout );
-    contextTable.dump( cout );
-  }
-  idTable.leaveScope();
-  typeTable.leaveScope();
-  structTable.leaveScope();
-  enumTable.leaveScope();
-  unionTable.leaveScope();
-  contextTable.leaveScope();
-}
-
-void 
-Indexer::print( std::ostream &os, int indent ) const
-{
-    idTable.dump( os );
-    typeTable.dump( os );
-    structTable.dump( os );
-    enumTable.dump( os );
-    unionTable.dump( os );
-    contextTable.dump( os );
-}
-
+    void Indexer::visit( TypeDecl *typeDecl ) {
+	// see A NOTE ON THE ORDER OF TRAVERSAL, above
+	// note that assertions come after the type is added to the symtab, since they aren't part
+	// of the type proper and may depend on the type itself
+	enterScope();
+	acceptAll( typeDecl->get_parameters(), *this );
+	maybeAccept( typeDecl->get_base(), *this );
+	leaveScope();
+	debugPrint( "Adding type " << typeDecl->get_name() << std::endl );
+	typeTable.add( typeDecl );
+	acceptAll( typeDecl->get_assertions(), *this );
+    }
+
+    void Indexer::visit( TypedefDecl *typeDecl ) {
+	enterScope();
+	acceptAll( typeDecl->get_parameters(), *this );
+	maybeAccept( typeDecl->get_base(), *this );
+	leaveScope();
+	debugPrint( "Adding typedef " << typeDecl->get_name() << std::endl );
+	typeTable.add( typeDecl );
+    }
+
+    void Indexer::visit( StructDecl *aggregateDecl ) {
+	// make up a forward declaration and add it before processing the members
+	StructDecl fwdDecl( aggregateDecl->get_name() );
+	cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
+	debugPrint( "Adding fwd decl for struct " << fwdDecl.get_name() << std::endl );
+	structTable.add( &fwdDecl );
+  
+	enterScope();
+	acceptAll( aggregateDecl->get_parameters(), *this );
+	acceptAll( aggregateDecl->get_members(), *this );
+	leaveScope();
+  
+	debugPrint( "Adding struct " << aggregateDecl->get_name() << std::endl );
+	// this addition replaces the forward declaration
+	structTable.add( aggregateDecl );
+    }
+
+    void Indexer::visit( UnionDecl *aggregateDecl ) {
+	// make up a forward declaration and add it before processing the members
+	UnionDecl fwdDecl( aggregateDecl->get_name() );
+	cloneAll( aggregateDecl->get_parameters(), fwdDecl.get_parameters() );
+	debugPrint( "Adding fwd decl for union " << fwdDecl.get_name() << std::endl );
+	unionTable.add( &fwdDecl );
+  
+	enterScope();
+	acceptAll( aggregateDecl->get_parameters(), *this );
+	acceptAll( aggregateDecl->get_members(), *this );
+	leaveScope();
+  
+	debugPrint( "Adding union " << aggregateDecl->get_name() << std::endl );
+	unionTable.add( aggregateDecl );
+    }
+
+    void Indexer::visit( EnumDecl *aggregateDecl ) {
+	debugPrint( "Adding enum " << aggregateDecl->get_name() << std::endl );
+	enumTable.add( aggregateDecl );
+	// unlike structs, contexts, and unions, enums inject their members into the global scope
+	acceptAll( aggregateDecl->get_members(), *this );
+    }
+
+    void Indexer::visit( ContextDecl *aggregateDecl ) {
+	enterScope();
+	acceptAll( aggregateDecl->get_parameters(), *this );
+	acceptAll( aggregateDecl->get_members(), *this );
+	leaveScope();
+  
+	debugPrint( "Adding context " << aggregateDecl->get_name() << std::endl );
+	contextTable.add( aggregateDecl );
+    }
+
+    void Indexer::visit( CompoundStmt *compoundStmt ) {
+	enterScope();
+	acceptAll( compoundStmt->get_kids(), *this );
+	leaveScope();
+    }
+
+    void Indexer::visit( ContextInstType *contextInst ) {
+	acceptAll( contextInst->get_parameters(), *this );
+	acceptAll( contextInst->get_members(), *this );
+    }
+
+    void Indexer::visit( StructInstType *structInst ) {
+	if ( ! structTable.lookup( structInst->get_name() ) ) {
+	    debugPrint( "Adding struct " << structInst->get_name() << " from implicit forward declaration" << std::endl );
+	    structTable.add( structInst->get_name() );
+	}
+	enterScope();
+	acceptAll( structInst->get_parameters(), *this );
+	leaveScope();
+    }
+
+    void Indexer::visit( UnionInstType *unionInst ) {
+	if ( ! unionTable.lookup( unionInst->get_name() ) ) {
+	    debugPrint( "Adding union " << unionInst->get_name() << " from implicit forward declaration" << std::endl );
+	    unionTable.add( unionInst->get_name() );
+	}
+	enterScope();
+	acceptAll( unionInst->get_parameters(), *this );
+	leaveScope();
+    }
+
+    void Indexer::lookupId( const std::string &id, std::list< DeclarationWithType* > &list ) const {
+	idTable.lookupId( id, list );
+    }
+
+    NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
+	return typeTable.lookup( id );
+    }
+
+    StructDecl *Indexer::lookupStruct( const std::string &id ) const {
+	return structTable.lookup( id );
+    }
+
+    EnumDecl *Indexer::lookupEnum( const std::string &id ) const {
+	return enumTable.lookup( id );
+    }
+
+    UnionDecl *Indexer::lookupUnion( const std::string &id ) const {
+	return unionTable.lookup( id );
+    }
+
+    ContextDecl  * Indexer::lookupContext( const std::string &id ) const {
+	return contextTable.lookup( id );
+    }
+
+    void Indexer::enterScope() {
+	if ( doDebug ) {
+	    std::cout << "--- Entering scope" << std::endl;
+	}
+	idTable.enterScope();
+	typeTable.enterScope();
+	structTable.enterScope();
+	enumTable.enterScope();
+	unionTable.enterScope();
+	contextTable.enterScope();
+    }
+
+    void Indexer::leaveScope() {
+	using std::cout;
+	using std::endl;
+  
+	if ( doDebug ) {
+	    cout << "--- Leaving scope containing" << endl;
+	    idTable.dump( cout );
+	    typeTable.dump( cout );
+	    structTable.dump( cout );
+	    enumTable.dump( cout );
+	    unionTable.dump( cout );
+	    contextTable.dump( cout );
+	}
+	idTable.leaveScope();
+	typeTable.leaveScope();
+	structTable.leaveScope();
+	enumTable.leaveScope();
+	unionTable.leaveScope();
+	contextTable.leaveScope();
+    }
+
+    void Indexer::print( std::ostream &os, int indent ) const {
+	idTable.dump( os );
+	typeTable.dump( os );
+	structTable.dump( os );
+	enumTable.dump( os );
+	unionTable.dump( os );
+	contextTable.dump( os );
+    }
 } // namespace SymTab
Index: translator/SymTab/Indexer.h
===================================================================
--- translator/SymTab/Indexer.h	(revision 42dcae7185b7830fd591cd47f895c0a362a6e77d)
+++ translator/SymTab/Indexer.h	(revision 0b8cd7227c65b28513877765de7302e28eefbb6f)
@@ -1,12 +1,2 @@
-/*
- * This file is part of the Cforall project
- *
- * A class that indexes the syntax tree.  It is intended to be subclassed by a visitor class
- * that wants to use the index.
- *
- * $Id: Indexer.h,v 1.9 2005/08/29 20:14:18 rcbilson Exp $
- *
- */
-
 #ifndef SYMTAB_INDEXER_H
 #define SYMTAB_INDEXER_H
@@ -22,52 +12,48 @@
 
 namespace SymTab {
+    class Indexer : public Visitor {
+      public:
+	Indexer( bool useDebug = false );
+	virtual ~Indexer();
 
-class Indexer : public Visitor
-{
-public:
-  Indexer( bool useDebug = false );
-  virtual ~Indexer();
+	//using Visitor::visit;
+	virtual void visit( ObjectDecl *objectDecl );
+	virtual void visit( FunctionDecl *functionDecl );
+	virtual void visit( TypeDecl *typeDecl );
+	virtual void visit( TypedefDecl *typeDecl );
+	virtual void visit( StructDecl *aggregateDecl );
+	virtual void visit( UnionDecl *aggregateDecl );
+	virtual void visit( EnumDecl *aggregateDecl );
+	virtual void visit( ContextDecl *aggregateDecl );
 
-///   using Visitor::visit;
-  virtual void visit( ObjectDecl *objectDecl );
-  virtual void visit( FunctionDecl *functionDecl );
-  virtual void visit( TypeDecl *typeDecl );
-  virtual void visit( TypedefDecl *typeDecl );
-  virtual void visit( StructDecl *aggregateDecl );
-  virtual void visit( UnionDecl *aggregateDecl );
-  virtual void visit( EnumDecl *aggregateDecl );
-  virtual void visit( ContextDecl *aggregateDecl );
+	virtual void visit( CompoundStmt *compoundStmt );
 
-  virtual void visit( CompoundStmt *compoundStmt );
+	virtual void visit( ContextInstType *contextInst );
+	virtual void visit( StructInstType *contextInst );
+	virtual void visit( UnionInstType *contextInst );
+  
+	// when using an indexer manually (e.g., within a mutator traversal), it is necessary to tell the indexer
+	// explicitly when scopes begin and end
+	void enterScope();
+	void leaveScope();
 
-  virtual void visit( ContextInstType *contextInst );
-  virtual void visit( StructInstType *contextInst );
-  virtual void visit( UnionInstType *contextInst );
+	void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
+	NamedTypeDecl *lookupType( const std::string &id ) const;
+	StructDecl *lookupStruct( const std::string &id ) const;
+	EnumDecl *lookupEnum( const std::string &id ) const;
+	UnionDecl *lookupUnion( const std::string &id ) const;
+	ContextDecl *lookupContext( const std::string &id ) const;
   
-  // when using an indexer manually (e.g., within a mutator traversal), it is
-  // necessary to tell the indexer explicitly when scopes begin and end
-  void enterScope();
-  void leaveScope();
-
-  void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
-  NamedTypeDecl *lookupType( const std::string &id ) const;
-  StructDecl *lookupStruct( const std::string &id ) const;
-  EnumDecl *lookupEnum( const std::string &id ) const;
-  UnionDecl *lookupUnion( const std::string &id ) const;
-  ContextDecl *lookupContext( const std::string &id ) const;
+	void print( std::ostream &os, int indent = 0 ) const;
+      private:
+	IdTable idTable;
+	TypeTable typeTable;
+	StructTable structTable;
+	EnumTable enumTable;
+	UnionTable unionTable;
+	ContextTable contextTable;
   
-  void print( std::ostream &os, int indent = 0 ) const;
-
- private:
-  IdTable idTable;
-  TypeTable typeTable;
-  StructTable structTable;
-  EnumTable enumTable;
-  UnionTable unionTable;
-  ContextTable contextTable;
-  
-  bool doDebug;		// display debugging trace
-};
-
+	bool doDebug;					// display debugging trace
+    };
 } // namespace SymTab
 
Index: translator/SymTab/Validate.cc
===================================================================
--- translator/SymTab/Validate.cc	(revision 42dcae7185b7830fd591cd47f895c0a362a6e77d)
+++ translator/SymTab/Validate.cc	(revision 0b8cd7227c65b28513877765de7302e28eefbb6f)
@@ -185,7 +185,7 @@
 	    if ( ! visitor.get_declsToAdd().empty() ) {
 		translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() );
-	    }
+	    } // if
 	    i = next;
-	}
+	} // while
     }
 
@@ -206,9 +206,9 @@
 		if ( doDelete ) {
 		    delete *i;
-		}
+		} // if
 		declList.erase( i );
-	    }
+	    } // if
 	    i = next;
-	}
+	} // while
     }
 
@@ -227,5 +227,5 @@
 	    Visitor::visit( aggregateDecl );
 	    inStruct = false;
-	}
+	} // if
 	// Always remove the hoisted aggregate from the inner structure.
 	filter( aggregateDecl->get_members(), isStructOrUnion, false );
@@ -275,9 +275,9 @@
 	// Set the type of each member of the enumeration to be EnumConstant
   
-	for( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
+	for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
 	    ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i );
 	    assert( obj );
 	    obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false ), enumDecl->get_name() ) );
-	}
+	} // for
 	Parent::visit( enumDecl );
     }
@@ -285,6 +285,5 @@
     namespace {
 	template< typename DWTIterator >
-	void
-	fixFunctionList( DWTIterator begin, DWTIterator end, FunctionType *func ) {
+	void fixFunctionList( DWTIterator begin, DWTIterator end, FunctionType *func ) {
 	    // the only case in which "void" is valid is where it is the only one in the list; then
 	    // it should be removed entirely
@@ -300,15 +299,15 @@
 		if ( i != end ) { 
 		    throw SemanticError( "invalid type void in function type ", func );
-		}
+		} // if
 	    } else {
 		++i;
-		for( ; i != end; ++i ) {
+		for ( ; i != end; ++i ) {
 		    FixFunction fixer;
 		    *i = (*i )->acceptMutator( fixer );
 		    if ( fixer.get_isVoid() ) {
 			throw SemanticError( "invalid type void in function type ", func );
-		    }
-		}
-	    }
+		    } // if
+		} // for
+	    } // if
 	}
     }
@@ -326,5 +325,5 @@
 	} else {
 	    indexer = this;
-	}
+	} // if
     }
 
@@ -336,9 +335,9 @@
 	    assert( ! structInst->get_baseStruct() || structInst->get_baseStruct()->get_members().empty() || ! st->get_members().empty() );
 	    structInst->set_baseStruct( st );
-	}
+	} // if
 	if ( ! st || st->get_members().empty() ) {
 	    // use of forward declaration
 	    forwardStructs[ structInst->get_name() ].push_back( structInst );
-	}
+	} // if
     }
 
@@ -349,9 +348,9 @@
 	if ( un ) {
 	    unionInst->set_baseUnion( un );
-	}
+	} // if
 	if ( ! un || un->get_members().empty() ) {
 	    // use of forward declaration
 	    forwardUnions[ unionInst->get_name() ].push_back( unionInst );
-	}
+	} // if
     }
 
@@ -361,14 +360,14 @@
 	if ( ! ctx ) {
 	    throw SemanticError( "use of undeclared context " + contextInst->get_name() );
-	}
-	for( std::list< TypeDecl * >::const_iterator i = ctx->get_parameters().begin(); i != ctx->get_parameters().end(); ++i ) {
-	    for( std::list< DeclarationWithType * >::const_iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
+	} // if
+	for ( std::list< TypeDecl * >::const_iterator i = ctx->get_parameters().begin(); i != ctx->get_parameters().end(); ++i ) {
+	    for ( std::list< DeclarationWithType * >::const_iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
 		if ( ContextInstType *otherCtx = dynamic_cast< ContextInstType * >(*assert ) ) {
 		    cloneAll( otherCtx->get_members(), contextInst->get_members() );
 		} else {
 		    contextInst->get_members().push_back( (*assert )->clone() );
-		}
-	    }
-	}
+		} // if
+	    } // for
+	} // for
 	applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) );
     }
@@ -378,10 +377,10 @@
 	    ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->get_name() );
 	    if ( fwds != forwardStructs.end() ) {
-		for( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
+		for ( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
 		    (*inst )->set_baseStruct( structDecl );
-		}
+		} // for
 		forwardStructs.erase( fwds );
-	    }
-	}
+	    } // if
+	} // if
 	Indexer::visit( structDecl );
     }
@@ -391,10 +390,10 @@
 	    ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->get_name() );
 	    if ( fwds != forwardUnions.end() ) {
-		for( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
+		for ( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
 		    (*inst )->set_baseUnion( unionDecl );
-		}
+		} // for
 		forwardUnions.erase( fwds );
-	    }
-	}
+	    } // if
+	} // if
 	Indexer::visit( unionDecl );
     }
@@ -404,6 +403,6 @@
 	    if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) {
 		typeInst->set_isFtype( typeDecl->get_kind() == TypeDecl::Ftype );
-	    }
-	}
+	    } // if
+	} // if
     }
 
@@ -413,16 +412,16 @@
 	} else {
 	    indexer = this;
-	}
+	} // if
     }
 
     void forallFixer( Type *func ) {
 	// Fix up assertions
-	for( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
+	for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
 	    std::list< DeclarationWithType * > toBeDone, nextRound;
 	    toBeDone.splice( toBeDone.end(), (*type )->get_assertions() );
 	    while ( ! toBeDone.empty() ) {
-		for( std::list< DeclarationWithType * >::iterator assertion = toBeDone.begin(); assertion != toBeDone.end(); ++assertion ) {
+		for ( std::list< DeclarationWithType * >::iterator assertion = toBeDone.begin(); assertion != toBeDone.end(); ++assertion ) {
 		    if ( ContextInstType *ctx = dynamic_cast< ContextInstType * >( (*assertion )->get_type() ) ) {
-			for( std::list< Declaration * >::const_iterator i = ctx->get_members().begin(); i != ctx->get_members().end(); ++i ) {
+			for ( std::list< Declaration * >::const_iterator i = ctx->get_members().begin(); i != ctx->get_members().end(); ++i ) {
 			    DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *i );
 			    assert( dwt );
@@ -449,5 +448,5 @@
 	if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
 	    forallFixer( pointer->get_base() );
-	}
+	} // if
 	Parent::visit( object );
 	object->fixUniqueId();
@@ -546,5 +545,5 @@
 	assignDecl->fixUniqueId();
   
-	for( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
+	for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
 	    if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) {
 		if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
@@ -552,7 +551,7 @@
 		} else {
 		    makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );
-		}
-	    }
-	}
+		} // if
+	    } // if
+	} // for
 	assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
   
@@ -594,5 +593,5 @@
 	    declsToAdd.push_back( makeStructAssignment( structDecl, structInst, functionNesting ) );
 	    structsDone.insert( structDecl->get_name() );
-	}
+	} // if
     }
 
@@ -602,5 +601,5 @@
 	    unionInst->set_baseUnion( unionDecl );
 	    declsToAdd.push_back( makeUnionAssignment( unionDecl, unionInst, functionNesting ) );
-	}
+	} // if
     }
 
@@ -617,5 +616,5 @@
 	    assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) );
 	    stmts->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) );
-	}
+	} // if
 	FunctionType *type = new FunctionType( Type::Qualifiers(), false );
 	type->get_returnVals().push_back( new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
@@ -628,24 +627,21 @@
     void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
 	if ( ! declsToAdd.empty() ) {
-	    for( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
+	    for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
 		statements.insert( i, new DeclStmt( noLabels, *decl ) );
-	    }
+	    } // for
 	    declsToAdd.clear();
-	}
+	} // if
     }
 
     void AddStructAssignment::visit( FunctionType *) {
-	// ensure that we don't add assignment ops for types defined
-	// as part of the function
+	// ensure that we don't add assignment ops for types defined as part of the function
     }
 
     void AddStructAssignment::visit( PointerType *) {
-	// ensure that we don't add assignment ops for types defined
-	// as part of the pointer
+	// ensure that we don't add assignment ops for types defined as part of the pointer
     }
 
     void AddStructAssignment::visit( ContextDecl *) {
-	// ensure that we don't add assignment ops for types defined
-	// as part of the context
+	// ensure that we don't add assignment ops for types defined as part of the context
     }
 
@@ -714,5 +710,5 @@
 	    delete typeInst;
 	    return ret;
-	}
+	} // if
 	return typeInst;
     }
@@ -721,11 +717,19 @@
 	Declaration *ret = Mutator::mutate( tyDecl );
 	typedefNames[ tyDecl->get_name() ] = tyDecl;
-	if ( AggregateDecl *aggDecl = dynamic_cast< AggregateDecl * >( tyDecl->get_base() ) ) {
-	    tyDecl->set_base( 0 );
-	    delete tyDecl;
-	    return aggDecl;
+	// When a typedef is a forward declaration:
+	//    typedef struct screen SCREEN;
+	// the declaration portion must be retained:
+	//    struct screen;
+	// because the expansion of the typedef is:
+	//    void rtn( SCREEN *p ) => void rtn( struct screen *p )
+	// hence the type-name "screen" must be defined.
+	// Note, qualifiers on the typedef are superfluous for the forward declaration.
+	if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) {
+	    return new StructDecl( aggDecl->get_name() );
+	} else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) {
+	    return new UnionDecl( aggDecl->get_name() );
 	} else {
 	    return ret;
-	}
+	} // if
     }
 
@@ -734,5 +738,5 @@
 	if ( i != typedefNames.end() ) {
 	    typedefNames.erase( i ) ;
-	}
+	} // if
 	return typeDecl;
     }
@@ -770,8 +774,8 @@
 		    delete *i;
 		    compoundStmt->get_kids().erase( i );
-		}
-	    }
+		} // if
+	    } // if
 	    i = next;
-	}
+	} // while
 	typedefNames = oldNames;
 	return ret;
