diff mbox

Go patch committed: Don't crash on bad receiver

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

Commit Message

Ian Lance Taylor Feb. 24, 2011, 2:51 a.m. UTC
This patch to the Go frontend avoids a crash when a method receiver is
erroneous when building recover thunks.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r e3de25810f55 go/gogo.cc
--- a/go/gogo.cc	Wed Feb 23 18:41:59 2011 -0800
+++ b/go/gogo.cc	Wed Feb 23 18:46:55 2011 -0800
@@ -2205,10 +2205,14 @@ 
 
       const std::string& new_receiver_name(orig_fntype->receiver()->name());
       Named_object* new_rec_no = new_bindings->lookup_local(new_receiver_name);
-      gcc_assert(new_rec_no != NULL
-		 && new_rec_no->is_variable()
-		 && new_rec_no->var_value()->is_receiver());
-      new_rec_no->var_value()->set_is_not_receiver();
+      if (new_rec_no == NULL)
+	gcc_assert(saw_errors());
+      else
+	{
+	  gcc_assert(new_rec_no->is_variable()
+		     && new_rec_no->var_value()->is_receiver());
+	  new_rec_no->var_value()->set_is_not_receiver();
+	}
     }
 
   // Because we flipped blocks but not types, the can_recover