Patchwork Go patch committed: Avoid crash when selecting on non-channel

login
register
mail settings
Submitter Ian Taylor
Date Jan. 4, 2011, 5:42 p.m.
Message ID <mcr62u4r2f3.fsf@google.com>
Download mbox | patch
Permalink /patch/77505/
State New
Headers show

Comments

Ian Taylor - Jan. 4, 2011, 5:42 p.m.
This patch to the Go frontend avoids a compiler crash when a select
statement is used with a send or receive with some value that is not a
channel.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r f59f14d1d82a go/statements.cc
--- a/go/statements.cc	Thu Dec 23 17:25:38 2010 -0800
+++ b/go/statements.cc	Tue Jan 04 07:34:25 2011 -0800
@@ -4165,6 +4165,14 @@ 
 	  continue;
 	}
 
+      if (p->channel()->type()->channel_type() == NULL)
+	{
+	  // We should have given an error in the send or receive
+	  // statement we created via lowering.
+	  gcc_assert(saw_errors());
+	  return error_mark_node;
+	}
+
       tree channel_tree = p->channel()->get_tree(context);
       if (channel_tree == error_mark_node)
 	return error_mark_node;