From: Manuel López-Ibáñez Date: Wed, 28 Apr 2010 08:34:01 +0000 (+0000) Subject: re PR c++/9335 (repeated diagnostic when maximum template depth is exceeded) X-Git-Tag: releases/gcc-4.6.0~7602 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b414c93f0d6e1e70bff5eaca0fb8f066f793883;p=thirdparty%2Fgcc.git re PR c++/9335 (repeated diagnostic when maximum template depth is exceeded) 2010-04-28 Manuel López-Ibáñez 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6d09c80c434b..03bf79b820a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-04-28 Manuel López-Ibáñez + + PR c++/9335 + * error.c (print_instantiation_partial_context_line): Handle + recursive instantiation. + (print_instantiation_partial_context): Likewise. + 2010-04-27 Jason Merrill * init.c (perform_member_init): Check CLASS_TYPE_P. diff --git a/gcc/cp/error.c b/gcc/cp/error.c index b03c83ff152d..4ac70f74b69a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac3d6e63021c..bb6b97ce7b26 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2010-04-28 Manuel López-Ibáñez + + 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 PR c++/29043 diff --git a/gcc/testsuite/g++.dg/template/pr23510.C b/gcc/testsuite/g++.dg/template/pr23510.C index a0806e245c59..b9e9889e9c0f 100644 --- a/gcc/testsuite/g++.dg/template/pr23510.C +++ b/gcc/testsuite/g++.dg/template/pr23510.C @@ -4,7 +4,7 @@ template struct Factorial { enum { nValue = nFactor * Factorial::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 } } diff --git a/gcc/testsuite/g++.dg/template/recurse.C b/gcc/testsuite/g++.dg/template/recurse.C index 17fe1866eb20..448c34721c21 100644 --- a/gcc/testsuite/g++.dg/template/recurse.C +++ b/gcc/testsuite/g++.dg/template/recurse.C @@ -8,8 +8,7 @@ template struct F F 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" } } }; diff --git a/gcc/testsuite/g++.dg/template/recurse2.C b/gcc/testsuite/g++.dg/template/recurse2.C index cf085e0d553b..b9767dfb600d 100644 --- a/gcc/testsuite/g++.dg/template/recurse2.C +++ b/gcc/testsuite/g++.dg/template/recurse2.C @@ -3,5 +3,6 @@ template struct X { static const int value = X::value; // { dg-error "instantiation|incomplete" } + // { dg-message "recursively instantiated" "" { target *-*-* } 5 } }; template struct X<1000>; diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp index 160f651b6e76..769169d4271b 100644 --- a/gcc/testsuite/lib/prune.exp +++ b/gcc/testsuite/lib/prune.exp @@ -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