diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-08-10 16:13:01 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-08-10 19:36:15 -0700 |
commit | fed7c1634e8e50600e20cb97dbfbd74ecbd5ba22 (patch) | |
tree | bd2062dbc843a2c220aac6de267ee6c3a28eddcd /gcc/go/gofrontend/expressions.cc | |
parent | 05a03f3986db25cb5076b409f4048e9dbb5dbfdf (diff) | |
download | gcc-fed7c1634e8e50600e20cb97dbfbd74ecbd5ba22.zip gcc-fed7c1634e8e50600e20cb97dbfbd74ecbd5ba22.tar.gz gcc-fed7c1634e8e50600e20cb97dbfbd74ecbd5ba22.tar.bz2 |
compiler: don't crash on a, b := int(0)
Fixes PR go/101851
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341330
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index f462b0e..67917da 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -11202,12 +11202,23 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, { Location loc = this->location(); + if (this->is_error_expression()) + return Expression::make_error(loc); + // A type cast can look like a function call. if (this->fn_->is_type_expression() && this->args_ != NULL && this->args_->size() == 1) - return Expression::make_cast(this->fn_->type(), this->args_->front(), - loc); + { + if (this->expected_result_count_ != 0 + && this->expected_result_count_ != 1) + { + this->report_error(_("type conversion result count mismatch")); + return Expression::make_error(loc); + } + return Expression::make_cast(this->fn_->type(), this->args_->front(), + loc); + } // Because do_type will return an error type and thus prevent future // errors, check for that case now to ensure that the error gets |