Patchwork Go patch committed: Don't crash on erroneous named result

login
register
mail settings
Submitter Ian Taylor
Date March 3, 2011, 12:54 a.m.
Message ID <mcrmxld3twf.fsf@google.com>
Download mbox | patch
Permalink /patch/85197/
State New
Headers show

Comments

Ian Taylor - March 3, 2011, 12:54 a.m.
This patch to the Go frontend avoids crashing if there is an erroneous
named result, such as a result parameter with the same name as a regular
parameter.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r a43381c7d981 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed Mar 02 16:40:45 2011 -0800
+++ b/go/gogo-tree.cc	Wed Mar 02 16:45:21 2011 -0800
@@ -1786,8 +1786,14 @@ 
   // defer statements, the result variables may be unnamed.
   bool is_named = !results->front().name().empty();
   if (is_named)
-    gcc_assert(this->named_results_ != NULL
-	       && this->named_results_->size() == results->size());
+    {
+      gcc_assert(this->named_results_ != NULL);
+      if (this->named_results_->size() != results->size())
+	{
+	  gcc_assert(saw_errors());
+	  return error_mark_node;
+	}
+    }
 
   tree retval;
   if (results->size() == 1)