From 3868d6bfa679afaf881699faa86ea73dc5bd441f Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 21 Dec 2010 18:31:48 +0000 Subject: [PATCH] Report errors for temporary statements rather than crashing. From-SVN: r168128 --- gcc/go/gofrontend/statements.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 97b89551e279..047045cffc37 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -350,7 +350,18 @@ void Temporary_statement::do_check_types(Gogo*) { if (this->type_ != NULL && this->init_ != NULL) - gcc_assert(Type::are_assignable(this->type_, this->init_->type(), NULL)); + { + std::string reason; + if (!Type::are_assignable(this->type_, this->init_->type(), &reason)) + { + if (reason.empty()) + error_at(this->location(), "incompatible types in assignment"); + else + error_at(this->location(), "incompatible types in assignment (%s)", + reason.c_str()); + this->set_is_error(); + } + } } // Return a tree.