Patchwork Go patch committed: Don't crash on interface loops of forwarding types

login
register
mail settings
Submitter Ian Taylor
Date Feb. 15, 2011, 7:53 p.m.
Message ID <mcrei795b26.fsf@google.com>
Download mbox | patch
Permalink /patch/83289/
State New
Headers show

Comments

Ian Taylor - Feb. 15, 2011, 7:53 p.m.
This patch to the Go frontend avoids crashing when there is an interface
loop involving forwarding types--types which are seen before they are
defined.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 31a6b335fc55 go/types.cc
--- a/go/types.cc	Tue Feb 15 11:41:00 2011 -0800
+++ b/go/types.cc	Tue Feb 15 11:48:40 2011 -0800
@@ -5659,7 +5659,7 @@ 
 	{
 	  if (q->name().empty())
 	    {
-	      if (q->type() == p->type())
+	      if (q->type()->forwarded() == p->type()->forwarded())
 		error_at(p->location(), "interface inheritance loop");
 	      else
 		{
@@ -5667,7 +5667,8 @@ 
 		  for (i = from + 1; i < this->methods_->size(); ++i)
 		    {
 		      const Typed_identifier* r = &this->methods_->at(i);
-		      if (r->name().empty() && r->type() == q->type())
+		      if (r->name().empty()
+			  && r->type()->forwarded() == q->type()->forwarded())
 			{
 			  error_at(p->location(),
 				   "inherited interface listed twice");