diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-27 00:44:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-27 00:44:11 +0000 |
commit | d8d9efb3480764438e243f6c22843a57b5188185 (patch) | |
tree | e42134a1e3cde1b47412f40a0bf80e01e9b0847f | |
parent | d252f921bb6560c226c05c25ced419493ab48ab6 (diff) | |
download | gcc-d8d9efb3480764438e243f6c22843a57b5188185.zip gcc-d8d9efb3480764438e243f6c22843a57b5188185.tar.gz gcc-d8d9efb3480764438e243f6c22843a57b5188185.tar.bz2 |
compiler: Don't crash on invalid builtin calls.
Fixes golang/go#11544.
Reviewed-on: https://go-review.googlesource.com/13893
From-SVN: r227245
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index b3fcc04..f29ffd4 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -cd5362c7bb0b207f484a8dfb8db229fd2bffef09 +5ee78e7d52a4cad0b23f5bc62e5b452489243c70 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 79b772e..c18ae4a 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -6588,7 +6588,11 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo, recover_arg_is_set_(false) { Func_expression* fnexp = this->fn()->func_expression(); - go_assert(fnexp != NULL); + if (fnexp == NULL) + { + this->code_ = BUILTIN_INVALID; + return; + } const std::string& name(fnexp->named_object()->name()); if (name == "append") this->code_ = BUILTIN_APPEND; @@ -6661,7 +6665,7 @@ Expression* Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, Statement_inserter* inserter, int) { - if (this->classification() == EXPRESSION_ERROR) + if (this->is_error_expression()) return this; Location loc = this->location(); @@ -7500,11 +7504,13 @@ Builtin_call_expression::do_discarding_value() Type* Builtin_call_expression::do_type() { + if (this->is_error_expression()) + return Type::make_error_type(); switch (this->code_) { case BUILTIN_INVALID: default: - go_unreachable(); + return Type::make_error_type(); case BUILTIN_NEW: case BUILTIN_MAKE: |