From 480cc89916ef34ec51c77b894a5e3781545a1e6c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 22 Dec 2010 16:21:06 +0000 Subject: Don't crash if a temporary is not defined due to errors. From-SVN: r168173 --- gcc/go/gofrontend/statements.cc | 13 +++++++++++++ gcc/go/gofrontend/statements.h | 6 +----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'gcc/go') 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 -- cgit v1.1