compiler: avoid crashing on bad self-referential type

The compiler was crashing partway through emitting an error for a bad
    self-referential struct type (which refers to one of its own fields
    via an unsafe.Offset expression). Tweak the offset logic to check for
    this class of type error and exit cleanly.
    
    Fixes golang/go#24180
    
    Reviewed-on: https://go-review.googlesource.com/97855

From-SVN: r258112
This commit is contained in:
Ian Lance Taylor 2018-03-01 19:56:14 +00:00
parent eedaaaf7d7
commit 56fc943329
2 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,4 @@
821960465883fbdd96568f2325f55ee4b05de1cb
262d629b1592f681fef396166a671e46cdb31230
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.

View File

@ -8224,6 +8224,11 @@ Builtin_call_expression::do_numeric_constant_value(Numeric_constant* nc) const
return false;
if (st->named_type() != NULL)
st->named_type()->convert(this->gogo_);
if (st->is_error_type())
{
go_assert(saw_errors());
return false;
}
int64_t offset;
this->seen_ = true;
bool ok = st->struct_type()->backend_field_offset(this->gogo_,