Patchwork Go patch committed: Don't crash on defer of type conversion

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

Comments

Ian Taylor - Feb. 15, 2011, 7:52 p.m.
Code like "defer T(v)" where T is a type and v is a value is invalid.
However, since this is a type conversion which looks like a function
call, it may not be detected as invalid at parse time.  This patch
avoids a crash where such a type conversion is used with defer.
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");