Patchwork Go patch committed: Correct handling of methods which call recover

login
register
mail settings
Submitter Ian Taylor
Date Dec. 21, 2010, 9:14 p.m.
Message ID <mcrzkryltg3.fsf@google.com>
Download mbox | patch
Permalink /patch/76331/
State New
Headers show

Comments

Ian Taylor - Dec. 21, 2010, 9:14 p.m.
The complicated dance that the Go frontend does to handle functions
which call recover had some bugs when dealing with a method call.  This
patch fixes those bugs.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r cf19102d606a go/expressions.cc
--- a/go/expressions.cc	Tue Dec 21 12:30:43 2010 -0800
+++ b/go/expressions.cc	Tue Dec 21 13:04:41 2010 -0800
@@ -8630,6 +8630,7 @@ 
 	   pe != this->args_->end();
 	   ++pe, ++pp, ++i)
 	{
+	  gcc_assert(pp != params->end());
 	  tree arg_val = (*pe)->get_tree(context);
 	  args[i] = Expression::convert_for_assignment(context,
 						       pp->type(),
diff -r cf19102d606a go/gogo.cc
--- a/go/gogo.cc	Tue Dec 21 12:30:43 2010 -0800
+++ b/go/gogo.cc	Tue Dec 21 13:04:41 2010 -0800
@@ -2093,14 +2093,6 @@ 
   Expression* fn = Expression::make_func_reference(new_no, closure, location);
 
   Expression_list* args = new Expression_list();
-  if (orig_fntype->is_method())
-    {
-      Named_object* rec_no = gogo->lookup(receiver_name, NULL);
-      gcc_assert(rec_no != NULL
-		 && rec_no->is_variable()
-		 && rec_no->var_value()->is_parameter());
-      args->push_back(Expression::make_var_reference(rec_no, location));
-    }
   if (new_params != NULL)
     {
       // Note that we skip the last parameter, which is the boolean
@@ -2153,10 +2145,11 @@ 
 		 && !orig_rec_no->var_value()->is_receiver());
       orig_rec_no->var_value()->set_is_receiver();
 
-      Named_object* new_rec_no = new_bindings->lookup_local(receiver_name);
+      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()->is_receiver());
       new_rec_no->var_value()->set_is_not_receiver();
     }