diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-11-28 18:22:45 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-30 12:07:39 -0800 |
commit | 8d8fea8a57068a0c5f0c1df766679a25f4272481 (patch) | |
tree | 47eb514d19b2127fe8219778cbc704e2931908da /gcc/go/gofrontend/expressions.cc | |
parent | 38f10841817a9fee28ee97c7115b6f4d24f5245d (diff) | |
download | gcc-8d8fea8a57068a0c5f0c1df766679a25f4272481.zip gcc-8d8fea8a57068a0c5f0c1df766679a25f4272481.tar.gz gcc-8d8fea8a57068a0c5f0c1df766679a25f4272481.tar.bz2 |
compiler: always use int context for index values
For golang/go#14844
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273889
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index dc7399e..d154630 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -12802,24 +12802,11 @@ Array_index_expression::do_determine_type(const Type_context*) this->array_->determine_type_no_context(); Type_context index_context(Type::lookup_integer_type("int"), false); - if (this->start_->is_constant()) - this->start_->determine_type(&index_context); - else - this->start_->determine_type_no_context(); + this->start_->determine_type(&index_context); if (this->end_ != NULL) - { - if (this->end_->is_constant()) - this->end_->determine_type(&index_context); - else - this->end_->determine_type_no_context(); - } + this->end_->determine_type(&index_context); if (this->cap_ != NULL) - { - if (this->cap_->is_constant()) - this->cap_->determine_type(&index_context); - else - this->cap_->determine_type_no_context(); - } + this->cap_->determine_type(&index_context); } // Check types of an array index. @@ -13488,17 +13475,9 @@ String_index_expression::do_determine_type(const Type_context*) this->string_->determine_type_no_context(); Type_context index_context(Type::lookup_integer_type("int"), false); - if (this->start_->is_constant()) - this->start_->determine_type(&index_context); - else - this->start_->determine_type_no_context(); + this->start_->determine_type(&index_context); if (this->end_ != NULL) - { - if (this->end_->is_constant()) - this->end_->determine_type(&index_context); - else - this->end_->determine_type_no_context(); - } + this->end_->determine_type(&index_context); } // Check types of a string index. |