aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 19:21:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-02-10 19:21:20 +0000
commit0f9f95adea6386e02f3ff3da61b06b1d7fcd7fa0 (patch)
tree4f774eb7fb12274a9cbabfdeab198471f2cf7ab3
parent26d061fc233db50e5b599a10d092dfed8417a023 (diff)
downloadgcc-0f9f95adea6386e02f3ff3da61b06b1d7fcd7fa0.zip
gcc-0f9f95adea6386e02f3ff3da61b06b1d7fcd7fa0.tar.gz
gcc-0f9f95adea6386e02f3ff3da61b06b1d7fcd7fa0.tar.bz2
Don't crash on field reference to erroneous struct.
From-SVN: r170020
-rw-r--r--gcc/go/gofrontend/expressions.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 739032b..d17b173 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -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);
}