Commit 0f9f95ad by Ian Lance Taylor

Don't crash on field reference to erroneous struct.

From-SVN: r170020
parent 26d061fc
......@@ -9946,7 +9946,10 @@ Expression::make_map_index(Expression* map, Expression* index,
Type*
Field_reference_expression::do_type()
{
Struct_type* struct_type = this->expr_->type()->struct_type();
Type* type = this->expr_->type();
if (type->is_error_type())
return type;
Struct_type* struct_type = type->struct_type();
gcc_assert(struct_type != NULL);
return struct_type->field(this->field_index_)->type();
}
......@@ -9956,7 +9959,10 @@ Field_reference_expression::do_type()
void
Field_reference_expression::do_check_types(Gogo*)
{
Struct_type* struct_type = this->expr_->type()->struct_type();
Type* type = this->expr_->type();
if (type->is_error_type())
return;
Struct_type* struct_type = type->struct_type();
gcc_assert(struct_type != NULL);
gcc_assert(struct_type->field(this->field_index_) != NULL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment