diff mbox

Go patch committed: Don't crash if a compound statement does nothing

Message ID mcrd2ca3mmt.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 8, 2014, 5:40 p.m. UTC
This patch to the Go frontend fixes a compiler crash if a compound
statement winds up doing nothing at all.  The test case is
http://codereview.appspot.com/124020044 and will go into the master Go
testsuite.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2014-08-08  Ian Lance Taylor  <iant@google.com>

	* go-gcc.cc (Gcc_backend::compound_statement): Don't return
	NULL_TREE.
diff mbox

Patch

Index: go-gcc.cc
===================================================================
--- go-gcc.cc	(revision 213760)
+++ go-gcc.cc	(working copy)
@@ -2123,6 +2123,12 @@  Gcc_backend::compound_statement(Bstateme
   if (t == error_mark_node)
     return this->error_statement();
   append_to_statement_list(t, &stmt_list);
+
+  // If neither statement has any side effects, stmt_list can be NULL
+  // at this point.
+  if (stmt_list == NULL_TREE)
+    stmt_list = integer_zero_node;
+
   return this->make_statement(stmt_list);
 }