Skip to content

Commit 5ee78e7

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Don't crash on invalid builtin calls.
Fixes golang/go#11544. Change-Id: I6105ad00cccd23f35dc69565cb1e58bdc9e90c4f Reviewed-on: https://go-review.googlesource.com/13893 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent cd5362c commit 5ee78e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

go/expressions.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -6588,7 +6588,11 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
65886588
recover_arg_is_set_(false)
65896589
{
65906590
Func_expression* fnexp = this->fn()->func_expression();
6591-
go_assert(fnexp != NULL);
6591+
if (fnexp == NULL)
6592+
{
6593+
this->code_ = BUILTIN_INVALID;
6594+
return;
6595+
}
65926596
const std::string& name(fnexp->named_object()->name());
65936597
if (name == "append")
65946598
this->code_ = BUILTIN_APPEND;
@@ -6661,7 +6665,7 @@ Expression*
66616665
Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
66626666
Statement_inserter* inserter, int)
66636667
{
6664-
if (this->classification() == EXPRESSION_ERROR)
6668+
if (this->is_error_expression())
66656669
return this;
66666670

66676671
Location loc = this->location();
@@ -7500,11 +7504,13 @@ Builtin_call_expression::do_discarding_value()
75007504
Type*
75017505
Builtin_call_expression::do_type()
75027506
{
7507+
if (this->is_error_expression())
7508+
return Type::make_error_type();
75037509
switch (this->code_)
75047510
{
75057511
case BUILTIN_INVALID:
75067512
default:
7507-
go_unreachable();
7513+
return Type::make_error_type();
75087514

75097515
case BUILTIN_NEW:
75107516
case BUILTIN_MAKE:

0 commit comments

Comments
 (0)