Don't crash if a temporary is not defined due to errors.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 16:21:06 +0000 (16:21 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 22 Dec 2010 16:21:06 +0000 (16:21 +0000)
From-SVN: r168173

gcc/go/gofrontend/statements.cc
gcc/go/gofrontend/statements.h

index 047045cffc372619bed5b4050e6a8bd2ce8c35f0..fcc16d14332d884f08ff8b7e6b4fc706ff73c7e1 100644 (file)
@@ -299,6 +299,19 @@ Temporary_statement::type() const
   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
index 6ca586f10a9cf9c9ae0a405f0dd2a698337ee7af..80cdffe801ec2fe406304793b0c4a5fa329438cf 100644 (file)
@@ -487,11 +487,7 @@ class Temporary_statement : public Statement
   // 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