re PR c++/44783 (implement -ftemplate-backtrace-limit=)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Thu, 15 Mar 2012 09:57:29 +0000 (09:57 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 15 Mar 2012 09:57:29 +0000 (09:57 +0000)
/c-family
2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/44783
* c.opt (ftemplate-backtrace-limit) Add.

/cp
2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/44783
* error.c (print_instantiation_partial_context): Use
template_backtrace_limit.

/doc
2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/44783
* doc/invoke.texi [C++ Language Options]: Document
-ftemplate-backtrace-limit.

From-SVN: r185424

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/cp/ChangeLog
gcc/cp/error.c
gcc/doc/invoke.texi

index fff00bd..fcd2c2e 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/44783
+       * doc/invoke.texi [C++ Language Options]: Document
+       -ftemplate-backtrace-limit.
+
 2012-03-15  Tristan Gingold  <gingold@adacore.com>
 
        * c-parser.c (c_parser_parameter_declaration): Handle #pragma
index b5085cd..274eacd 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/44783
+       * c.opt (ftemplate-backtrace-limit) Add.
+
 2012-03-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * c-cppbuiltin.c (c_cpp_builtins): Remove #pragma extern_prefix
index 40ff96c..a14514a 100644 (file)
@@ -1035,6 +1035,10 @@ 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)
+Set the maximum number of template instantiation notes for a single warning or error
+
 ftemplate-depth-
 C++ ObjC++ Joined RejectNegative Undocumented Alias(ftemplate-depth=)
 
index 4c99dec..f4f46fe 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/44783
+       * error.c (print_instantiation_partial_context): Use
+       template_backtrace_limit.
+
 2012-03-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * Make-lang.in (doc/g++.1): Remove IRIX 6.5 reference.
 
        PR c++/51641
        * cp-tree.h (template_type_parameter_p): Declare new function.
-       (parameter_of_template_p): Remove
-       * pt.c (template_type_parameter_p): Define new function.
        (parameter_of_template_p): Remove.
-       * name-lookup.c (binding_to_template_parms_of_scope_p): Don't rely
+       * pt.c (template_type_parameter_p): Define new function.
+       (parameter_of_template_p): Remove.
+       * name-lookup.c (binding_to_template_parms_of_scope_p): Don't rely
        on parameter_of_template_p anymore.  Compare the level of the
        template parameter to the depth of the template.
 
index 4ec263b..ee8f0e0 100644 (file)
@@ -3076,10 +3076,20 @@ print_instantiation_partial_context (diagnostic_context *context,
 
   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;
+      int head = template_backtrace_limit / 2;
+
+      /* Avoid skipping just 1.  If so, skip 2.  */
+      if (skip == 1)
+       {
+         skip = 2;
+         head = (template_backtrace_limit - 1) / 2;
+       }
+     
+      for (n = 0; n < head; n++)
        {
          gcc_assert (t != NULL);
          if (loc != t->locus)
@@ -3088,17 +3098,19 @@ print_instantiation_partial_context (diagnostic_context *context,
          loc = t->locus;
          t = t->next;
        }
-      if (t != NULL && skip > 1)
+      if (t != NULL && skip > 0)
        {
          expanded_location xloc;
          xloc = expand_location (loc);
          if (context->show_column)
            pp_verbatim (context->printer,
-                        _("%s:%d:%d:   [ skipping %d instantiation contexts ]\n"),
+                        _("%s:%d:%d:   [ skipping %d instantiation contexts, "
+                          "use -ftemplate-backtrace-limit=0 to disable ]\n"),
                         xloc.file, xloc.line, xloc.column, skip);
          else
            pp_verbatim (context->printer,
-                        _("%s:%d:   [ skipping %d instantiation contexts ]\n"),
+                        _("%s:%d:   [ skipping %d instantiation contexts, "
+                          "use -ftemplate-backtrace-limit=0 to disable ]\n"),
                         xloc.file, xloc.line, skip);
          
          do {
index cf23ced..8571a8b 100644 (file)
@@ -192,7 +192,8 @@ in the following sections.
 -fno-nonansi-builtins  -fnothrow-opt  -fno-operator-names @gol
 -fno-optional-diags  -fpermissive @gol
 -fno-pretty-templates @gol
--frepo  -fno-rtti  -fstats  -ftemplate-depth=@var{n} @gol
+-frepo  -fno-rtti  -fstats  -ftemplate-backtrace-limit=@var{n} @gol
+-ftemplate-depth=@var{n} @gol
 -fno-threadsafe-statics -fuse-cxa-atexit  -fno-weak  -nostdinc++ @gol
 -fno-default-inline  -fvisibility-inlines-hidden @gol
 -fvisibility-ms-compat @gol
@@ -2124,6 +2125,11 @@ represented in the minimum number of bits needed to represent all the
 enumerators).  This assumption may not be valid if the program uses a
 cast to convert an arbitrary integer value to the enumerated type.
 
+@item -ftemplate-backtrace-limit=@var{n}
+@opindex ftemplate-backtrace-limit
+Set the maximum number of template instantiation notes for a single
+warning or error to @var{n}.  The default value is 10.
+
 @item -ftemplate-depth=@var{n}
 @opindex ftemplate-depth
 Set the maximum instantiation depth for template classes to @var{n}.