public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/9335] Inordinately long output when maximum template depth is exceeded
Date: Fri, 19 Feb 2010 01:49:00 -0000	[thread overview]
Message-ID: <20100219014930.25231.qmail@sourceware.org> (raw)
In-Reply-To: <bug-9335-180@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2010-02-19  1:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-9335-180@http.gcc.gnu.org/bugzilla/>
2010-02-18 14:19 ` paolo dot carlini at oracle dot com
2010-02-19  1:49 ` manu at gcc dot gnu dot org [this message]
2010-02-19  1:54 ` paolo dot carlini at oracle dot com
2010-02-19  1:54 ` manu at gcc dot gnu dot org
2010-02-19  1:59 ` manu at gcc dot gnu dot org
2010-02-19  2:03 ` manu at gcc dot gnu dot org
2010-02-19  9:16 ` paolo dot carlini at oracle dot com
2010-02-20  1:55 ` [Bug c++/9335] repeated diagnostic " manu at gcc dot gnu dot org
2010-04-13 23:48 ` manu at gcc dot gnu dot org
2010-04-14  1:41 ` jason at gcc dot gnu dot org
2010-04-14 10:10 ` lopezibanez at gmail dot com
2010-04-16 22:07 ` jason at gcc dot gnu dot org
2010-04-16 22:24 ` manu at gcc dot gnu dot org
2010-04-17  3:53 ` jason at gcc dot gnu dot org
2010-04-17  7:59 ` manu at gcc dot gnu dot org
2010-04-18 14:42 ` jason at gcc dot gnu dot org
2010-04-18 16:17 ` manu at gcc dot gnu dot org
2010-04-18 17:10 ` jason at gcc dot gnu dot org
2010-04-18 17:40 ` manu at gcc dot gnu dot org
2010-04-18 22:35 ` [Bug c++/9335] [4.3/4.4/4.5/4.6 regression] " jason at gcc dot gnu dot org
2010-04-21  6:07 ` jason at gcc dot gnu dot org
2010-04-28  8:34 ` manu at gcc dot gnu dot org
2010-04-28  8:40 ` manu at gcc dot gnu dot org
2010-04-28 18:50 ` jason at gcc dot gnu dot org
     [not found] <20030115143600.9335.bangerth@ticam.utexas.edu>
2005-09-14 15:36 ` [Bug c++/9335] Inordinately long output " bangerth at dealii dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100219014930.25231.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).