[Bug c++/44783] implement -ftemplate-backtrace-limit=

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 13 17:11:00 GMT 2012


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

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-02-13 17:09:50 UTC ---
Any of you has a minimal self-contained testcase? The ones I used when
implementing this, no longer need this option. Thanks.

This is my totally untested but compiles patch. Probably it needs some tuning.


Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt  (revision 184150)
+++ gcc/c-family/c.opt  (working copy)
@@ -1033,10 +1033,14 @@ C++ ObjC++ Ignore Warn(switch %qs is no 

 ftabstop=
 C ObjC C++ ObjC++ Joined RejectNegative UInteger
 -ftabstop=<number>     Distance between tab stops for column reporting

+ftemplate-backtrace-limit=
+C++ ObjC++ Joined RejectNegative UInteger Var(template_backtrace_limit)
Init(10)
+Specify number of template instantiations notes for a single warning or error
+
 ftemplate-depth-
 C++ ObjC++ Joined RejectNegative Undocumented Alias(ftemplate-depth=)

 ftemplate-depth=
 C++ ObjC++ Joined RejectNegative UInteger
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c      (revision 184150)
+++ gcc/cp/error.c      (working copy)
@@ -3072,14 +3072,15 @@ print_instantiation_partial_context (dia
        n_total++;
       }

   t = t0;

-  if (n_total >= 12) 
+  if (template_backtrace_limit &&
+      n_total > template_backtrace_limit) 
     {
-      int skip = n_total - 10;
-      for (n = 0; n < 5; n++)
+      int skip = n_total - template_backtrace_limit;
+      for (n = 0; n < template_backtrace_limit/2; n++)
        {
          gcc_assert (t != NULL);
          if (loc != t->locus)
            print_instantiation_partial_context_line (context, t, loc,
                                                      /*recursive_p=*/false);



More information about the Gcc-bugs mailing list