summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-03-27 17:52:34 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-03-27 17:52:34 +0000
commit4e90195a62a85d7c21c8f8a05fc0782bde88655e (patch)
tree113cdf21faacf44fcc2456160ce122eec33f05a1 /gcc/go
parent7e3b6543e0a188283f2307019e835eeb77cdf795 (diff)
downloadgcc-4e90195a62a85d7c21c8f8a05fc0782bde88655e.tar.gz
Error for return with no values when result parameters are not named.
From-SVN: r171576
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/statements.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 6843d6d8958..f57ada8278c 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -2581,10 +2581,20 @@ Return_statement::do_determine_types()
void
Return_statement::do_check_types(Gogo*)
{
+ const Typed_identifier_list* results = this->results_;
if (this->vals_ == NULL)
- return;
+ {
+ if (results != NULL
+ && !results->empty()
+ && results->front().name().empty())
+ {
+ // The result parameters are not named, which means that we
+ // need to supply values for them.
+ this->report_error(_("not enough arguments to return"));
+ }
+ return;
+ }
- const Typed_identifier_list* results = this->results_;
if (results == NULL)
{
this->report_error(_("return with value in function "
@@ -2621,7 +2631,7 @@ Return_statement::do_check_types(Gogo*)
}
if (pt != results->end())
- this->report_error(_("not enough values in return statement"));
+ this->report_error(_("not enough arguments to return"));
}
// Build a RETURN_EXPR tree.