public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@golang.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
		"gofrontend-dev@googlegroups.com"
	<gofrontend-dev@googlegroups.com>
Subject: Go patch committed: Type check parameters in sink function declaration
Date: Tue, 25 Aug 2015 08:14:00 -0000	[thread overview]
Message-ID: <CAOyqgcXbGW5VR2=h8xUhStJE6Z9gh6Hpnkwm9h6O3s=57AfipA@mail.gmail.com> (raw)

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

This patch by Chris Manghane fixes the Go frontend to type check
function parameters in a sink function declaration, as in func _(int).
This fixes https://golang.org/issue/11535 .  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1430 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 227039)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-cc7303c97b232ea979cab950d95aaf76c4e0f5b5
+81810917af7ba19e1f9f8efc8b1989f7d6419d30
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/parse.cc
===================================================================
--- gcc/go/gofrontend/parse.cc	(revision 226846)
+++ gcc/go/gofrontend/parse.cc	(working copy)
@@ -2305,8 +2305,20 @@ Parse::function_decl(bool saw_nointerfac
 
   if (!this->peek_token()->is_op(OPERATOR_LCURLY))
     {
-      if (named_object == NULL && !Gogo::is_sink_name(name))
+      if (named_object == NULL)
 	{
+          // Function declarations with the blank identifier as a name are
+          // mostly ignored since they cannot be called.  We make an object
+          // for this declaration for type-checking purposes.
+          if (Gogo::is_sink_name(name))
+            {
+              static int count;
+              char buf[30];
+              snprintf(buf, sizeof buf, ".$sinkfndecl%d", count);
+              ++count;
+              name = std::string(buf);
+            }
+
 	  if (fntype == NULL
               || (expected_receiver && rec == NULL))
 	    this->gogo_->add_erroneous_name(name);

                 reply	other threads:[~2015-08-25  3:48 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='CAOyqgcXbGW5VR2=h8xUhStJE6Z9gh6Hpnkwm9h6O3s=57AfipA@mail.gmail.com' \
    --to=iant@golang.org \
    --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).