Skip to content

Commit 32e3ff6

Browse files
author
ian
committed
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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227039 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 2744340 commit 32e3ff6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

gcc/go/gofrontend/MERGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ec34cfb0b148ff461df12c8f5270a06e2f438b7c
1+
cc7303c97b232ea979cab950d95aaf76c4e0f5b5
22

33
The first line of this file holds the git revision number of the last
44
merge done from the gofrontend repository.

gcc/go/gofrontend/expressions.cc

+6
Original file line numberDiff line numberDiff line change
@@ -8177,6 +8177,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context)
81778177
location);
81788178
}
81798179

8180+
// There aren't any arguments to the print builtin. The compiler
8181+
// issues a warning for this so we should avoid getting the backend
8182+
// representation for this call. Instead, perform a no-op.
8183+
if (print_stmts == NULL)
8184+
return context->backend()->boolean_constant_expression(false);
8185+
81808186
return print_stmts->get_backend(context);
81818187
}
81828188

0 commit comments

Comments
 (0)