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>
* init.c (perform_member_init): Check CLASS_TYPE_P.
......
......@@ -2733,31 +2733,45 @@ print_instantiation_full_context (diagnostic_context *context)
static void
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;
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);
}
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,
recursive_p
? _("%s:%d:%d: recursively instantiated from %qs\n")
: _("%s:%d:%d: instantiated from %qs\n"),
xloc.file, xloc.line, xloc.column, str);
else
pp_verbatim (context->printer,
recursive_p
? _("%s:%d: recursively instantiated from %qs\n")
: _("%s:%d: recursively instantiated from %qs\n"),
xloc.file, xloc.line, str);
}
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. */
......@@ -2769,9 +2783,14 @@ print_instantiation_partial_context (diagnostic_context *context,
struct tinst_level *t;
int n_total = 0;
int n;
location_t prev_loc = loc;
for (t = t0; t != NULL; t = t->next)
n_total++;
if (prev_loc != t->locus)
{
prev_loc = t->locus;
n_total++;
}
t = t0;
......@@ -2781,11 +2800,13 @@ print_instantiation_partial_context (diagnostic_context *context,
for (n = 0; n < 5; n++)
{
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;
t = t->next;
}
if (skip > 1)
if (t != NULL && skip > 1)
{
expanded_location xloc;
xloc = expand_location (loc);
......@@ -2799,18 +2820,26 @@ print_instantiation_partial_context (diagnostic_context *context,
xloc.file, xloc.line, skip);
do {
loc = t->locus;
t = t->next;
} while (--skip > 0);
loc = t->locus;
t = t->next;
} 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;
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);
}
......
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>
PR c++/29043
......
......@@ -4,7 +4,7 @@ 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-message "recursively instantiated" "" { target *-*-* } 6 }
// { dg-error "incomplete type" "" { target *-*-* } 6 }
}
......
......@@ -8,8 +8,7 @@ template <int I> struct F
F<I+1> f; // { dg-error "incomplete type" "incomplete" }
// { 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 }
return f()*I; // { dg-message "recursively instantiated" "recurse" }
}
};
......
......@@ -3,5 +3,6 @@
template <int N> struct X {
static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" }
// { dg-message "recursively instantiated" "" { target *-*-* } 5 }
};
template struct X<1000>;
......@@ -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\]*(: )?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) inlined from \[^\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