diff mbox

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

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

Commit Message

Ian Lance Taylor March 3, 2011, 12:54 a.m. UTC
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
diff mbox

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)