diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-22 15:25:23 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-22 15:25:23 +0000 |
commit | f39c772f2ee579fc42707bffd0480c01f8bc2bd7 (patch) | |
tree | 97befc3315c32c585c8831cb83d07c1c831a7780 | |
parent | 9ed91cebef42dd20ca7f9f665d3f7b2b248a3584 (diff) | |
download | gcc-f39c772f2ee579fc42707bffd0480c01f8bc2bd7.zip gcc-f39c772f2ee579fc42707bffd0480c01f8bc2bd7.tar.gz gcc-f39c772f2ee579fc42707bffd0480c01f8bc2bd7.tar.bz2 |
Don't crash if array length is invalid const.
From-SVN: r168171
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 2b60256..de07a1d 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -9095,7 +9095,11 @@ Array_index_expression::do_check_types(Gogo*) this->report_error(_("slice end must be integer")); Array_type* array_type = this->array_->type()->array_type(); - gcc_assert(array_type != NULL); + if (array_type == NULL) + { + gcc_assert(this->array_->type()->is_error_type()); + return; + } unsigned int int_bits = Type::lookup_integer_type("int")->integer_type()->bits(); @@ -10936,7 +10940,14 @@ class Open_array_construction_expression : public Array_construction_expression tree Open_array_construction_expression::do_get_tree(Translate_context* context) { - Type* element_type = this->type()->array_type()->element_type(); + Array_type* array_type = this->type()->array_type(); + if (array_type == NULL) + { + gcc_assert(this->type()->is_error_type()); + return error_mark_node; + } + + Type* element_type = array_type->element_type(); tree element_type_tree = element_type->get_tree(context->gogo()); if (element_type_tree == error_mark_node) return error_mark_node; |