summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 13:57:40 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 13:57:40 +0000
commite429e3bd7a4ee90fd247e078d29aee17ad3b15c2 (patch)
tree9470bd83d6c0817a3a3dcf333b3163f36fc50d6a /gcc/go
parent706dca65fda779bf270d3d7018c138cbe87f643d (diff)
downloadgcc-e429e3bd7a4ee90fd247e078d29aee17ad3b15c2.tar.gz
compiler: Issue channel type errors earlier.
When asking for the type of a receive operation, the compiler would return an error type if the receive operator was being used on an invalid channel type and the error would be reported in a later pass. There are several ways that the type checking pass would not see the original node and fail to issue the error. This patch modifies receive operations to give an error immediately once it is known that the channel type is invalid. Fixes golang/go#12323. Reviewed-on: https://go-review.googlesource.com/13987 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227863 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc8
-rw-r--r--gcc/go/gofrontend/statements.cc5
3 files changed, 12 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index c150747ae36..f21c43a8c6d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-1cb26dc898bda1e85f4dd2ee204adbce792e4813
+e069d4417a692c1261df99fe3323277e1a0193d2
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 542f3de6fbb..7ad271f109b 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -13502,9 +13502,14 @@ Expression::make_heap_expression(Expression* expr, Location location)
Type*
Receive_expression::do_type()
{
+ if (this->is_error_expression())
+ return Type::make_error_type();
Channel_type* channel_type = this->channel_->type()->channel_type();
if (channel_type == NULL)
- return Type::make_error_type();
+ {
+ this->report_error(_("expected channel"));
+ return Type::make_error_type();
+ }
return channel_type->element_type();
}
@@ -13516,6 +13521,7 @@ Receive_expression::do_check_types(Gogo*)
Type* type = this->channel_->type();
if (type->is_error())
{
+ go_assert(saw_errors());
this->set_is_error();
return;
}
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 5d102bf2e17..a84203a5fea 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -3856,7 +3856,10 @@ Switch_statement::do_lower(Gogo*, Named_object*, Block* enclosing,
if (this->val_ != NULL
&& (this->val_->is_error_expression()
|| this->val_->type()->is_error()))
- return Statement::make_error_statement(loc);
+ {
+ go_assert(saw_errors());
+ return Statement::make_error_statement(loc);
+ }
if (this->val_ != NULL
&& this->val_->type()->integer_type() != NULL