Index: src/Parser/DeclarationNode.cc
===================================================================
--- src/Parser/DeclarationNode.cc	(revision 9e1eabcd0b1110ea5a76cdd8b2b483675b207071)
+++ src/Parser/DeclarationNode.cc	(revision c38ae927de4734c94eb69a436cca8cc25a347b02)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 12:34:05 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Sep 23 18:16:48 2017
-// Update Count     : 1024
+// Last Modified On : Mon Nov 20 09:21:52 2017
+// Update Count     : 1031
 //
 
@@ -509,16 +509,13 @@
 
 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) {
-	if ( ! q ) { delete q; return this; }
+	if ( ! q ) { delete q; return this; }				// empty qualifier
 
 	checkSpecifiers( q );
 	copySpecifiers( q );
 
-	if ( ! q->type ) {
-		delete q;
-		return this;
-	} // if
+	if ( ! q->type ) { delete q; return this; }
 
 	if ( ! type ) {
-		type = q->type;									// reuse this structure
+		type = q->type;									// reuse structure
 		q->type = nullptr;
 		delete q;
@@ -526,17 +523,21 @@
 	} // if
 
-	if ( q->type->forall ) {
-		if ( type->forall ) {
-			type->forall->appendList( q->type->forall );
+	if ( q->type->forall ) {							// forall qualifier ?
+		if ( type->forall ) {							// polymorphic routine ?
+			type->forall->appendList( q->type->forall ); // augment forall qualifier
 		} else {
-			if ( type->kind == TypeData::Aggregate ) {
-				type->aggregate.params = q->type->forall;
-				// change implicit typedef from TYPEDEFname to TYPEGENname
-				typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
-			} else {
-				type->forall = q->type->forall;
+			if ( type->kind == TypeData::Aggregate ) {	// struct/union ?
+				if ( type->aggregate.params ) {			// polymorphic ?
+					type->aggregate.params->appendList( q->type->forall ); // augment forall qualifier
+				} else {								// not polymorphic
+					type->aggregate.params = q->type->forall; // make polymorphic type
+					// change implicit typedef from TYPEDEFname to TYPEGENname
+					typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
+				} // if
+			} else {									// not polymorphic
+				type->forall = q->type->forall;			// make polymorphic routine
 			} // if
 		} // if
-		q->type->forall = nullptr;
+		q->type->forall = nullptr;						// forall qualifier moved
 	} // if
 
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision 9e1eabcd0b1110ea5a76cdd8b2b483675b207071)
+++ src/Parser/parser.yy	(revision c38ae927de4734c94eb69a436cca8cc25a347b02)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Nov 17 11:38:57 2017
-// Update Count     : 2914
+// Last Modified On : Mon Nov 20 09:45:36 2017
+// Update Count     : 2945
 //
 
@@ -114,4 +114,16 @@
 	} // for
 } // distExt
+
+// There is an ambiguity for inline generic-routine return-types and generic routines.
+//   forall( otype T ) struct S { int i; } bar( T ) {}
+// Does the forall bind to the struct or the routine, and how would it be possible to explicitly specify the binding.
+//   forall( otype T ) struct S { int T; } forall( otype W ) bar( W ) {}
+
+void rebindForall( DeclarationNode * declSpec, DeclarationNode * funcDecl ) {
+	if ( declSpec->type->kind == TypeData::Aggregate ) { // return is aggregate definition
+		funcDecl->type->forall = declSpec->type->aggregate.params; // move forall from aggregate to function type
+		declSpec->type->aggregate.params = nullptr;
+	} // if
+} // rebindForall
 
 bool forall = false;									// aggregate have one or more forall qualifiers ?
@@ -2401,4 +2413,5 @@
 	| declaration_specifier function_declarator with_clause_opt compound_statement
 		{
+			rebindForall( $1, $2 );
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
@@ -2427,4 +2440,5 @@
 	| declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
 		{
+			rebindForall( $1, $2 );
 			typedefTable.addToEnclosingScope( TypedefTable::ID );
 			typedefTable.leaveScope();
