Patchwork Go patch committed: Fix abstract types in temporary statements

login
register
mail settings
Submitter Ian Taylor
Date Jan. 4, 2011, 7:02 p.m.
Message ID <mcrk4ikpk4l.fsf@google.com>
Download mbox | patch
Permalink /patch/77514/
State New
Headers show

Comments

Ian Taylor - Jan. 4, 2011, 7:02 p.m.
This patch to the Go frontend fixes the handling of abstract types in
temporary statements.  We must not let the expression have an abstract
type, even if the temporary statement was created with one.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r e06d82844ddb go/statements.cc
--- a/go/statements.cc	Tue Jan 04 10:51:43 2011 -0800
+++ b/go/statements.cc	Tue Jan 04 10:59:57 2011 -0800
@@ -340,6 +340,9 @@ 
 void
 Temporary_statement::do_determine_types()
 {
+  if (this->type_ != NULL && this->type_->is_abstract())
+    this->type_ = this->type_->make_non_abstract_type();
+
   if (this->init_ != NULL)
     {
       if (this->type_ == NULL)
@@ -352,10 +355,10 @@ 
     }
 
   if (this->type_ == NULL)
-    this->type_ = this->init_->type();
-
-  if (this->type_->is_abstract())
-    this->type_ = this->type_->make_non_abstract_type();
+    {
+      this->type_ = this->init_->type();
+      gcc_assert(!this->type_->is_abstract());
+    }
 }
 
 // Check types.