OSDN Git Service

Don't crash on field reference to erroneous struct.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 19:21:20 +0000 (19:21 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 19:21:20 +0000 (19:21 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170020 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index 739032b..d17b173 100644 (file)
@@ -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);
 }