diff mbox

Go patch committed: Don't crash if a temporary is not defined

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

Commit Message

Ian Lance Taylor Dec. 22, 2010, 4:21 p.m. UTC
This patch to the Go frontend avoids a compiler crash if a temporary is
not defined due to errors.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r f0539ea34ab9 go/statements.cc
--- a/go/statements.cc	Wed Dec 22 07:55:23 2010 -0800
+++ b/go/statements.cc	Wed Dec 22 08:17:25 2010 -0800
@@ -299,6 +299,19 @@ 
   return this->type_ != NULL ? this->type_ : this->init_->type();
 }
 
+// Return the tree for the temporary variable.
+
+tree
+Temporary_statement::get_decl() const
+{
+  if (this->decl_ == NULL)
+    {
+      gcc_assert(saw_errors());
+      return error_mark_node;
+    }
+  return this->decl_;
+}
+
 // Traversal.
 
 int
diff -r f0539ea34ab9 go/statements.h
--- a/go/statements.h	Wed Dec 22 07:55:23 2010 -0800
+++ b/go/statements.h	Wed Dec 22 08:17:25 2010 -0800
@@ -487,11 +487,7 @@ 
   // Return the tree for the temporary variable itself.  This should
   // not be called until after the statement itself has been expanded.
   tree
-  get_decl() const
-  {
-    gcc_assert(this->decl_ != NULL);
-    return this->decl_;
-  }
+  get_decl() const;
 
  protected:
   int