Commit d8d9efb3 by Ian Lance Taylor

compiler: Don't crash on invalid builtin calls.

    
    Fixes golang/go#11544.
    
    Reviewed-on: https://go-review.googlesource.com/13893

From-SVN: r227245
parent d252f921
cd5362c7bb0b207f484a8dfb8db229fd2bffef09 5ee78e7d52a4cad0b23f5bc62e5b452489243c70
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -6588,7 +6588,11 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo, ...@@ -6588,7 +6588,11 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
recover_arg_is_set_(false) recover_arg_is_set_(false)
{ {
Func_expression* fnexp = this->fn()->func_expression(); 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()); const std::string& name(fnexp->named_object()->name());
if (name == "append") if (name == "append")
this->code_ = BUILTIN_APPEND; this->code_ = BUILTIN_APPEND;
...@@ -6661,7 +6665,7 @@ Expression* ...@@ -6661,7 +6665,7 @@ Expression*
Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int) Statement_inserter* inserter, int)
{ {
if (this->classification() == EXPRESSION_ERROR) if (this->is_error_expression())
return this; return this;
Location loc = this->location(); Location loc = this->location();
...@@ -7500,11 +7504,13 @@ Builtin_call_expression::do_discarding_value() ...@@ -7500,11 +7504,13 @@ Builtin_call_expression::do_discarding_value()
Type* Type*
Builtin_call_expression::do_type() Builtin_call_expression::do_type()
{ {
if (this->is_error_expression())
return Type::make_error_type();
switch (this->code_) switch (this->code_)
{ {
case BUILTIN_INVALID: case BUILTIN_INVALID:
default: default:
go_unreachable(); return Type::make_error_type();
case BUILTIN_NEW: case BUILTIN_NEW:
case BUILTIN_MAKE: case BUILTIN_MAKE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment