compiler: Don't crash on invalid print call.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 20 Aug 2015 17:43:55 +0000 (17:43 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 20 Aug 2015 17:43:55 +0000 (17:43 +0000)
    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

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc

index b2f305b354cd28129422f182303bf36b3cf9d35d..853cb4acc0051083a33ac0881ed330e1f5f58e52 100644 (file)
@@ -1,4 +1,4 @@
-ec34cfb0b148ff461df12c8f5270a06e2f438b7c
+cc7303c97b232ea979cab950d95aaf76c4e0f5b5
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 9f757a2aa26540a059cf75c5030f813539f0e987..c0e5fc53a82271262a087958bfcfdc314e8cd21e 100644 (file)
@@ -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);
       }