This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash if a temporary is not defined
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Wed, 22 Dec 2010 08:21:09 -0800
- Subject: Go patch committed: Don't crash if a temporary is not defined
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 -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