aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-04-28 08:34:01 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-04-28 08:34:01 +0000
commit4b414c93f0d6e1e70bff5eaca0fb8f066f793883 (patch)
tree8d11fc6717643399c2039596ee4aaf922b4469c5
parent012e6a1e049a8b2706203876ee1418140842fcb3 (diff)
downloadgcc-4b414c93f0d6e1e70bff5eaca0fb8f066f793883.zip
gcc-4b414c93f0d6e1e70bff5eaca0fb8f066f793883.tar.gz
gcc-4b414c93f0d6e1e70bff5eaca0fb8f066f793883.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/error.c89
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/template/pr23510.C2
-rw-r--r--gcc/testsuite/g++.dg/template/recurse.C3
-rw-r--r--gcc/testsuite/g++.dg/template/recurse2.C1
-rw-r--r--gcc/testsuite/lib/prune.exp2
7 files changed, 78 insertions, 34 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6d09c80..03bf79b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+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.
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index b03c83f..4ac70f7 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 ac3d6e6..bb6b97c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/gcc/testsuite/g++.dg/template/pr23510.C b/gcc/testsuite/g++.dg/template/pr23510.C
index a0806e2..b9e9889 100644
--- a/gcc/testsuite/g++.dg/template/pr23510.C
+++ b/gcc/testsuite/g++.dg/template/pr23510.C
@@ -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 }
}
diff --git a/gcc/testsuite/g++.dg/template/recurse.C b/gcc/testsuite/g++.dg/template/recurse.C
index 17fe186..448c347 100644
--- a/gcc/testsuite/g++.dg/template/recurse.C
+++ b/gcc/testsuite/g++.dg/template/recurse.C
@@ -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" }
}
};
diff --git a/gcc/testsuite/g++.dg/template/recurse2.C b/gcc/testsuite/g++.dg/template/recurse2.C
index cf085e0..b9767df 100644
--- a/gcc/testsuite/g++.dg/template/recurse2.C
+++ b/gcc/testsuite/g++.dg/template/recurse2.C
@@ -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>;
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 160f651..769169d 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