Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c	(revision 174231)
+++ cp/typeck2.c	(working copy)
@@ -1429,24 +1429,35 @@ build_x_arrow (tree expr)
 
   if (MAYBE_CLASS_TYPE_P (type))
     {
+      struct tinst_level *actual_inst = current_instantiation ();
+      
       while ((expr = build_new_op (COMPONENT_REF, LOOKUP_NORMAL, expr,
 				   NULL_TREE, NULL_TREE,
 				   /*overloaded_p=*/NULL, 
 				   tf_warning_or_error)))
 	{
+	  tree chain_type = TREE_TYPE (expr);
+	  
 	  if (expr == error_mark_node)
 	    return error_mark_node;
 
-	  if (vec_member (TREE_TYPE (expr), types_memoized))
+	  if (vec_member (chain_type, types_memoized))
 	    {
 	      error ("circular pointer delegation detected");
 	      return error_mark_node;
 	    }
+	  
+	  /* For diagnostic purposes, pretend that the chain is nested. */
+	  if (CLASS_TYPE_P (chain_type) && CLASSTYPE_TEMPLATE_INFO (chain_type))
+	    push_tinst_level (chain_type);
 
-	  VEC_safe_push (tree, gc, types_memoized, TREE_TYPE (expr));
+	  VEC_safe_push (tree, gc, types_memoized, chain_type);
 	  last_rval = expr;
 	}
 
+      while (current_instantiation () != actual_inst)
+	pop_tinst_level ();
+      
       if (last_rval == NULL_TREE)
 	{
 	  error ("base operand of %<->%> has non-pointer type %qT", type);
