public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/49117 (error message regression on conversion failure)
@ 2011-06-14 17:46 Jason Merrill
  2011-06-18 14:20 ` Jakub Jelinek
  2011-07-01 18:07 ` C++ PATCH to improve 'aka's on type printing in diagnostics Jason Merrill
  0 siblings, 2 replies; 6+ messages in thread
From: Jason Merrill @ 2011-06-14 17:46 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]

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.

[-- Attachment #2: 49117.patch --]
[-- Type: text/x-patch, Size: 1734 bytes --]

commit 2978b60371c26f46ba5ac44244d94ef100cf9cf2
Author: Jason Merrill <jason@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." }
     ;
 }

[-- Attachment #3: aka.patch --]
[-- Type: text/x-patch, Size: 758 bytes --]

commit 16136651e85c19a1e8338a0bd1b2b1a453413c23
Author: Jason Merrill <jason@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);
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-04 21:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-14 17:46 C++ PATCH for c++/49117 (error message regression on conversion failure) Jason Merrill
2011-06-18 14:20 ` Jakub Jelinek
2011-07-01 18:07 ` C++ PATCH to improve 'aka's on type printing in diagnostics Jason Merrill
2011-07-04 19:54   ` Gabriel Dos Reis
2011-07-04 21:29     ` Jason Merrill
2011-07-04 21:31       ` Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).