diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-25 03:48:35 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-25 03:48:35 +0000 |
commit | e3552bf9f0a78afb9d13351b05c3adf306d847d0 (patch) | |
tree | 05d055d0ebde38c8cdfec91ce5321799c219d9aa /gcc/go/gofrontend/parse.cc | |
parent | cd0fea2ba9b535f22658c78b5f3be49284ec8147 (diff) | |
download | gcc-e3552bf9f0a78afb9d13351b05c3adf306d847d0.zip gcc-e3552bf9f0a78afb9d13351b05c3adf306d847d0.tar.gz gcc-e3552bf9f0a78afb9d13351b05c3adf306d847d0.tar.bz2 |
compiler: Type check params in sink function decl.
When a function is declared and named with the blank identifier, only
the syntax is checked. This patch modifies the parser to add a dummy
node for each function declaration with a blank identifier name that
will be type checked like any function declaration.
Fixes golang/go#11535.
Reviewed-on: https://go-review.googlesource.com/13792
From-SVN: r227160
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 211fd73..922473a 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -2305,8 +2305,20 @@ Parse::function_decl(bool saw_nointerface) 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); |