Index: src/Parser/TypedefTable.cc
===================================================================
--- src/Parser/TypedefTable.cc	(revision 3fd8b0e5843090638b089c00c98afdee3dbe23be)
+++ src/Parser/TypedefTable.cc	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:20:13 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 13:17:56 2018
-// Update Count     : 192
+// Last Modified On : Fri Jun 22 06:14:39 2018
+// Update Count     : 206
 //
 
@@ -78,11 +78,12 @@
 	debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
 	auto ret = kindTable.insertAt( scope, identifier, kind );
-	if ( ! ret.second ) ret.first->second = kind;		// exists => update
+	//if ( ! ret.second ) ret.first->second = kind;		// exists => update
+	assert( ret.first->second == kind );				// exists
 } // TypedefTable::addToScope
 
 void TypedefTable::addToEnclosingScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
-	assert( kindTable.currentScope() >= 1 );
-	auto scope = kindTable.currentScope() - 1;
-	debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
+	assert( kindTable.currentScope() >= 1 + level );
+	auto scope = kindTable.currentScope() - 1 - level;
+	debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << endl );
 	auto ret = kindTable.insertAt( scope, identifier, kind );
 	if ( ! ret.second ) ret.first->second = kind;		// exists => update
@@ -91,11 +92,9 @@
 void TypedefTable::enterScope() {
 	kindTable.beginScope();
-	debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl );
-	debugPrint( print() );
+	debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl; print() );
 } // TypedefTable::enterScope
 
 void TypedefTable::leaveScope() {
-	debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl );
-	debugPrint( print() );
+	debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl; print() );
 	kindTable.endScope();
 } // TypedefTable::leaveScope
@@ -114,7 +113,7 @@
 		--scope;
 		debugPrint( cerr << endl << "[" << scope << "]" );
-	}
+	} // while
 	debugPrint( cerr << endl );
-}
+} // TypedefTable::print
 
 // Local Variables: //
Index: src/Parser/TypedefTable.h
===================================================================
--- src/Parser/TypedefTable.h	(revision 3fd8b0e5843090638b089c00c98afdee3dbe23be)
+++ src/Parser/TypedefTable.h	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:24:36 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 12:10:17 2018
-// Update Count     : 85
+// Last Modified On : Fri Jun 22 05:29:58 2018
+// Update Count     : 86
 //
 
@@ -25,4 +25,5 @@
 	typedef ScopedMap< std::string, int > KindTable;
 	KindTable kindTable;	
+	unsigned int level = 0;
   public:
 	~TypedefTable();
@@ -37,4 +38,7 @@
 	void leaveScope();
 
+	void up() { level += 1; }
+	void down() { level -= 1; }
+
 	void print( void ) const;
 }; // TypedefTable
Index: src/Parser/lex.ll
===================================================================
--- src/Parser/lex.ll	(revision 3fd8b0e5843090638b089c00c98afdee3dbe23be)
+++ src/Parser/lex.ll	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
  * Created On       : Sat Sep 22 08:58:10 2001
  * Last Modified By : Peter A. Buhr
- * Last Modified On : Thu Jun  7 08:27:40 2018
- * Update Count     : 679
+ * Last Modified On : Wed Jun 20 09:08:28 2018
+ * Update Count     : 682
  */
 
@@ -25,6 +25,13 @@
 //**************************** Includes and Defines ****************************
 
+// trigger before each matching rule's action
+#define YY_USER_ACTION \
+	yylloc.first_line = yylineno; \
+	yylloc.first_column = column; \
+	column += yyleng; \
+	yylloc.last_column = column; \
+	yylloc.last_line = yylineno; \
+	yylloc.filename = yyfilename ? yyfilename : "";
 unsigned int column = 0;								// position of the end of the last token parsed
-#define YY_USER_ACTION yylloc.first_line = yylineno; yylloc.first_column = column; column += yyleng; yylloc.last_column = column; yylloc.last_line = yylineno; yylloc.filename = yyfilename ? yyfilename : "";				// trigger before each matching rule's action
 
 #include <string>
@@ -49,5 +56,5 @@
 #define NUMERIC_RETURN(x)	rm_underscore(); RETURN_VAL( x ) // numeric constant
 #define KEYWORD_RETURN(x)	RETURN_CHAR( x )			// keyword
-#define QKEYWORD_RETURN(x)	typedefTable.isKind( yytext ); RETURN_VAL(x); // quasi-keyword
+#define QKEYWORD_RETURN(x)	RETURN_VAL(x);				// quasi-keyword
 #define IDENTIFIER_RETURN()	RETURN_VAL( typedefTable.isKind( yytext ) )
 #define ATTRIBUTE_RETURN()	RETURN_VAL( ATTR_IDENTIFIER )
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision 3fd8b0e5843090638b089c00c98afdee3dbe23be)
+++ src/Parser/parser.yy	(revision c653b37a0a370ac84dabe4b28e825c920a425f13)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jun  7 10:07:12 2018
-// Update Count     : 3527
+// Last Modified On : Sun Jun 24 10:41:10 2018
+// Update Count     : 3587
 //
 
@@ -136,5 +136,5 @@
 } // build_postfix_name
 
-bool forall = false, xxx = false;						// aggregate have one or more forall qualifiers ?
+bool forall = false, xxx = false, yyy = false;			// aggregate have one or more forall qualifiers ?
 
 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type
@@ -304,5 +304,7 @@
 %type<en> enumerator_value_opt
 
-%type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt
+%type<decl> external_definition external_definition_list external_definition_list_opt
+
+%type<decl> exception_declaration
 
 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list
