Patchwork Go patch committed: Don't crash on array with erroneous length

login
register
mail settings
Submitter Ian Taylor
Date Dec. 22, 2010, 4:47 p.m.
Message ID <mcr1v59hhz7.fsf@google.com>
Download mbox | patch
Permalink /patch/76435/
State New
Headers show

Comments

Ian Taylor - Dec. 22, 2010, 4:47 p.m.
This patch to the Go frontend avoids a crash on an array type with an
erroneous length expression.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 035d537723d7 go/types.cc
--- a/go/types.cc	Wed Dec 22 08:37:27 2010 -0800
+++ b/go/types.cc	Wed Dec 22 08:45:10 2010 -0800
@@ -4359,8 +4359,12 @@ 
 	  // expression.  FIXME: This won't work in general.
 	  Translate_context context(gogo, NULL, NULL, NULL_TREE);
 	  tree len = this->length_->get_tree(&context);
-	  len = convert_to_integer(integer_type_node, len);
-	  this->length_tree_ = save_expr(len);
+	  if (len != error_mark_node)
+	    {
+	      len = convert_to_integer(integer_type_node, len);
+	      len = save_expr(len);
+	    }
+	  this->length_tree_ = len;
 	}
     }
   return this->length_tree_;