From patchwork Thu Sep 9 00:51:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 64249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7D6EEB6EEC for ; Thu, 9 Sep 2010 10:52:21 +1000 (EST) Received: (qmail 4005 invoked by alias); 9 Sep 2010 00:52:19 -0000 Received: (qmail 3996 invoked by uid 22791); 9 Sep 2010 00:52:18 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Sep 2010 00:52:14 +0000 Received: from hpaq13.eem.corp.google.com (hpaq13.eem.corp.google.com [172.25.149.13]) by smtp-out.google.com with ESMTP id o890qBH8016246 for ; Wed, 8 Sep 2010 17:52:11 -0700 Received: from pvg16 (pvg16.prod.google.com [10.241.210.144]) by hpaq13.eem.corp.google.com with ESMTP id o890q9qY018551 for ; Wed, 8 Sep 2010 17:52:10 -0700 Received: by pvg16 with SMTP id 16so373495pvg.26 for ; Wed, 08 Sep 2010 17:52:09 -0700 (PDT) Received: by 10.114.102.11 with SMTP id z11mr188825wab.13.1283993529122; Wed, 08 Sep 2010 17:52:09 -0700 (PDT) Received: from coign.google.com ([66.109.106.2]) by mx.google.com with ESMTPS id o17sm1087819wal.21.2010.09.08.17.52.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 08 Sep 2010 17:52:07 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Better error message Date: Wed, 08 Sep 2010 17:51:55 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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; }