From cc7303c97b232ea979cab950d95aaf76c4e0f5b5 Mon Sep 17 00:00:00 2001 From: Chris Manghane Date: Tue, 4 Aug 2015 11:53:05 -0700 Subject: [PATCH] compiler: Don't crash on invalid print call. 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 --- go/expressions.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go/expressions.cc b/go/expressions.cc index 9f757a2aa..c0e5fc53a 100644 --- a/go/expressions.cc +++ b/go/expressions.cc @@ -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); }