Patchwork Go patch committed: Don't finalize methods more than once

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

Comments

Ian Taylor - Dec. 21, 2010, 10:33 p.m.
This patch to the Go frontend prevents the compiler from trying to
finalize the methods for a type more than once.  This avoids an endless
loop in an invalid case.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 7975dbfdedb1 go/types.cc
--- a/go/types.cc	Tue Dec 21 13:12:12 2010 -0800
+++ b/go/types.cc	Tue Dec 21 14:29:10 2010 -0800
@@ -3698,6 +3698,8 @@ 
 void
 Struct_type::finalize_methods(Gogo* gogo)
 {
+  if (this->all_methods_ != NULL)
+    return;
   Type::finalize_methods(gogo, this, this->location_, &this->all_methods_);
 }
 
@@ -6615,6 +6617,9 @@ 
 void
 Named_type::finalize_methods(Gogo* gogo)
 {
+  if (this->all_methods_ != NULL)
+    return;
+
   if (this->local_methods_ != NULL
       && (this->points_to() != NULL || this->interface_type() != NULL))
     {