Index: src/AST/Convert.cpp
===================================================================
--- src/AST/Convert.cpp	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/AST/Convert.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -2729,5 +2729,6 @@
 			ty->forall.emplace_back(new ast::TypeInstType(param));
 			for (auto asst : param->assertions) {
-				ty->assertions.emplace_back(new ast::VariableExpr({}, asst));
+				ty->assertions.emplace_back(
+					new ast::VariableExpr(param->location, asst));
 			}
 		}
Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/Common/utility.h	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Feb 11 13:00:36 2020
-// Update Count     : 50
+// Last Modified By : Andrew Beach
+// Last Modified On : Mon Apr 25 14:26:00 2022
+// Update Count     : 51
 //
 
@@ -230,4 +230,10 @@
 }
 
+template<typename Container, typename Pred>
+void erase_if( Container & cont, Pred && pred ) {
+	auto keep_end = std::remove_if( cont.begin(), cont.end(), pred );
+	cont.erase( keep_end, cont.end() );
+}
+
 template< typename... Args >
 auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) {
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/SymTab/Validate.cc	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -10,6 +10,6 @@
 // Created On       : Sun May 17 21:50:04 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Nov 12 11:00:00 2021
-// Update Count     : 364
+// Last Modified On : Fri Apr 29  9:45:00 2022
+// Update Count     : 365
 //
 
@@ -143,4 +143,5 @@
 	struct LinkReferenceToTypes_old final : public WithIndexer, public WithGuards, public WithVisitorRef<LinkReferenceToTypes_old>, public WithShortCircuiting {
 		LinkReferenceToTypes_old( const Indexer * indexer );
+
 		void postvisit( TypeInstType * typeInst );
 
@@ -370,11 +371,15 @@
 	}
 
+	void linkReferenceToTypes( std::list< Declaration * > & translationUnit ) {
+		PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );
+		acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
+	}
+
 	void validate_B( std::list< Declaration * > & translationUnit ) {
-		PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );
 		PassVisitor<FixQualifiedTypes> fixQual;
 		{
 			Stats::Heap::newPass("validate-B");
 			Stats::Time::BlockGuard guard("validate-B");
-			acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
+			//linkReferenceToTypes( translationUnit );
 			mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed
 			HoistStruct::hoistStruct( translationUnit );
Index: src/SymTab/Validate.h
===================================================================
--- src/SymTab/Validate.h	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/SymTab/Validate.h	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -42,4 +42,5 @@
 	void validate_E( std::list< Declaration * > &translationUnit );
 	void validate_F( std::list< Declaration * > &translationUnit );
+	void linkReferenceToTypes( std::list< Declaration * > &translationUnit );
 
 	const ast::Type * validateType(
Index: src/Validate/EliminateTypedef.cpp
===================================================================
--- src/Validate/EliminateTypedef.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/EliminateTypedef.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,79 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// EliminateTypedef.cpp -- Removes TypedefDecl nodes from the AST.
+//
+// Author           : Andrew Beach
+// Created On       : Wed Apr 20 16:37:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Mon Apr 25 14:26:00 2022
+// Update Count     : 0
+//
+
+#include "Validate/EliminateTypedef.hpp"
+
+#include <algorithm>
+
+#include "AST/Decl.hpp"
+#include "AST/Pass.hpp"
+#include "AST/Stmt.hpp"
+#include "Common/utility.h"
+
+namespace Validate {
+
+namespace {
+
+struct EliminateTypedefCore {
+	ast::StructDecl const * previsit( ast::StructDecl const * decl );
+	ast::UnionDecl const * previsit( ast::UnionDecl const * decl );
+	ast::CompoundStmt const * previsit( ast::CompoundStmt const * stmt );
+};
+
+bool isTypedef( ast::ptr<ast::Decl> const & decl ) {
+	return (nullptr != decl.as<ast::TypedefDecl>());
+}
+
+bool isTypedefStmt( ast::ptr<ast::Stmt> const & stmt ) {
+	if ( auto declStmt = stmt.as<ast::DeclStmt>() ) {
+		return isTypedef( declStmt->decl );
+	}
+	return false;
+}
+
+template<typename node_t, typename super_t, typename field_t, typename pred_t>
+node_t const * field_erase_if( node_t const * node, field_t super_t::*field, pred_t && pred) {
+	node_t * mut = ast::mutate( node );
+	erase_if( mut->*field, pred );
+	return mut;
+}
+
+ast::StructDecl const * EliminateTypedefCore::previsit( ast::StructDecl const * decl ) {
+	return field_erase_if( decl, &ast::StructDecl::members, isTypedef );
+}
+
+ast::UnionDecl const * EliminateTypedefCore::previsit( ast::UnionDecl const * decl ) {
+	return field_erase_if( decl, &ast::UnionDecl::members, isTypedef );
+}
+
+ast::CompoundStmt const * EliminateTypedefCore::previsit( ast::CompoundStmt const * stmt ) {
+	return field_erase_if( stmt, &ast::CompoundStmt::kids, isTypedefStmt );
+}
+
+} // namespace
+
+/// Removes TypedefDecl nodes from the AST.
+void eliminateTypedef( ast::TranslationUnit & translationUnit ) {
+	ast::Pass<EliminateTypedefCore>::run( translationUnit );
+	erase_if( translationUnit.decls, isTypedef );
+}
+
+} // namespace Validate
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/EliminateTypedef.hpp
===================================================================
--- src/Validate/EliminateTypedef.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/EliminateTypedef.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,33 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// EliminateTypedef.hpp -- Removes TypedefDecl nodes from the AST.
+//
+// Author           : Andrew Beach
+// Created On       : Wed Apr 20 16:35:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Wed Apr 20 16:38:00 2022
+// Update Count     : 0
+//
+
+#pragma once
+
+namespace ast {
+	class TranslationUnit;
+}
+
+namespace Validate {
+
+/// Removes TypedefDecl nodes from the AST.
+void eliminateTypedef( ast::TranslationUnit & translationUnit );
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/FixQualifiedTypes.cpp
===================================================================
--- src/Validate/FixQualifiedTypes.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/FixQualifiedTypes.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,106 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// FixQualifiedTypes.cpp --
+//
+// Author           : Andrew Beach
+// Created On       : Thr Apr 21 11:13:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Fri Apr 22 11:36:00 2022
+// Update Count     : 0
+//
+
+#include "Validate/FixQualifiedTypes.hpp"
+
+#include "AST/Pass.hpp"
+#include "AST/TranslationUnit.hpp"
+#include "Validate/NoIdSymbolTable.hpp"
+
+namespace Validate {
+
+namespace {
+
+struct FixQualifiedTypesCore :
+		public WithNoIdSymbolTable, public ast::WithGuards {
+	CodeLocation const * location = nullptr;
+
+	void previsit( ast::ParseNode const * node ) {
+		GuardValue( location ) = &node->location;
+	}
+
+	ast::Type const * postvisit( ast::QualifiedType const * type ) {
+		assert( location );
+
+		ast::ptr<ast::Type> const & parent = type->parent;
+		ast::ptr<ast::Type> const & child = type->child;
+		if ( parent.as<ast::GlobalScopeType>() ) {
+			// .T => lookup T at global scope.
+			if ( auto inst = child.as<ast::TypeInstType>() ) {
+				auto td = symtab.globalLookupType( inst->name );
+				if ( !td ) {
+					SemanticError( *location, toString("Use of undefined global type ", inst->name) );
+				}
+				auto base = td->base;
+				assert( base );
+				ast::Type * ret = ast::deepCopy( base );
+				ret->qualifiers = type->qualifiers;
+				return ret;
+			} else {
+				// .T => T is not a type name.
+				assertf( false, "unhandled global qualified child type: %s", toCString(child) );
+			}
+		} else {
+			// S.T => S must be an aggregate type, find the declaration for T in S.
+			ast::AggregateDecl const * aggr = nullptr;
+			ast::BaseInstType const * instp = nullptr;
+			if ( auto inst = parent.as<ast::StructInstType>() ) {
+				aggr = inst->base;
+				instp = inst;
+			} else if ( auto inst = parent.as<ast::UnionInstType>() ) {
+				aggr = inst->base;
+				instp = inst;
+			} else {
+				SemanticError( *location, toString("Qualified type requires an aggregate on the left, but has: ", parent) );
+			}
+			// TODO: Need to handle forward declarations.
+			assert( aggr );
+			for ( ast::ptr<ast::Decl> const & member : aggr->members ) {
+				if ( auto inst = child.as<ast::TypeInstType>() ) {
+					if ( auto decl = member.as<ast::NamedTypeDecl>() ) {
+						if ( decl->name == inst->name ) {
+							assert( decl->base );
+							ast::Type * ret = ast::deepCopy( decl->base );
+							ret->qualifiers = type->qualifiers;
+							ast::TypeSubstitution sub( aggr->params, instp->params );
+							// = parent->genericSubstitution();
+							auto result = sub.apply(ret);
+							return result.node.release();
+						}
+					}
+				} else {
+					// S.T - S is not an aggregate => error.
+					assertf( false, "unhandled qualified child type: %s", toCString(type) );
+				}
+			}
+			// failed to find a satisfying definition of type
+			SemanticError( *location, toString("Undefined type in qualified type: ", type) );
+		}
+	}
+};
+
+} // namespace
+
+void fixQualifiedTypes( ast::TranslationUnit & translationUnit ) {
+	ast::Pass<FixQualifiedTypesCore>::run( translationUnit );
+}
+
+} // namespace Validate
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/FixQualifiedTypes.hpp
===================================================================
--- src/Validate/FixQualifiedTypes.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/FixQualifiedTypes.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,32 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// FixQualifiedTypes.hpp --
+//
+// Author           : Andrew Beach
+// Created On       : Thr Apr 21 11:11:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Apr 21 11:11:00 2022
+// Update Count     : 0
+//
+
+#pragma once
+
+namespace ast {
+	class TranslationUnit;
+}
+
+namespace Validate {
+
+void fixQualifiedTypes( ast::TranslationUnit & translationUnit );
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/ForallPointerDecay.cpp
===================================================================
--- src/Validate/ForallPointerDecay.cpp	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/Validate/ForallPointerDecay.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -10,6 +10,6 @@
 // Created On       : Tue Dec  7 16:15:00 2021
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Feb 11 10:59:00 2022
-// Update Count     : 0
+// Last Modified On : Sat Apr 23 13:10:00 2022
+// Update Count     : 1
 //
 
@@ -237,4 +237,9 @@
 }
 
+std::vector<ast::ptr<ast::DeclWithType>> expandAssertions(
+		std::vector<ast::ptr<ast::DeclWithType>> const & old ) {
+	return TraitExpander::expandAssertions( old );
+}
+
 } // namespace Validate
 
Index: src/Validate/ForallPointerDecay.hpp
===================================================================
--- src/Validate/ForallPointerDecay.hpp	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/Validate/ForallPointerDecay.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -10,11 +10,15 @@
 // Created On       : Tue Dec  7 16:15:00 2021
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Dec  8 11:50:00 2021
-// Update Count     : 0
+// Last Modified On : Sat Apr 23 13:13:00 2022
+// Update Count     : 1
 //
 
 #pragma once
 
+#include <vector>
+#include "AST/Node.hpp"
+
 namespace ast {
+	class DeclWithType;
 	class TranslationUnit;
 }
@@ -27,4 +31,8 @@
 void decayForallPointers( ast::TranslationUnit & transUnit );
 
+/// Expand all traits in an assertion list.
+std::vector<ast::ptr<ast::DeclWithType>> expandAssertions(
+        std::vector<ast::ptr<ast::DeclWithType>> const & );
+
 }
 
Index: src/Validate/GenericParameter.cpp
===================================================================
--- src/Validate/GenericParameter.cpp	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/Validate/GenericParameter.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -10,6 +10,6 @@
 // Created On       : Fri Mar 21 10:02:00 2022
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Apr 13 10:09:00 2022
-// Update Count     : 0
+// Last Modified On : Fri Apr 22 16:43:00 2022
+// Update Count     : 1
 //
 
@@ -22,4 +22,5 @@
 #include "AST/TranslationUnit.hpp"
 #include "AST/Type.hpp"
+#include "Validate/NoIdSymbolTable.hpp"
 
 namespace Validate {
@@ -138,31 +139,6 @@
 // --------------------------------------------------------------------------
 
-// A SymbolTable that only has the operations used in the Translate Dimension
-// pass. More importantly, it doesn't have some methods that should no be
-// called by the Pass template (lookupId and addId).
-class NoIdSymbolTable {
-	ast::SymbolTable base;
-public:
-#	define FORWARD_X( func, types_and_names, just_names ) \
-	inline auto func types_and_names -> decltype( base.func just_names ) { \
-		return base.func just_names ; \
-	}
-#	define FORWARD_0( func )         FORWARD_X( func, (),             () )
-#	define FORWARD_1( func, type )   FORWARD_X( func, (type arg),     (arg) )
-#	define FORWARD_2( func, t0, t1 ) FORWARD_X( func, (t0 a0, t1 a1), (a0, a1) )
-
-	FORWARD_0( enterScope )
-	FORWARD_0( leaveScope )
-	FORWARD_1( lookupType, const std::string &        )
-	FORWARD_1( addType   , const ast::NamedTypeDecl * )
-	FORWARD_1( addStruct , const ast::StructDecl *    )
-	FORWARD_1( addEnum   , const ast::EnumDecl *      )
-	FORWARD_1( addUnion  , const ast::UnionDecl *     )
-	FORWARD_1( addTrait  , const ast::TraitDecl *     )
-	FORWARD_2( addWith   , const std::vector< ast::ptr<ast::Expr> > &, const ast::Decl * )
-};
-
-struct TranslateDimensionCore : public ast::WithGuards {
-	NoIdSymbolTable symtab;
+struct TranslateDimensionCore :
+		public WithNoIdSymbolTable, public ast::WithGuards {
 
 	// SUIT: Struct- or Union- InstType
Index: src/Validate/HoistStruct.cpp
===================================================================
--- src/Validate/HoistStruct.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/HoistStruct.cpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,145 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// HoistStruct.cpp -- Flattens nested type declarations.
+//
+// Author           : Andrew Beach
+// Created On       : Thr Apr 21 10:34:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Apr 21 10:34:00 2022
+// Update Count     : 0
+//
+
+#include "Validate/HoistStruct.hpp"
+
+#include "AST/Pass.hpp"
+#include "AST/TranslationUnit.hpp"
+#include "Common/utility.h"
+
+namespace Validate {
+
+namespace {
+
+bool shouldHoist( ast::Decl const * decl ) {
+	return dynamic_cast< ast::StructDecl const * >( decl )
+		|| dynamic_cast< ast::UnionDecl const * >( decl )
+		|| dynamic_cast< ast::StaticAssertDecl const * >( decl );
+}
+
+/* This pass also does some renaming and internal field alteration, but the
+ * complex part is the actual hoisting. Hoisted declarations should always
+ * appear before the declaration they are hoisted out of and if two types are
+ * nested in the same declaration their order should not change.
+ */
+struct HoistStructCore final :
+		public ast::WithDeclsToAdd<>, public ast::WithGuards {
+	ast::StructDecl const * previsit( ast::StructDecl const * decl );
+	ast::StructDecl const * postvisit( ast::StructDecl const * decl );
+	ast::UnionDecl const * previsit( ast::UnionDecl const * decl );
+	ast::UnionDecl const * postvisit( ast::UnionDecl const * decl );
+	ast::StructInstType const * previsit( ast::StructInstType const * type );
+	ast::UnionInstType const * previsit( ast::UnionInstType const * type );
+	ast::EnumInstType const * previsit( ast::EnumInstType const * type );
+
+private:
+	template<typename AggrDecl>
+	AggrDecl const * preAggregate( AggrDecl const * );
+	template<typename AggrDecl>
+	AggrDecl const * postAggregate( AggrDecl const * );
+
+	ast::AggregateDecl const * parent = nullptr;
+};
+
+void qualifiedName( ast::AggregateDecl const * decl, std::ostringstream & ss ) {
+	if ( decl->parent ) {
+		qualifiedName( decl->parent, ss );
+	}
+	ss << "__" << decl->name;
+}
+
+std::string qualifiedName( ast::AggregateDecl const * decl ) {
+	std::ostringstream ss;
+	qualifiedName( decl, ss );
+	return ss.str();
+}
+
+template<typename AggrDecl>
+AggrDecl const * HoistStructCore::preAggregate( AggrDecl const * decl ) {
+	if ( parent ) {
+		auto mut = ast::mutate( decl );
+		mut->parent = parent;
+		mut->name = qualifiedName( mut );
+		return mut;
+	} else {
+		GuardValue( parent ) = decl;
+		return decl;
+	}
+}
+
+template<typename AggrDecl>
+AggrDecl const * HoistStructCore::postAggregate( AggrDecl const * decl ) {
+	auto mut = ast::mutate( decl );
+	for ( auto it = mut->members.begin() ; it != mut->members.end() ; ) {
+		if ( shouldHoist( *it ) ) {
+			// This is the place where the actual hoisting happens.
+			declsToAddBefore.push_back( it->get() );
+			it = mut->members.erase( it );
+		} else {
+			++it;
+		}
+	}
+	return mut;
+}
+
+ast::StructDecl const * HoistStructCore::previsit( ast::StructDecl const * decl ) {
+	return preAggregate( decl );
+}
+
+ast::StructDecl const * HoistStructCore::postvisit( ast::StructDecl const * decl ) {
+	return postAggregate( decl );
+}
+
+ast::UnionDecl const * HoistStructCore::previsit( ast::UnionDecl const * decl ) {
+	return preAggregate( decl );
+}
+
+ast::UnionDecl const * HoistStructCore::postvisit( ast::UnionDecl const * decl ) {
+	return postAggregate( decl );
+}
+
+template<typename InstType>
+InstType const * preInstType( InstType const * type ) {
+	assert( type->base );
+	auto mut = ast::mutate( type );
+	mut->name = mut->base->name;
+	return mut;
+}
+
+ast::StructInstType const * HoistStructCore::previsit( ast::StructInstType const * type ) {
+	return preInstType( type );
+}
+
+ast::UnionInstType const * HoistStructCore::previsit( ast::UnionInstType const * type ) {
+	return preInstType( type );
+}
+
+ast::EnumInstType const * HoistStructCore::previsit( ast::EnumInstType const * type ) {
+	return preInstType( type );
+}
+
+} // namespace
+
+void hoistStruct( ast::TranslationUnit & translationUnit ) {
+	ast::Pass<HoistStructCore>::run( translationUnit );
+}
+
+} // namespace Validate
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/HoistStruct.hpp
===================================================================
--- src/Validate/HoistStruct.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/HoistStruct.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,33 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// HoistStruct.hpp -- Flattens nested type declarations.
+//
+// Author           : Andrew Beach
+// Created On       : Thr Apr 21 10:33:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Apr 21 10:39:00 2022
+// Update Count     : 0
+//
+
+#pragma once
+
+namespace ast {
+	class TranslationUnit;
+}
+
+namespace Validate {
+
+/// Flattens nested type declarations.
+void hoistStruct( ast::TranslationUnit & translationUnit );
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/NoIdSymbolTable.hpp
===================================================================
--- src/Validate/NoIdSymbolTable.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ src/Validate/NoIdSymbolTable.hpp	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,70 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// NoIdSymbolTable.hpp -- Special WithSymbolTable variant ast::Pass helper.
+//
+// Author           : Andrew Beach
+// Created On       : Thr Apr 21 11:57:00 2022
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Apr 21 11:57:00 2022
+// Update Count     : 0
+//
+
+#pragma once
+
+#include "AST/SymbolTable.hpp"
+
+namespace Validate {
+
+// A SymbolTable that only has the operations used in the Translate Dimension
+// pass. More importantly, it doesn't have some methods that should no be
+// called by the Pass template (lookupId and addId).
+class NoIdSymbolTable {
+	ast::SymbolTable base;
+public:
+#	define FORWARD_X( func, types_and_names, just_names ) \
+	inline auto func types_and_names -> decltype( base.func just_names ) { \
+		return base.func just_names ; \
+	}
+#	define FORWARD_0( func )         FORWARD_X( func, (),             () )
+#	define FORWARD_1( func, type )   FORWARD_X( func, (type arg),     (arg) )
+#	define FORWARD_2( func, t0, t1 ) FORWARD_X( func, (t0 a0, t1 a1), (a0, a1) )
+
+	FORWARD_0( enterScope )
+	FORWARD_0( leaveScope )
+	FORWARD_1( lookupType  , const std::string & )
+	FORWARD_1( lookupStruct, const std::string & )
+	FORWARD_1( lookupEnum  , const std::string & )
+	FORWARD_1( lookupUnion , const std::string & )
+	FORWARD_1( lookupTrait , const std::string & )
+	FORWARD_1( addType  , const ast::NamedTypeDecl * )
+	FORWARD_1( addStruct, const ast::StructDecl *    )
+	FORWARD_1( addEnum  , const ast::EnumDecl *      )
+	FORWARD_1( addUnion , const ast::UnionDecl *     )
+	FORWARD_1( addTrait , const ast::TraitDecl *     )
+	FORWARD_1( addStruct, const std::string &        )
+	FORWARD_1( addUnion , const std::string &        )
+	FORWARD_2( addWith  , const std::vector< ast::ptr<ast::Expr> > &, const ast::Decl * )
+
+	FORWARD_1( globalLookupType, const std::string & )
+
+#	undef FORWARD_2
+#	undef FORWARD_1
+#	undef FORWARD_0
+#	undef FORWARD_X
+};
+
+struct WithNoIdSymbolTable {
+	NoIdSymbolTable symtab;
+};
+
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/Validate/module.mk
===================================================================
--- src/Validate/module.mk	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/Validate/module.mk	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -20,4 +20,8 @@
 	Validate/CompoundLiteral.cpp \
 	Validate/CompoundLiteral.hpp \
+	Validate/EliminateTypedef.cpp \
+	Validate/EliminateTypedef.hpp \
+	Validate/FixQualifiedTypes.cpp \
+	Validate/FixQualifiedTypes.hpp \
 	Validate/ForallPointerDecay.cpp \
 	Validate/ForallPointerDecay.hpp \
@@ -26,8 +30,11 @@
 	Validate/HandleAttributes.cc \
 	Validate/HandleAttributes.h \
+	Validate/HoistStruct.cpp \
+	Validate/HoistStruct.hpp \
 	Validate/InitializerLength.cpp \
 	Validate/InitializerLength.hpp \
 	Validate/LabelAddressFixer.cpp \
 	Validate/LabelAddressFixer.hpp \
+	Validate/NoIdSymbolTable.hpp \
 	Validate/ReturnCheck.cpp \
 	Validate/ReturnCheck.hpp \
Index: src/main.cc
===================================================================
--- src/main.cc	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ src/main.cc	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -10,6 +10,6 @@
 // Created On       : Fri May 15 23:12:02 2015
 // Last Modified By : Andrew Beach
-// Last Modified On : Wed Apr 13 11:11:00 2022
-// Update Count     : 672
+// Last Modified On : Fri Apr 29  9:52:00 2022
+// Update Count     : 673
 //
 
@@ -75,10 +75,14 @@
 #include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
 #include "Validate/Autogen.hpp"             // for autogenerateRoutines
+#include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
+#include "Validate/EliminateTypedef.hpp"    // for eliminateTypedef
+#include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
+#include "Validate/FixQualifiedTypes.hpp"   // for fixQualifiedTypes
+#include "Validate/ForallPointerDecay.hpp"  // for decayForallPointers
 #include "Validate/GenericParameter.hpp"    // for fillGenericParameters, tr...
-#include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
-#include "Validate/ForallPointerDecay.hpp"  // for decayForallPointers
-#include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
+#include "Validate/HoistStruct.hpp"         // for hoistStruct
 #include "Validate/InitializerLength.hpp"   // for setLengthFromInitializer
 #include "Validate/LabelAddressFixer.hpp"   // for fixLabelAddresses
+#include "Validate/LinkReferenceToTypes.hpp"// for linkReferenceToTypes
 #include "Validate/ReturnCheck.hpp"         // for checkReturnStatements
 #include "Virtual/ExpandCasts.h"            // for expandCasts
@@ -328,5 +332,7 @@
 		// add the assignment statement after the initialization of a type parameter
 		PASS( "Validate-A", SymTab::validate_A( translationUnit ) );
-		PASS( "Validate-B", SymTab::validate_B( translationUnit ) );
+
+		// Must happen before auto-gen, because it uses the sized flag.
+		PASS( "Link Reference To Types", SymTab::linkReferenceToTypes( translationUnit ) );
 
 		CodeTools::fillLocations( translationUnit );
@@ -342,4 +348,11 @@
 
 			forceFillCodeLocations( transUnit );
+
+			// Must happen after Link References To Types,
+			// because aggregate members are accessed.
+			PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) );
+
+			PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) );
+			PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) );
 
 			// Check as early as possible. Can't happen before
@@ -438,4 +451,5 @@
 			translationUnit = convert( move( transUnit ) );
 		} else {
+			PASS( "Validate-B", SymTab::validate_B( translationUnit ) );
 			PASS( "Validate-C", SymTab::validate_C( translationUnit ) );
 			PASS( "Validate-D", SymTab::validate_D( translationUnit ) );
Index: tests/.expect/nested-types-ERR2.nast.txt
===================================================================
--- tests/.expect/nested-types-ERR2.nast.txt	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ tests/.expect/nested-types-ERR2.nast.txt	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,7 @@
+nested-types.cfa:100:25: warning: Compiled
+nested-types.cfa:86:1 error: Use of undefined global type Z
+nested-types.cfa:87:1 error: Qualified type requires an aggregate on the left, but has: signed int
+nested-types.cfa:88:1 error: Undefined type in qualified type: Qualified Type:
+  instance of struct S with body
+  instance of type Z (not function type)
+
Index: tests/.expect/nested-types-ERR2.oast.txt
===================================================================
--- tests/.expect/nested-types-ERR2.oast.txt	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
+++ tests/.expect/nested-types-ERR2.oast.txt	(revision 298fe57025894ebcfae9883bdbc21d0e39e12ee8)
@@ -0,0 +1,7 @@
+nested-types.cfa:100:25: warning: Compiled
+nested-types.cfa:86:1 error: Use of undefined global type Z
+nested-types.cfa:87:1 error: Qualified type requires an aggregate on the left, but has: signed int
+nested-types.cfa:88:1 error: Undefined type in qualified type: Qualified Type:
+  instance of struct S with body 1
+  instance of type Z (not function type)
+
Index: sts/.expect/nested-types-ERR2.txt
===================================================================
--- tests/.expect/nested-types-ERR2.txt	(revision ffef2466401407de2086608fd91a3cb01202e96a)
+++ 	(revision )
@@ -1,7 +1,0 @@
-nested-types.cfa:100:25: warning: Compiled
-nested-types.cfa:86:1 error: Use of undefined global type Z
-nested-types.cfa:87:1 error: Qualified type requires an aggregate on the left, but has: signed int
-nested-types.cfa:88:1 error: Undefined type in qualified type: Qualified Type:
-  instance of struct S with body 1
-  instance of type Z (not function type)
-
