Patchwork [gccgo] Better error message

login
register
mail settings
Submitter Ian Taylor
Date Sept. 9, 2010, 12:51 a.m.
Message ID <mcr62yfg2ms.fsf@google.com>
Download mbox | patch
Permalink /patch/64249/
State New
Headers show

Comments

Ian Taylor - Sept. 9, 2010, 12:51 a.m.
This gccgo patch gives a better error message for trying to convert a
pointer to an interface type to an interface type.  Committed to gccgo
branch.

Ian

Patch

diff -r 1a780eee0bc4 go/types.cc
--- a/go/types.cc	Wed Sep 08 17:37:19 2010 -0700
+++ b/go/types.cc	Wed Sep 08 17:49:47 2010 -0700
@@ -4749,14 +4749,26 @@ 
   if (nt == NULL && st == NULL)
     {
       if (reason != NULL)
-	reason->assign(_("type has no methods"));
+	{
+	  if (t->points_to() != NULL
+	      && t->points_to()->interface_type() != NULL)
+	    reason->assign(_("pointer to interface type has no methods"));
+	  else
+	    reason->assign(_("type has no methods"));
+	}
       return false;
     }
 
   if (nt != NULL ? !nt->has_any_methods() : !st->has_any_methods())
     {
       if (reason != NULL)
-	reason->assign(_("type has no methods"));
+	{
+	  if (t->points_to() != NULL
+	      && t->points_to()->interface_type() != NULL)
+	    reason->assign(_("pointer to interface type has no methods"));
+	  else
+	    reason->assign(_("type has no methods"));
+	}
       return false;
     }