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

login
register
mail settings
Submitter Ian Taylor
Date Dec. 22, 2010, 1:28 a.m.
Message ID <mcr39pqk33y.fsf@google.com>
Download mbox | patch
Permalink /patch/76353/
State New
Headers show

Comments

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

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)
     {