public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com
Subject: Go patch committed: method names must be non-blank
Date: Thu, 16 Oct 2014 20:04:00 -0000	[thread overview]
Message-ID: <mcrppdr7ps6.fsf@iant-glaptop.roam.corp.google.com> (raw)

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

The Go language spec was clarified to say that method names must be
non-blank.  This patch by Chris Manghane implements this restriction in
the Go frontend.  This requires a couple of testsuite changes, already
in the master testsuite and included in this patch.  This fixes
http://golang.org/issue/8078 .  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1736 bytes --]

Index: gcc/go/gofrontend/parse.cc
===================================================================
--- gcc/go/gofrontend/parse.cc	(revision 216343)
+++ gcc/go/gofrontend/parse.cc	(working copy)
@@ -1253,6 +1253,8 @@ Parse::method_spec(Typed_identifier_list
   if (this->advance_token()->is_op(OPERATOR_LPAREN))
     {
       // This is a MethodName.
+      if (name == "_")
+	error_at(this->location(), "methods must have a unique non-blank name");
       name = this->gogo_->pack_hidden_name(name, is_exported);
       Type* type = this->signature(NULL, location);
       if (type == NULL)
Index: gcc/testsuite/go.test/test/interface/explicit.go
===================================================================
--- gcc/testsuite/go.test/test/interface/explicit.go	(revision 216257)
+++ gcc/testsuite/go.test/test/interface/explicit.go	(working copy)
@@ -83,12 +83,12 @@ var m4 = M(jj) // ERROR "invalid|wrong t
 
 
 type B1 interface {
-	_()
+	_() // ERROR "methods must have a unique non-blank name"
 }
 
 type B2 interface {
 	M()
-	_()
+	_() // ERROR "methods must have a unique non-blank name"
 }
 
 type T2 struct{}
Index: gcc/testsuite/go.test/test/interface/fail.go
===================================================================
--- gcc/testsuite/go.test/test/interface/fail.go	(revision 216257)
+++ gcc/testsuite/go.test/test/interface/fail.go	(working copy)
@@ -14,7 +14,6 @@ type I interface {
 
 func main() {
 	shouldPanic(p1)
-	shouldPanic(p2)
 }
 
 func p1() {
@@ -30,19 +29,6 @@ type S struct{}
 
 func (s *S) _() {}
 
-type B interface {
-	_()
-}
-
-func p2() {
-	var s *S
-	var b B
-	var e interface{}
-	e = s
-	b = e.(B)
-	_ = b
-}
-
 func shouldPanic(f func()) {
 	defer func() {
 		if recover() == nil {

                 reply	other threads:[~2014-10-16 19:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mcrppdr7ps6.fsf@iant-glaptop.roam.corp.google.com \
    --to=iant@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).