This patch by Chris Manghane fixes the Go frontend to not crash on erroneous channel reads. This fixes https://golang.org/issue/12320 . Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 227830) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -79f457a267ff2bf8e65db4bcec0cbc7add79227a +1cb26dc898bda1e85f4dd2ee204adbce792e4813 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 227830) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -3472,6 +3472,15 @@ Unsafe_type_conversion_expression::do_ge Type* t = this->type_; Type* et = this->expr_->type(); + + if (t->is_error_type() + || this->expr_->is_error_expression() + || et->is_error_type()) + { + go_assert(saw_errors()); + return context->backend()->error_expression(); + } + if (t->array_type() != NULL) go_assert(et->array_type() != NULL && t->is_slice_type() == et->is_slice_type());