aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-02-20 15:20:26 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-02-20 15:20:26 +0000
commit7f5e81887717c4fe8b89c81720b94b5e93174c38 (patch)
tree19983422901df258e218c9312c39e5117d05c796
parentefd2d3c8c4e1e6387304d85b3b12b8d623348330 (diff)
downloadgcc-7f5e81887717c4fe8b89c81720b94b5e93174c38.zip
gcc-7f5e81887717c4fe8b89c81720b94b5e93174c38.tar.gz
gcc-7f5e81887717c4fe8b89c81720b94b5e93174c38.tar.bz2
re PR go/60288 (gccgo crashes compiling '*func_ptr(0)')
PR go/60288 compiler: Avoid crash, give error for *&x when x is not addressable. From-SVN: r207960
-rw-r--r--gcc/go/gofrontend/expressions.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index c4230f6..6ac18f5 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -3792,6 +3792,12 @@ Unary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
if (e == expr)
{
// *&x == x.
+ if (!ue->expr_->is_addressable() && !ue->create_temp_)
+ {
+ error_at(ue->location(),
+ "invalid operand for unary %<&%>");
+ this->set_is_error();
+ }
return ue->expr_;
}
ue->set_does_not_escape();
@@ -3828,6 +3834,9 @@ Expression*
Unary_expression::do_flatten(Gogo* gogo, Named_object*,
Statement_inserter* inserter)
{
+ if (this->is_error_expression() || this->expr_->is_error_expression())
+ return Expression::make_error(this->location());
+
Location location = this->location();
if (this->op_ == OPERATOR_MULT
&& !this->expr_->is_variable())
@@ -4167,7 +4176,10 @@ Unary_expression::do_check_types(Gogo*)
if (!this->expr_->is_addressable())
{
if (!this->create_temp_)
- this->report_error(_("invalid operand for unary %<&%>"));
+ {
+ error_at(this->location(), "invalid operand for unary %<&%>");
+ this->set_is_error();
+ }
}
else
{