------- Comment #6 from manu at gcc dot gnu dot org  2010-02-19 01:49 -------
The following patch seems to do the trick:
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c      (revision 150311)
+++ gcc/cp/error.c      (working copy)
@@ -2707,31 +2707,83 @@ print_instantiation_full_context (diagno
 }

 /* Same as above but less verbose.  */
 static void
 print_instantiation_partial_context (diagnostic_context *context,
-                                    struct tinst_level *t, location_t loc)
+                                    struct tinst_level *t0, location_t loc)
 {
+  struct tinst_level *t;
   expanded_location xloc;
   const char *str;
-  for (; ; t = t->next)
+  int n_total = 0;
+  int n;
+  int skip = 0;
+
+  xloc = expand_location (loc);
+
+  for (t = t0; t != NULL; t = t->next)
+    n_total++;
+
+  t = t0;
+
+  if (n_total >= 12)
+    {
+      skip = n_total - 10;
+      for (n = 0; n < 5; n++)
+       {
+         gcc_assert (t != NULL);
+         str = decl_as_string_translate (t->decl,
+                                         TFF_DECL_SPECIFIERS |
TFF_RETURN_TYPE);
+         if (flag_show_column)
+           pp_verbatim (context->printer,
+                        _("%s:%d:%d:   instantiated from %qs\n"),
+                        xloc.file, xloc.line, xloc.column, str);
+         else
+           pp_verbatim (context->printer,
+                        _("%s:%d:   instantiated from %qs\n"),
+                        xloc.file, xloc.line, str);
+         loc = t->locus;
+         xloc = expand_location (loc);
+         t = t->next;
+       }
+    }
+
+  if (skip)
+    {
+      if (flag_show_column)
+       pp_verbatim (context->printer,
+                    _("%s:%d:%d:   [ skipping %d instantiation contexts ]\n"),
+                    xloc.file, xloc.line, xloc.column, skip);
+      else
+       pp_verbatim (context->printer,
+                    _("%s:%d:   [ skipping %d instantiation contexts ]\n"),
+                    xloc.file, xloc.line, skip);
+
+      while (skip-- > 0)
+       {
+         loc = t->locus;
+         xloc = expand_location (loc);
+         t = t->next;
+       }
+    }
+
+  for (; t != NULL; t = t->next)
     {
-      xloc = expand_location (loc);
-      if (t == NULL)
-       break;
       str = decl_as_string_translate (t->decl,
-                                     TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
+                                     TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
       if (flag_show_column)
        pp_verbatim (context->printer,
                     _("%s:%d:%d:   instantiated from %qs\n"),
                     xloc.file, xloc.line, xloc.column, str);
       else
        pp_verbatim (context->printer,
                     _("%s:%d:   instantiated from %qs\n"),
                     xloc.file, xloc.line, str);
       loc = t->locus;
+      xloc = expand_location (loc);
     }
+
   if (flag_show_column)
     pp_verbatim (context->printer, _("%s:%d:%d:   instantiated from here"),
                 xloc.file, xloc.line, xloc.column);
   else
     pp_verbatim (context->printer, _("%s:%d:   instantiated from here"),


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|gdr at gcc dot gnu dot org  |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9335

Reply via email to