diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-22 16:21:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-22 16:21:06 +0000 |
commit | 480cc89916ef34ec51c77b894a5e3781545a1e6c (patch) | |
tree | 162e28a65f8c5d29defa904a5c9bade83b68d753 | |
parent | 1d9fa70c34069d3b341e07ada11dde6cd029207b (diff) | |
download | gcc-480cc89916ef34ec51c77b894a5e3781545a1e6c.zip gcc-480cc89916ef34ec51c77b894a5e3781545a1e6c.tar.gz gcc-480cc89916ef34ec51c77b894a5e3781545a1e6c.tar.bz2 |
Don't crash if a temporary is not defined due to errors.
From-SVN: r168173
-rw-r--r-- | gcc/go/gofrontend/statements.cc | 13 | ||||
-rw-r--r-- | gcc/go/gofrontend/statements.h | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 047045c..fcc16d1 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -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 diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index 6ca586f..80cdffe 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -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 |