PR 49117 complains that the error message given on conversion failure regressed from 4.5 to 4.6 in that it no longer prints the source type. So I've added it back in.

While I was at it, I've also tweaked the compiler to also print the typedef-stripped version of a type when appropriate, which should help with understanding template error messages.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.
commit 2978b60371c26f46ba5ac44244d94ef100cf9cf2
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Jun 14 09:43:04 2011 -0400

    	PR c++/49117
    	* call.c (perform_implicit_conversion_flags): Print source type as
    	well as expression.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4ee0eaf..b43d078 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8296,7 +8296,8 @@ perform_implicit_conversion_flags (tree type, tree expr, tsubst_flags_t complain
 	  else if (invalid_nonstatic_memfn_p (expr, complain))
 	    /* We gave an error.  */;
 	  else
-	    error ("could not convert %qE to %qT", expr, type);
+	    error ("could not convert %qE from %qT to %qT", expr,
+		   TREE_TYPE (expr), type);
 	}
       expr = error_mark_node;
     }
diff --git a/gcc/testsuite/g++.dg/other/error23.C b/gcc/testsuite/g++.dg/other/error23.C
index 0ff1915..959fe40 100644
--- a/gcc/testsuite/g++.dg/other/error23.C
+++ b/gcc/testsuite/g++.dg/other/error23.C
@@ -2,4 +2,4 @@
 // { dg-do compile }
 
 int v __attribute ((vector_size (8)));
-bool b = !(v - v);	// { dg-error "could not convert .\\(__vector.2. int\\)\\{0, 0\\}. to .bool.|in argument to unary" }
+bool b = !(v - v);	// { dg-error "could not convert .\\(__vector.2. int\\)\\{0, 0\\}. from .__vector.2. int. to .bool.|in argument to unary" }
diff --git a/gcc/testsuite/g++.dg/other/error32.C b/gcc/testsuite/g++.dg/other/error32.C
index 35c64c4..56d3b7a 100644
--- a/gcc/testsuite/g++.dg/other/error32.C
+++ b/gcc/testsuite/g++.dg/other/error32.C
@@ -3,6 +3,6 @@
 
 void foo()
 {
-  if (throw 0) // { dg-error "could not convert .\\<throw-expression\\>. to .bool." }
+  if (throw 0) // { dg-error "could not convert .\\<throw-expression\\>. from .void. to .bool." }
     ;
 }
commit 16136651e85c19a1e8338a0bd1b2b1a453413c23
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Jun 14 09:43:25 2011 -0400

    	* error.c (type_to_string): Print typedef-stripped version too.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 96796c2..22470dc 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2632,6 +2632,15 @@ type_to_string (tree typ, int verbose)
 
   reinit_cxx_pp ();
   dump_type (typ, flags);
+  if (typ && TYPE_P (typ) && typ != TYPE_CANONICAL (typ)
+      && !uses_template_parms (typ))
+    {
+      tree aka = strip_typedefs (typ);
+      pp_string (cxx_pp, " {aka");
+      pp_cxx_whitespace (cxx_pp);
+      dump_type (aka, flags);
+      pp_character (cxx_pp, '}');
+    }
   return pp_formatted_text (cxx_pp);
 }
 

Reply via email to