diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-09-16 17:21:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-09-16 17:21:33 +0000 |
commit | 1d44db181fe6bbebf3c2ed3edf523cf87d66304c (patch) | |
tree | dc23fe1db3ca15d17e0e32ac66f0635e8684ffe2 /gcc/go | |
parent | 48c6522f7147595cffbc9cec526e115a6ffd066b (diff) | |
download | gcc-1d44db181fe6bbebf3c2ed3edf523cf87d66304c.zip gcc-1d44db181fe6bbebf3c2ed3edf523cf87d66304c.tar.gz gcc-1d44db181fe6bbebf3c2ed3edf523cf87d66304c.tar.bz2 |
compiler: Don't crash on malformed numeric constants.
Fixes golang/go#11548.
Reviewed-on: https://go-review.googlesource.com/13794
From-SVN: r227830
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 29 |
2 files changed, 28 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index bcaabac..fb61c64 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -01a574c1b2bb244be764b6a18aab980ca0aef43c +79f457a267ff2bf8e65db4bcec0cbc7add79227a The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 1c329b8..49d4d27 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -1904,6 +1904,13 @@ Integer_expression::do_check_types(Gogo*) Bexpression* Integer_expression::do_get_backend(Translate_context* context) { + if (this->is_error_expression() + || (this->type_ != NULL && this->type_->is_error_type())) + { + go_assert(saw_errors()); + return context->gogo()->backend()->error_expression(); + } + Type* resolved_type = NULL; if (this->type_ != NULL && !this->type_->is_abstract()) resolved_type = this->type_; @@ -2266,6 +2273,13 @@ Float_expression::do_check_types(Gogo*) Bexpression* Float_expression::do_get_backend(Translate_context* context) { + if (this->is_error_expression() + || (this->type_ != NULL && this->type_->is_error_type())) + { + go_assert(saw_errors()); + return context->gogo()->backend()->error_expression(); + } + Type* resolved_type; if (this->type_ != NULL && !this->type_->is_abstract()) resolved_type = this->type_; @@ -2448,6 +2462,13 @@ Complex_expression::do_check_types(Gogo*) Bexpression* Complex_expression::do_get_backend(Translate_context* context) { + if (this->is_error_expression() + || (this->type_ != NULL && this->type_->is_error_type())) + { + go_assert(saw_errors()); + return context->gogo()->backend()->error_expression(); + } + Type* resolved_type; if (this->type_ != NULL && !this->type_->is_abstract()) resolved_type = this->type_; @@ -2826,8 +2847,12 @@ Const_expression::do_check_types(Gogo*) Bexpression* Const_expression::do_get_backend(Translate_context* context) { - if (this->type_ != NULL && this->type_->is_error()) - return context->backend()->error_expression(); + if (this->is_error_expression() + || (this->type_ != NULL && this->type_->is_error())) + { + go_assert(saw_errors()); + return context->backend()->error_expression(); + } // If the type has been set for this expression, but the underlying // object is an abstract int or float, we try to get the abstract |