Go patch committed: Don't crash on function from different package

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

Commit Message

Ian Taylor Feb. 15, 2011, 6:55 p.m.
This patch to the Go frontend avoids crashing when generating a function
from a different package.  Today that can only happen via an erroneous
use of "import .".  In the future, however, I plan to make it possible
to inline functions across packages, in which case a function defined in
a different package should be treated as the equivalent of a
__gnu_inline function.  This patch is a small step toward that goal
which avoids the crash.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.



diff -r cb75be61dd62 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Thu Feb 10 22:35:55 2011 -0800
+++ b/go/gogo-tree.cc	Tue Feb 15 10:49:58 2011 -0800
@@ -1252,8 +1252,9 @@ 
 	  this->fndecl_ = decl;
-	  gcc_assert(no->package() == NULL);
-	  if (this->enclosing_ != NULL || Gogo::is_thunk(no))
+	  if (no->package() != NULL)
+	    ;
+	  else if (this->enclosing_ != NULL || Gogo::is_thunk(no))
 	  else if (Gogo::unpack_hidden_name(no->name()) == "init"
 		   && !this->type_->is_method())