@@ -503,9 +505,7 @@
 		{ $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
 	| type_name '.' no_attr_identifier					// CFA, nested type
-		// { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
-		{ $$ = nullptr; }
+		{ SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
 	| type_name '.' '[' field_list ']'					// CFA, nested type / tuple field selector
-		// { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
-		{ $$ = nullptr; }
+		{ SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
 	| GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
 		{
@@ -1821,23 +1821,26 @@
 	;
 
+fred:
+	// empty
+		{ yyy = false; }
+	;
+
 aggregate_type:											// struct, union
 	aggregate_key attribute_list_opt '{' field_declaration_list_opt '}'
 		{ $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }
-	| aggregate_key attribute_list_opt no_attr_identifier
+	| aggregate_key attribute_list_opt no_attr_identifier fred
 		{
 			typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef
-			//if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
 			forall = false;								// reset
 		}
 	  '{' field_declaration_list_opt '}'
-		{ $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); }
-	| aggregate_key attribute_list_opt type_name
+		{ $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $7, true )->addQualifiers( $2 ); }
+	| aggregate_key attribute_list_opt type_name fred
 		{
 			typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef
-			//if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update
 			forall = false;								// reset
 		}
 	  '{' field_declaration_list_opt '}'
-		{ $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $6, true )->addQualifiers( $2 ); }
+		{ $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $7, true )->addQualifiers( $2 ); }
 	| aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA
 		{ $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }
@@ -1846,12 +1849,11 @@
 
 aggregate_type_nobody:									// struct, union - {...}
-	aggregate_key attribute_list_opt no_attr_identifier
+	aggregate_key attribute_list_opt no_attr_identifier fred
 		{
 			typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname );
-			//if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
 			forall = false;								// reset
 			$$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
 		}
-	| aggregate_key attribute_list_opt type_name
+	| aggregate_key attribute_list_opt type_name fred
 		{
 			// Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is
@@ -1867,15 +1869,15 @@
 aggregate_key:
 	STRUCT
-		{ $$ = DeclarationNode::Struct; }
+		{ yyy = true; $$ = DeclarationNode::Struct; }
 	| UNION
-		{ $$ = DeclarationNode::Union; }
+		{ yyy = true; $$ = DeclarationNode::Union; }
 	| EXCEPTION
-		{ $$ = DeclarationNode::Exception; }
+		{ yyy = true; $$ = DeclarationNode::Exception; }
 	| COROUTINE
-		{ $$ = DeclarationNode::Coroutine; }
+		{ yyy = true; $$ = DeclarationNode::Coroutine; }
 	| MONITOR
-		{ $$ = DeclarationNode::Monitor; }
+		{ yyy = true; $$ = DeclarationNode::Monitor; }
 	| THREAD
-		{ $$ = DeclarationNode::Thread; }
+		{ yyy = true; $$ = DeclarationNode::Thread; }
 	;
 
@@ -2320,6 +2322,5 @@
 
 translation_unit:
-	// empty
-		{}												// empty input file
+	// empty, input file
 	| external_definition_list
 		{ parseTree = parseTree ? parseTree->appendList( $1 ) : $1;	}
@@ -2335,22 +2336,16 @@
 	;
 
-	// SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.
-	// However, external_definition_list creates a new scope around each external_definition, but the pop loses all the
-	// types in the extern "X" and distribution at the end of the block. This version of external_definition_list does
-
-	// not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of
-	// external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.
-external_definition_list_no_pop_push:
-	external_definition
-	| external_definition_list_no_pop_push
-		{ forall = xxx; }
-	  external_definition
-		{ $$ = $1 ? $1->appendList( $3 ) : $3; }
-	;
-
 external_definition_list_opt:
 	// empty
 		{ $$ = nullptr; }
-	| external_definition_list_no_pop_push
+	| external_definition_list
+	;
+
+up:
+		{ typedefTable.up(); }
+	;
+
+down:
+		{ typedefTable.down(); }
 	;
 
@@ -2372,15 +2367,18 @@
 			linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
 		}
-	  '{' external_definition_list_opt '}'
+	  '{' up external_definition_list_opt down '}'
 		{
 			linkage = linkageStack.top();
 			linkageStack.pop();
-			$$ = $5;
+			$$ = $6;
 		}
 	| type_qualifier_list
-		{ if ( $1->type->forall ) xxx = forall = true; } // remember generic type
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+		{
+			if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( $1->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) ) {		// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2389,11 +2387,14 @@
  			xxx = false;
 			delete $1;
-			$$ = $4;
+			$$ = $5;
 		}
 	| declaration_qualifier_list
-		{ if ( $1->type->forall ) xxx = forall = true; } // remember generic type
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+		{
+			if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( $1->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) ) {		// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2402,14 +2403,14 @@
  			xxx = false;
 			delete $1;
-			$$ = $4;
+			$$ = $5;
 		}
 	| declaration_qualifier_list type_qualifier_list
 		{
-			// forall must be in the type_qualifier_list
-			if ( $2->type->forall ) xxx = forall = true; // remember generic type
-		}
-	  '{' external_definition_list_opt '}'				// CFA, namespace
-		{
-			for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
+			if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }
+			if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type
+		}
+	  '{' up external_definition_list_opt down '}'		// CFA, namespace
+		{
+			for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
 				if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) {	// ignore extern "C"
 					iter->addQualifiers( $1->clone() );
@@ -2420,5 +2421,5 @@
 			delete $1;
 			delete $2;
-			$$ = $5;
+			$$ = $6;
 		}
 	;
