diff options
Diffstat (limited to 'gcc/go/gofrontend/statements.cc')
-rw-r--r-- | gcc/go/gofrontend/statements.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 0261f9d..a5102c0 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -594,6 +594,15 @@ Assignment_statement::do_check_types(Gogo*) Type* lhs_type = this->lhs_->type(); Type* rhs_type = this->rhs_->type(); + + // Invalid assignment of nil to the blank identifier. + if (lhs_type->is_sink_type() + && rhs_type->is_nil_type()) + { + this->report_error(_("use of untyped nil")); + return; + } + std::string reason; bool ok; if (this->are_hidden_fields_ok_) @@ -975,7 +984,10 @@ Tuple_assignment_statement::do_lower(Gogo*, Named_object*, Block* enclosing, if ((*plhs)->is_sink_expression()) { - b->add_statement(Statement::make_statement(*prhs, true)); + if ((*prhs)->type()->is_nil_type()) + this->report_error(_("use of untyped nil")); + else + b->add_statement(Statement::make_statement(*prhs, true)); continue; } |