This patch from Chris Manghane fixes the Go frontend so that when
using the -fgo-dump-ast option it does not crash when dumping an empty
block.  This fixes http://golang.org/issue/10420 .  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/ast-dump.cc
===================================================================
--- gcc/go/gofrontend/ast-dump.cc       (revision 223578)
+++ gcc/go/gofrontend/ast-dump.cc       (working copy)
@@ -65,6 +65,12 @@ class Ast_dump_traverse_statements : pub
 
 int Ast_dump_traverse_blocks_and_functions::block(Block * block)
 {
+  if (block == NULL)
+    {
+      this->ast_dump_context_->ostream() << std::endl;
+      return TRAVERSE_EXIT;
+    }
+
   this->ast_dump_context_->print_indent();
   this->ast_dump_context_->ostream() << "{" << std::endl;
   this->ast_dump_context_->indent();
@@ -466,4 +472,4 @@ Ast_dump_context::dump_to_stream(const E
 {
   Ast_dump_context adc(out, false);
   expr->dump_expression(&adc);
-}
\ No newline at end of file
+}

Reply via email to