aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/error.c14
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6ffebf1..692a95b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-04 Jason Merrill <jason@redhat.com>
+
+ * error.c (type_to_string): Avoid redundant akas.
+
2011-07-01 Jonathan Wakely <jwakely.gcc@gmail.com>
PR c++/49605
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 7c90ec4..664b918 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2634,14 +2634,28 @@ type_to_string (tree typ, int verbose)
reinit_cxx_pp ();
dump_type (typ, flags);
+ /* If we're printing a type that involves typedefs, also print the
+ stripped version. But sometimes the stripped version looks
+ exactly the same, so we don't want it after all. To avoid printing
+ it in that case, we play ugly obstack games. */
if (typ && TYPE_P (typ) && typ != TYPE_CANONICAL (typ)
&& !uses_template_parms (typ))
{
+ int aka_start; char *p;
+ struct obstack *ob = pp_base (cxx_pp)->buffer->obstack;
+ /* Remember the end of the initial dump. */
+ int len = obstack_object_size (ob);
tree aka = strip_typedefs (typ);
pp_string (cxx_pp, " {aka");
pp_cxx_whitespace (cxx_pp);
+ /* And remember the start of the aka dump. */
+ aka_start = obstack_object_size (ob);
dump_type (aka, flags);
pp_character (cxx_pp, '}');
+ p = (char*)obstack_base (ob);
+ /* If they are identical, cut off the aka with a NUL. */
+ if (memcmp (p, p+aka_start, len) == 0)
+ p[len] = '\0';
}
return pp_formatted_text (cxx_pp);
}