Skip to content

Commit

Permalink
compiler: Don't crash on invalid print call.
Browse files Browse the repository at this point in the history
When the print builtins are called with no arguments, the compiler
issues a warning and crashes when trying to produce the backend
representation for the arguments.

Fixes golang/go#11526.

Change-Id: I0616bfdd4f29cedeb44db51a311e706d4628c19c
Reviewed-on: https://go-review.googlesource.com/13131
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Aug 20, 2015
1 parent ec34cfb commit cc7303c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/expressions.cc
Expand Up @@ -8177,6 +8177,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context)
location);
}

// There aren't any arguments to the print builtin. The compiler
// issues a warning for this so we should avoid getting the backend
// representation for this call. Instead, perform a no-op.
if (print_stmts == NULL)
return context->backend()->boolean_constant_expression(false);

return print_stmts->get_backend(context);
}

Expand Down

0 comments on commit cc7303c

Please sign in to comment.