re PR c++/23510 (skip some instantation contexts if there are too many)

2010-02-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/23510
cp/
	* error.c (print_instantiation_partial_context_line): New.
	(print_instantiation_partial_context): Print at most 12 contexts,
	skip the rest with a message.
testsuite/
	* g++.dg/template/recurse.C: Adjust.
	* g++.dg/template/pr23510.C: New.

From-SVN: r156942
parent 681f05d4
2010-02-21 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/23510
* error.c (print_instantiation_partial_context_line): New.
(print_instantiation_partial_context): Print at most 12 contexts,
skip the rest with a message.
2010-02-21 Dodji Seketeli <dodji@redhat.com> 2010-02-21 Dodji Seketeli <dodji@redhat.com>
PR c++/42824 PR c++/42824
......
...@@ -2728,36 +2728,89 @@ print_instantiation_full_context (diagnostic_context *context) ...@@ -2728,36 +2728,89 @@ print_instantiation_full_context (diagnostic_context *context)
print_instantiation_partial_context (context, p, location); print_instantiation_partial_context (context, p, location);
} }
/* Same as above but less verbose. */ /* Helper function of print_instantiation_partial_context() that
prints a single line of instantiation context. */
static void static void
print_instantiation_partial_context (diagnostic_context *context, print_instantiation_partial_context_line (diagnostic_context *context,
struct tinst_level *t, location_t loc) const struct tinst_level *t, location_t loc)
{ {
expanded_location xloc; expanded_location xloc;
const char *str; xloc = expand_location (loc);
for (; ; t = t->next)
if (t != NULL) {
const char *str;
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);
} else {
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"),
xloc.file, xloc.line);
}
}
/* Same as print_instantiation_full_context but less verbose. */
static void
print_instantiation_partial_context (diagnostic_context *context,
struct tinst_level *t0, location_t loc)
{
struct tinst_level *t;
int n_total = 0;
int n;
for (t = t0; t != NULL; t = t->next)
n_total++;
t = t0;
if (n_total >= 12)
{ {
xloc = expand_location (loc); int skip = n_total - 10;
if (t == NULL) for (n = 0; n < 5; n++)
break; {
str = decl_as_string_translate (t->decl, gcc_assert (t != NULL);
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE); print_instantiation_partial_context_line (context, t, loc);
if (flag_show_column) loc = t->locus;
pp_verbatim (context->printer, t = t->next;
_("%s:%d:%d: instantiated from %qs\n"), }
xloc.file, xloc.line, xloc.column, str); if (skip > 1)
else {
pp_verbatim (context->printer, expanded_location xloc;
_("%s:%d: instantiated from %qs\n"), xloc = expand_location (loc);
xloc.file, xloc.line, str); 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);
do {
loc = t->locus;
t = t->next;
} while (--skip > 0);
}
}
for (; t != NULL; t = t->next)
{
print_instantiation_partial_context_line (context, t, loc);
loc = t->locus; loc = t->locus;
} }
if (flag_show_column) print_instantiation_partial_context_line (context, NULL, loc);
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"),
xloc.file, xloc.line);
pp_base_newline (context->printer); pp_base_newline (context->printer);
} }
......
2010-02-21 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/23510
* g++.dg/template/recurse.C: Adjust.
* g++.dg/template/pr23510.C: New.
2010-02-21 Dodji Seketeli <dodji@redhat.com> 2010-02-21 Dodji Seketeli <dodji@redhat.com>
PR c++/42824 PR c++/42824
......
// { dg-do compile }
// { dg-options "-ftemplate-depth-15" }
template<unsigned int nFactor>
struct Factorial
{
enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" }
// { dg-message "skipping 5 instantiation contexts" "" { target *-*-* } 6 }
// { dg-error "incomplete type" "" { target *-*-* } 6 }
}
template<> // { dg-error "expected" }
struct Factorial<0>
{
enum { nValue = 1 };
}
static const unsigned int FACTOR = 20;
int main()
{
Factorial<FACTOR>::nValue;
return 0;
}
...@@ -6,8 +6,10 @@ template <int I> struct F ...@@ -6,8 +6,10 @@ template <int I> struct F
int operator()() int operator()()
{ {
F<I+1> f; // { dg-error "incomplete type" "incomplete" } F<I+1> f; // { dg-error "incomplete type" "incomplete" }
// { dg-error "exceeds maximum" "exceeds" { target *-*-* } 8 } // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
// { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
return f()*I; // { dg-message "instantiated" "recurse" } return f()*I; // { dg-message "instantiated" "recurse" }
// { dg-message "skipping 40 instantiation contexts" "" { target *-*-* } 11 }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment