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
This commit is contained in:
parent
681f05d4f0
commit
f89b94d954
@ -1,3 +1,10 @@
|
||||
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>
|
||||
|
||||
PR c++/42824
|
||||
|
101
gcc/cp/error.c
101
gcc/cp/error.c
@ -2728,36 +2728,89 @@ print_instantiation_full_context (diagnostic_context *context)
|
||||
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
|
||||
print_instantiation_partial_context (diagnostic_context *context,
|
||||
struct tinst_level *t, location_t loc)
|
||||
print_instantiation_partial_context_line (diagnostic_context *context,
|
||||
const struct tinst_level *t, location_t loc)
|
||||
{
|
||||
expanded_location xloc;
|
||||
const char *str;
|
||||
for (; ; t = t->next)
|
||||
xloc = expand_location (loc);
|
||||
|
||||
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);
|
||||
if (t == NULL)
|
||||
break;
|
||||
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);
|
||||
int skip = n_total - 10;
|
||||
for (n = 0; n < 5; n++)
|
||||
{
|
||||
gcc_assert (t != NULL);
|
||||
print_instantiation_partial_context_line (context, t, loc);
|
||||
loc = t->locus;
|
||||
t = t->next;
|
||||
}
|
||||
if (skip > 1)
|
||||
{
|
||||
expanded_location xloc;
|
||||
xloc = expand_location (loc);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
print_instantiation_partial_context_line (context, NULL, loc);
|
||||
pp_base_newline (context->printer);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
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>
|
||||
|
||||
PR c++/42824
|
||||
|
23
gcc/testsuite/g++.dg/template/pr23510.C
Normal file
23
gcc/testsuite/g++.dg/template/pr23510.C
Normal file
@ -0,0 +1,23 @@
|
||||
// { 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
|
||||
int operator()()
|
||||
{
|
||||
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" }
|
||||
// { dg-message "skipping 40 instantiation contexts" "" { target *-*-* } 11 }
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user