OSDN Git Service

Report errors for temporary statements rather than crashing.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Dec 2010 18:31:48 +0000 (18:31 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Dec 2010 18:31:48 +0000 (18:31 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168128 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/statements.cc

index 97b8955..047045c 100644 (file)
@@ -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.