OSDN Git Service

Don't crash if a temporary is not defined due to errors.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 2010 16:21:06 +0000 (16:21 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 2010 16:21:06 +0000 (16:21 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168173 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 047045c..fcc16d1 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 6ca586f..80cdffe 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