aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gcc.gnu.org>2009-12-15 00:20:03 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2009-12-15 00:20:03 +0000
commit6ba6f70d7fa8fa889576172a23c199a51abdd045 (patch)
treecfeb179f5b57de2147e03bd05038051732204246 /gcc/cp
parent9ed796d78bd95091e6715200c029c812047f843c (diff)
downloadgcc-6ba6f70d7fa8fa889576172a23c199a51abdd045.zip
gcc-6ba6f70d7fa8fa889576172a23c199a51abdd045.tar.gz
gcc-6ba6f70d7fa8fa889576172a23c199a51abdd045.tar.bz2
[multiple changes]
2009-12-15 Paolo Bonzini <bonzini@gnu.org> Shujing Zhao <pearly.zhao@oracle.com> * intl.c (get_spaces): New. * intl.h (get_spaces): New. cp: 2009-12-15 Paolo Bonzini <bonzini@gnu.org> Shujing Zhao <pearly.zhao@oracle.com> * Makefile.in (cp/pt.o): Depend on intl.h * call.c (print_z_candidates): Make loop more compact, choose head string depending on number of candidates, extract creation of spaces string to intl.c. * pt.c (print_overloaded_functions): Replace with... (print_candidates_1): ... this rewrite. (print_candidates): Rewrite to call print_candidates_1. (most_specialized_class): Make loop more compact, choose head string depending on number of candidates, and size indents depending on translations. testsuite: 2009-12-15 Shujing Zhao <pearly.zhao@oracle.com> * g++.dg/other/error20.C: Adjust dg-message strings. * g++.dg/other/error31.C: Likewise. * g++.dg/rtti/typeid6.C: Likewise. * g++.dg/ext/ms-1.C: Likewise. * g++.dg/parse/error19.C: Likewise. * g++.dg/parse/crash5.C: Likewise. * g++.dg/cpp0x/explicit4.C: Likewise. * g++.dg/template/ptrmem4.C: Likewise. * g++.dg/template/crash37.C: Likewise. * g++.dg/template/qualttp5.C: Likewise. * g++.dg/template/local6.C: Likewise. * g++.dg/template/instantiate5.C: Likewise. * g++.old-deja/g++.brendan/overload1.C: Likewise. * g++.old-deja/g++.brendan/cvt3.C: Likewise. * g++.old-deja/g++.brendan/overload4.C: Likewise. * g++.old-deja/g++.jason/conversion11.C: Likewise. * g++.old-deja/g++.jason/scoping10.C: Likewise. * g++.old-deja/g++.other/expr1.C: Likewise. * g++.old-deja/g++.other/pmf3.C: Likewise. * g++.old-deja/g++.other/crash24.C: Likewise. * g++.old-deja/g++.niklas/t120.C: Likewise. * g++.old-deja/g++.niklas/t121.C: Likewise. * g++.old-deja/g++.law/operators9.C: Likewise. * g++.old-deja/g++.law/arm9.C: Likewise. * g++.old-deja/g++.law/enum4.C: Likewise. * g++.old-deja/g++.law/arg11.C: Likewise. * g++.old-deja/g++.benjamin/15800-1.C: Likewise. * g++.old-deja/g++.mike/p2431.C: Likewise. * g++.old-deja/g++.mike/p438.C: Likewise. * g++.old-deja/g++.mike/p9068.C: Likewise. * g++.old-deja/g++.mike/p11110.C: Likewise. * g++.old-deja/g++.bugs/900330_02.C: Likewise. From-SVN: r155245
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/Make-lang.in2
-rw-r--r--gcc/cp/call.c24
-rw-r--r--gcc/cp/pt.c76
4 files changed, 75 insertions, 41 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e51641b..bf6ecd8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-15 Paolo Bonzini <bonzini@gnu.org>
+ Shujing Zhao <pearly.zhao@oracle.com>
+
+ * Makefile.in (cp/pt.o): Depend on intl.h
+ * call.c (print_z_candidates): Make loop more compact,
+ choose head string depending on number of candidates,
+ extract creation of spaces string to intl.c.
+ * pt.c (print_overloaded_functions): Replace with...
+ (print_candidates_1): ... this rewrite.
+ (print_candidates): Rewrite to call print_candidates_1.
+ (most_specialized_class): Make loop more compact,
+ choose head string depending on number of candidates,
+ and size indents depending on translations.
+
2009-12-11 Jason Merrill <jason@redhat.com>
PR c++/42219
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 913993a..9b134ed 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -292,7 +292,7 @@ cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) $(FLAGS_H) $(EXPR_H) \
toplev.h except.h $(TM_P_H)
cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/cp-objcp-common.h \
toplev.h $(RTL_H) except.h $(TREE_INLINE_H) pointer-set.h gt-cp-pt.h \
- vecprim.h
+ vecprim.h intl.h
cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_H) \
$(FLAGS_H) $(REAL_H) $(LANGHOOKS_DEF_H) $(CXX_PRETTY_PRINT_H)
cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_H) \
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a6041f5..1f17180 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2730,6 +2730,7 @@ print_z_candidates (struct z_candidate *candidates)
const char *str;
struct z_candidate *cand1;
struct z_candidate **cand2;
+ char *spaces;
if (!candidates)
return;
@@ -2770,25 +2771,14 @@ print_z_candidates (struct z_candidate *candidates)
}
}
- str = _("candidates are:");
- print_z_candidate (str, candidates);
- if (candidates->next)
+ str = candidates->next ? _("candidates are:") : _("candidate is:");
+ spaces = NULL;
+ for (; candidates; candidates = candidates->next)
{
- /* Indent successive candidates by the width of the translation
- of the above string. */
- size_t len = gcc_gettext_width (str) + 1;
- char *spaces = (char *) alloca (len);
- memset (spaces, ' ', len-1);
- spaces[len - 1] = '\0';
-
- candidates = candidates->next;
- do
- {
- print_z_candidate (spaces, candidates);
- candidates = candidates->next;
- }
- while (candidates);
+ print_z_candidate (spaces ? spaces : str, candidates);
+ spaces = spaces ? spaces : get_spaces (str);
}
+ free (spaces);
}
/* USER_SEQ is a user-defined conversion sequence, beginning with a
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6f76d46..68e277e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "obstack.h"
#include "tree.h"
+#include "intl.h"
#include "pointer-set.h"
#include "flags.h"
#include "c-common.h"
@@ -1646,19 +1647,52 @@ explicit_class_specialization_p (tree type)
return !uses_template_parms (CLASSTYPE_TI_ARGS (type));
}
-/* Print the list of overloaded FNS in an error message. */
+/* Print the list of functions at FNS, going through all the overloads
+ for each element of the list. Alternatively, FNS can not be a
+ TREE_LIST, in which case it will be printed together with all the
+ overloads.
+
+ MORE and *STR should respectively be FALSE and NULL when the function
+ is called from the outside. They are used internally on recursive
+ calls. print_candidates manages the two parameters and leaves NULL
+ in *STR when it ends. */
static void
-print_overloaded_functions (tree fns, const char **str)
+print_candidates_1 (tree fns, bool more, const char **str)
{
- tree fn;
+ tree fn, fn2;
+ char *spaces = NULL;
+
for (fn = fns; fn; fn = OVL_NEXT (fn))
+ if (TREE_CODE (fn) == TREE_LIST)
+ {
+ gcc_assert (!OVL_NEXT (fn) && !is_overloaded_fn (fn));
+ for (fn2 = fn; fn2 != NULL_TREE; fn2 = TREE_CHAIN (fn2))
+ print_candidates_1 (TREE_VALUE (fn2),
+ TREE_CHAIN (fn2) || more, str);
+ }
+ else
+ {
+ if (!*str)
+ {
+ /* Pick the prefix string. */
+ if (!more && !OVL_NEXT (fns))
+ {
+ error ("candidate is: %+#D", OVL_CURRENT (fn));
+ continue;
+ }
+
+ *str = _("candidates are:");
+ spaces = get_spaces (*str);
+ }
+ error ("%s %+#D", *str, OVL_CURRENT (fn));
+ *str = spaces ? spaces : *str;
+ }
+
+ if (!more)
{
- if (TREE_CODE (fn) == TREE_LIST)
- print_candidates (fn);
- else
- error ("%s %+#D", *str, OVL_CURRENT (fn));
- *str = " ";
+ free (spaces);
+ *str = NULL;
}
}
@@ -1667,16 +1701,9 @@ print_overloaded_functions (tree fns, const char **str)
void
print_candidates (tree fns)
{
- const char *str = "candidates are:";
-
- if (is_overloaded_fn (fns))
- print_overloaded_functions (fns, &str);
- else
- {
- tree fn;
- for (fn = fns; fn != NULL_TREE; fn = TREE_CHAIN (fn))
- print_overloaded_functions (TREE_VALUE (fn), &str);
- }
+ const char *str = NULL;
+ print_candidates_1 (fns, false, &str);
+ gcc_assert (str == NULL);
}
/* Returns the template (one of the functions given by TEMPLATE_ID)
@@ -15753,13 +15780,16 @@ most_specialized_class (tree type, tree tmpl)
if (ambiguous_p)
{
- const char *str = "candidates are:";
+ const char *str;
+ char *spaces = NULL;
error ("ambiguous class template instantiation for %q#T", type);
+ str = TREE_CHAIN (list) ? _("candidates are:") : _("candidate is:");
for (t = list; t; t = TREE_CHAIN (t))
- {
- error ("%s %+#T", str, TREE_TYPE (t));
- str = " ";
- }
+ {
+ error ("%s %+#T", spaces ? spaces : str, TREE_TYPE (t));
+ spaces = spaces ? spaces : get_spaces (str);
+ }
+ free (spaces);
return error_mark_node;
}