diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-01 18:19:13 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-01 18:19:13 +0000 |
commit | b19aea32fad613a9405ce8774f9c4fb8c8ae4f6b (patch) | |
tree | 1d224f339691fe264cf8e099ff5ae5acd7df7f51 | |
parent | 5e4119eaa2f08c61e501e2989c6385b229dea2b0 (diff) | |
download | gcc-b19aea32fad613a9405ce8774f9c4fb8c8ae4f6b.zip gcc-b19aea32fad613a9405ce8774f9c4fb8c8ae4f6b.tar.gz gcc-b19aea32fad613a9405ce8774f9c4fb8c8ae4f6b.tar.bz2 |
compiler: Reliably give errors on misuse of multiple value call.
From-SVN: r184755
-rw-r--r-- | gcc/go/gofrontend/types.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 6abe21d..3c33a6d 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -622,16 +622,24 @@ Type::are_assignable_check_hidden(const Type* lhs, const Type* rhs, std::string* reason) { // Do some checks first. Make sure the types are defined. - if (rhs != NULL - && rhs->forwarded()->forward_declaration_type() == NULL - && rhs->is_void_type()) + if (rhs != NULL && !rhs->is_undefined()) { - if (reason != NULL) - *reason = "non-value used as value"; - return false; + if (rhs->is_void_type()) + { + if (reason != NULL) + *reason = "non-value used as value"; + return false; + } + if (rhs->is_call_multiple_result_type()) + { + if (reason != NULL) + reason->assign(_("multiple value function call in " + "single value context")); + return false; + } } - if (lhs != NULL && lhs->forwarded()->forward_declaration_type() == NULL) + if (lhs != NULL && !lhs->is_undefined()) { // Any value may be assigned to the blank identifier. if (lhs->is_sink_type()) @@ -639,9 +647,7 @@ Type::are_assignable_check_hidden(const Type* lhs, const Type* rhs, // All fields of a struct must be exported, or the assignment // must be in the same package. - if (check_hidden_fields - && rhs != NULL - && rhs->forwarded()->forward_declaration_type() == NULL) + if (check_hidden_fields && rhs != NULL && !rhs->is_undefined()) { if (lhs->has_hidden_fields(NULL, reason) || rhs->has_hidden_fields(NULL, reason)) @@ -715,9 +721,6 @@ Type::are_assignable_check_hidden(const Type* lhs, const Type* rhs, { if (rhs->interface_type() != NULL) reason->assign(_("need explicit conversion")); - else if (rhs->is_call_multiple_result_type()) - reason->assign(_("multiple value function call in " - "single value context")); else if (lhs->named_type() != NULL && rhs->named_type() != NULL) { size_t len = (lhs->named_type()->name().length() |