Index: src/Concurrency/Keywords.cc
===================================================================
--- src/Concurrency/Keywords.cc	(revision 6b0b624129f6017f7706b516a24a52e382e3a334)
+++ src/Concurrency/Keywords.cc	(revision 6ac5223ca2769b2152cbf9b708c56f96dff5d8c4)
@@ -200,5 +200,5 @@
 		std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
 		void validate( DeclarationWithType * );
-		void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);
+		void addStatments( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
 
 		static void implement( std::list< Declaration * > & translationUnit ) {
@@ -210,5 +210,14 @@
 	  	StructDecl* monitor_decl = nullptr;
 		StructDecl* guard_decl = nullptr;
+
+		static std::unique_ptr< Type > generic_func;
 	};
+
+	std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >(
+		new FunctionType(
+			noQualifiers,
+			true
+		)
+	);
 
 	//-----------------------------------------------------------------------------
@@ -394,4 +403,5 @@
 	// Mutex keyword implementation
 	//=============================================================================================
+
 	void MutexKeyword::visit(FunctionDecl* decl) {
 		Visitor::visit(decl);
@@ -410,5 +420,5 @@
 		if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
 
-		addStatments( body, mutexArgs );
+		addStatments( decl, body, mutexArgs );
 	}
 
@@ -456,5 +466,5 @@
 	}
 
-	void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
+	void MutexKeyword::addStatments( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
 		ObjectDecl * monitors = new ObjectDecl(
 			"__monitors",
@@ -487,6 +497,8 @@
 		);
 
+		assert(generic_func);
+
 		//in reverse order :
-		// monitor_guard_t __guard = { __monitors, # };
+		// monitor_guard_t __guard = { __monitors, #, func };
 		body->push_front(
 			new DeclStmt( noLabels, new ObjectDecl(
@@ -502,5 +514,6 @@
 					{
 						new SingleInit( new VariableExpr( monitors ) ),
-						new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
+						new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ),
+						new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )
 					},
 					noDesignators,
