Go patch committed: Don't crash on multiple results from void fn

Submitted by Ian Taylor on Dec. 22, 2010, 1:28 a.m.

Details

Message ID mcr39pqk33y.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Dec. 22, 2010, 1:28 a.m.
This patch fixes an ice-on-invalid in the Go frontend when a program
tried to get multiple results from a function which did not return any
results.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 2e6068faea8a go/expressions.cc
--- a/go/expressions.cc	Tue Dec 21 17:21:30 2010 -0800
+++ b/go/expressions.cc	Tue Dec 21 17:24:12 2010 -0800
@@ -8816,6 +8816,12 @@ 
   if (fntype == NULL)
     return Type::make_error_type();
   const Typed_identifier_list* results = fntype->results();
+  if (results == NULL)
+    {
+      this->report_error(_("number of results does not match "
+			   "number of values"));
+      return Type::make_error_type();
+    }
   Typed_identifier_list::const_iterator pr = results->begin();
   for (unsigned int i = 0; i < this->index_; ++i)
     {