Commit f4cd6a8d by Ian Lance Taylor

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.
    
    Reviewed-on: https://go-review.googlesource.com/13131

From-SVN: r227039
parent f999c862
ec34cfb0b148ff461df12c8f5270a06e2f438b7c cc7303c97b232ea979cab950d95aaf76c4e0f5b5
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.
...@@ -8177,6 +8177,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context) ...@@ -8177,6 +8177,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context)
location); 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); return print_stmts->get_backend(context);
} }
......
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