re PR c++/9335 (repeated diagnostic when maximum template depth is exceeded)

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

	PR c++/9335
cp/
        * error.c (print_instantiation_partial_context_line): Handle
	recursive instantiation.
        (print_instantiation_partial_context): Likewise.

testsuite/
        * g++.dg/template/recurse2.C: Update
        * g++.dg/template/recurse.C: Update.
        * g++.dg/template/pr23510.C: Update.
        * lib/prune.exp: Filter out 'recursively instantiated'.

From-SVN: r158823
parent 012e6a1e
2010-04-28 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/9335
* error.c (print_instantiation_partial_context_line): Handle
recursive instantiation.
(print_instantiation_partial_context): Likewise.
2010-04-27 Jason Merrill <jason@redhat.com> 2010-04-27 Jason Merrill <jason@redhat.com>
* init.c (perform_member_init): Check CLASS_TYPE_P. * init.c (perform_member_init): Check CLASS_TYPE_P.
......
...@@ -2733,31 +2733,45 @@ print_instantiation_full_context (diagnostic_context *context) ...@@ -2733,31 +2733,45 @@ print_instantiation_full_context (diagnostic_context *context)
static void static void
print_instantiation_partial_context_line (diagnostic_context *context, print_instantiation_partial_context_line (diagnostic_context *context,
const struct tinst_level *t, location_t loc) const struct tinst_level *t,
location_t loc, bool recursive_p)
{ {
expanded_location xloc; expanded_location xloc;
xloc = expand_location (loc); xloc = expand_location (loc);
if (t != NULL) { if (t != NULL)
const char *str; {
str = decl_as_string_translate (t->decl, const char *str;
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE); str = decl_as_string_translate (t->decl,
if (flag_show_column) TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
pp_verbatim (context->printer, if (flag_show_column)
_("%s:%d:%d: instantiated from %qs\n"), pp_verbatim (context->printer,
xloc.file, xloc.line, xloc.column, str); recursive_p
else ? _("%s:%d:%d: recursively instantiated from %qs\n")
pp_verbatim (context->printer, : _("%s:%d:%d: instantiated from %qs\n"),
_("%s:%d: instantiated from %qs\n"), xloc.file, xloc.line, xloc.column, str);
xloc.file, xloc.line, str); else
} else { pp_verbatim (context->printer,
if (flag_show_column) recursive_p
pp_verbatim (context->printer, _("%s:%d:%d: instantiated from here"), ? _("%s:%d: recursively instantiated from %qs\n")
xloc.file, xloc.line, xloc.column); : _("%s:%d: recursively instantiated from %qs\n"),
else xloc.file, xloc.line, str);
pp_verbatim (context->printer, _("%s:%d: instantiated from here"), }
xloc.file, xloc.line); else
} {
if (flag_show_column)
pp_verbatim (context->printer,
recursive_p
? _("%s:%d:%d: recursively instantiated from here")
: _("%s:%d:%d: instantiated from here"),
xloc.file, xloc.line, xloc.column);
else
pp_verbatim (context->printer,
recursive_p
? _("%s:%d: recursively instantiated from here")
: _("%s:%d: instantiated from here"),
xloc.file, xloc.line);
}
} }
/* Same as print_instantiation_full_context but less verbose. */ /* Same as print_instantiation_full_context but less verbose. */
...@@ -2769,9 +2783,14 @@ print_instantiation_partial_context (diagnostic_context *context, ...@@ -2769,9 +2783,14 @@ print_instantiation_partial_context (diagnostic_context *context,
struct tinst_level *t; struct tinst_level *t;
int n_total = 0; int n_total = 0;
int n; int n;
location_t prev_loc = loc;
for (t = t0; t != NULL; t = t->next) for (t = t0; t != NULL; t = t->next)
n_total++; if (prev_loc != t->locus)
{
prev_loc = t->locus;
n_total++;
}
t = t0; t = t0;
...@@ -2781,11 +2800,13 @@ print_instantiation_partial_context (diagnostic_context *context, ...@@ -2781,11 +2800,13 @@ print_instantiation_partial_context (diagnostic_context *context,
for (n = 0; n < 5; n++) for (n = 0; n < 5; n++)
{ {
gcc_assert (t != NULL); gcc_assert (t != NULL);
print_instantiation_partial_context_line (context, t, loc); if (loc != t->locus)
print_instantiation_partial_context_line (context, t, loc,
/*recursive_p=*/false);
loc = t->locus; loc = t->locus;
t = t->next; t = t->next;
} }
if (skip > 1) if (t != NULL && skip > 1)
{ {
expanded_location xloc; expanded_location xloc;
xloc = expand_location (loc); xloc = expand_location (loc);
...@@ -2799,18 +2820,26 @@ print_instantiation_partial_context (diagnostic_context *context, ...@@ -2799,18 +2820,26 @@ print_instantiation_partial_context (diagnostic_context *context,
xloc.file, xloc.line, skip); xloc.file, xloc.line, skip);
do { do {
loc = t->locus; loc = t->locus;
t = t->next; t = t->next;
} while (--skip > 0); } while (t != NULL && --skip > 0);
} }
} }
for (; t != NULL; t = t->next) while (t != NULL)
{ {
print_instantiation_partial_context_line (context, t, loc); while (t->next != NULL && t->locus == t->next->locus)
{
loc = t->locus;
t = t->next;
}
print_instantiation_partial_context_line (context, t, loc,
t->locus == loc);
loc = t->locus; loc = t->locus;
t = t->next;
} }
print_instantiation_partial_context_line (context, NULL, loc); print_instantiation_partial_context_line (context, NULL, loc,
/*recursive_p=*/false);
pp_base_newline (context->printer); pp_base_newline (context->printer);
} }
......
2010-04-28 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/9335
* g++.dg/template/recurse2.C: Update
* g++.dg/template/recurse.C: Update.
* g++.dg/template/pr23510.C: Update.
* lib/prune.exp: Filter out 'recursively instantiated'.
2010-04-27 Fabien Chêne <fabien.chene@gmail.com> 2010-04-27 Fabien Chêne <fabien.chene@gmail.com>
PR c++/29043 PR c++/29043
......
...@@ -4,7 +4,7 @@ template<unsigned int nFactor> ...@@ -4,7 +4,7 @@ template<unsigned int nFactor>
struct Factorial struct Factorial
{ {
enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" } enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" }
// { dg-message "skipping 5 instantiation contexts" "" { target *-*-* } 6 } // { dg-message "recursively instantiated" "" { target *-*-* } 6 }
// { dg-error "incomplete type" "" { target *-*-* } 6 } // { dg-error "incomplete type" "" { target *-*-* } 6 }
} }
......
...@@ -8,8 +8,7 @@ template <int I> struct F ...@@ -8,8 +8,7 @@ template <int I> struct F
F<I+1> f; // { dg-error "incomplete type" "incomplete" } F<I+1> f; // { dg-error "incomplete type" "incomplete" }
// { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 } // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
// { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 } // { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
return f()*I; // { dg-message "instantiated" "recurse" } return f()*I; // { dg-message "recursively instantiated" "recurse" }
// { dg-message "skipping 40 instantiation contexts" "" { target *-*-* } 11 }
} }
}; };
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
template <int N> struct X { template <int N> struct X {
static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" } static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" }
// { dg-message "recursively instantiated" "" { target *-*-* } 5 }
}; };
template struct X<1000>; template struct X<1000>;
...@@ -22,7 +22,7 @@ proc prune_gcc_output { text } { ...@@ -22,7 +22,7 @@ proc prune_gcc_output { text } {
regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|program|subroutine|block-data)\[^\n\]*" $text "" text regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|program|subroutine|block-data)\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: instantiated from \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: (recursively )?instantiated from \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text
regsub -all "(^|\n) inlined from \[^\n\]*" $text "" text regsub -all "(^|\n) inlined from \[^\n\]*" $text "" text
regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text
......
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