From acdc230d5f51e2702b0029beb5e692d45eb8b2ee Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 11 Oct 2013 17:45:29 +0000 Subject: [PATCH] compiler: accept integral float constants as string indices. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203452 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/expressions.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 37f8822..06c3429 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -10888,11 +10888,20 @@ String_index_expression::do_determine_type(const Type_context*) void String_index_expression::do_check_types(Gogo*) { - if (this->start_->type()->integer_type() == NULL) + Numeric_constant nc; + unsigned long v; + if (this->start_->type()->integer_type() == NULL + && !this->start_->type()->is_error() + && (!this->start_->numeric_constant_value(&nc) + || nc.to_unsigned_long(&v) == Numeric_constant::NC_UL_NOTINT)) this->report_error(_("index must be integer")); if (this->end_ != NULL && this->end_->type()->integer_type() == NULL - && !this->end_->is_nil_expression()) + && !this->end_->type()->is_error() + && !this->end_->is_nil_expression() + && !this->end_->is_error_expression() + && (!this->end_->numeric_constant_value(&nc) + || nc.to_unsigned_long(&v) == Numeric_constant::NC_UL_NOTINT)) this->report_error(_("slice end must be integer")); std::string sval; -- 2.7.4