aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/parse.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-08-03 19:55:00 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-08-03 19:55:00 +0000
commitef9da28d8fa1e2c0dc890f87374c0f21b18430c3 (patch)
tree2778fa322ef0a610a5cb813393ce2264acdf7363 /gcc/go/gofrontend/parse.cc
parentde0fb9055c0928960ecc8e3a5fe990728611c3ca (diff)
downloadgcc-ef9da28d8fa1e2c0dc890f87374c0f21b18430c3.zip
gcc-ef9da28d8fa1e2c0dc890f87374c0f21b18430c3.tar.gz
gcc-ef9da28d8fa1e2c0dc890f87374c0f21b18430c3.tar.bz2
compiler: Don't allow multiple function declarations.
Fixes golang/go#11573. Reviewed-on: https://go-review.googlesource.com/12508 From-SVN: r226529
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r--gcc/go/gofrontend/parse.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index b7a0c39..7f7eba4 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -2231,9 +2231,11 @@ Parse::function_decl(bool saw_nointerface)
std::string extern_name = this->lex_->extern_name();
const Token* token = this->advance_token();
+ bool expected_receiver = false;
Typed_identifier* rec = NULL;
if (token->is_op(OPERATOR_LPAREN))
{
+ expected_receiver = true;
rec = this->receiver();
token = this->peek_token();
}
@@ -2304,7 +2306,8 @@ Parse::function_decl(bool saw_nointerface)
{
if (named_object == NULL && !Gogo::is_sink_name(name))
{
- if (fntype == NULL)
+ if (fntype == NULL
+ || (expected_receiver && rec == NULL))
this->gogo_->add_erroneous_name(name);
else
{