aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-02-21 21:20:04 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-02-21 21:20:04 +0000
commitf89b94d954b87c1b90293d14f1ca1ed15d2ee8f1 (patch)
tree1a705e9468f4fd9553bcd09117ccf45e69d324ec /gcc
parent681f05d4f0195b8566bdc0c985afb6ac4cd95069 (diff)
downloadgcc-f89b94d954b87c1b90293d14f1ca1ed15d2ee8f1.zip
gcc-f89b94d954b87c1b90293d14f1ca1ed15d2ee8f1.tar.gz
gcc-f89b94d954b87c1b90293d14f1ca1ed15d2ee8f1.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/error.c101
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/template/pr23510.C23
-rw-r--r--gcc/testsuite/g++.dg/template/recurse.C4
5 files changed, 116 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2ce5e02..e933965 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 3d9f142..b03c83f 100644
--- a/gcc/cp/error.c
+++ b/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);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc94d47..7db619e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/template/pr23510.C b/gcc/testsuite/g++.dg/template/pr23510.C
new file mode 100644
index 0000000..a0806e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr23510.C
@@ -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;
+}
diff --git a/gcc/testsuite/g++.dg/template/recurse.C b/gcc/testsuite/g++.dg/template/recurse.C
index 25552d0..17fe186 100644
--- a/gcc/testsuite/g++.dg/template/recurse.C
+++ b/gcc/testsuite/g++.dg/template/recurse.C
@@ -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 }
}
};