diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-11-26 16:11:28 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-28 07:01:41 -0800 |
commit | b1adbc27c4a85ded4db81ed65b1cefce4cee8d15 (patch) | |
tree | 43770b3d503fd73e08fa5647f8a892d4c4ba6b54 /gcc/go/gofrontend/expressions.cc | |
parent | 822ea13e499db20af2080b48fc3bb530e429bb8d (diff) | |
download | gcc-b1adbc27c4a85ded4db81ed65b1cefce4cee8d15.zip gcc-b1adbc27c4a85ded4db81ed65b1cefce4cee8d15.tar.gz gcc-b1adbc27c4a85ded4db81ed65b1cefce4cee8d15.tar.bz2 |
compiler: avoid follow-on errors for bad types
Mark bad types as erroneous, to avoid generating further errors.
This required some code using array types to check for errors.
For https://golang.org/issue/19880
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273626
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 448888b..dc7399e 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -15303,9 +15303,22 @@ Array_construction_expression::do_is_static_initializer() const void Array_construction_expression::do_determine_type(const Type_context*) { + if (this->is_error_expression()) + { + go_assert(saw_errors()); + return; + } + if (this->vals() == NULL) return; - Type_context subcontext(this->type_->array_type()->element_type(), false); + Array_type* at = this->type_->array_type(); + if (at == NULL || at->is_error() || at->element_type()->is_error()) + { + go_assert(saw_errors()); + this->set_is_error(); + return; + } + Type_context subcontext(at->element_type(), false); for (Expression_list::const_iterator pv = this->vals()->begin(); pv != this->vals()->end(); ++pv) @@ -15320,10 +15333,22 @@ Array_construction_expression::do_determine_type(const Type_context*) void Array_construction_expression::do_check_types(Gogo*) { + if (this->is_error_expression()) + { + go_assert(saw_errors()); + return; + } + if (this->vals() == NULL) return; Array_type* at = this->type_->array_type(); + if (at == NULL || at->is_error() || at->element_type()->is_error()) + { + go_assert(saw_errors()); + this->set_is_error(); + return; + } int i = 0; Type* element_type = at->element_type(); for (Expression_list::const_iterator pv = this->vals()->begin(); @@ -15348,6 +15373,12 @@ Expression* Array_construction_expression::do_flatten(Gogo*, Named_object*, Statement_inserter* inserter) { + if (this->is_error_expression()) + { + go_assert(saw_errors()); + return this; + } + if (this->vals() == NULL) return this; @@ -15384,6 +15415,12 @@ Array_construction_expression::do_flatten(Gogo*, Named_object*, void Array_construction_expression::do_add_conversions() { + if (this->is_error_expression()) + { + go_assert(saw_errors()); + return; + } + if (this->vals() == NULL) return; |