compiler: Don't make void-typed temporaries.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 11 Aug 2015 21:37:26 +0000 (21:37 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 11 Aug 2015 21:37:26 +0000 (21:37 +0000)
    Fixes golang/go#11568.

    Reviewed-on: https://go-review.googlesource.com/12653

From-SVN: r226788

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/statements.cc

index a5b77a452f8278414ffacd50e0a389663f8f4aa5..2696ea5b36d88bd3c21d4b499ef891251acdd1a9 100644 (file)
@@ -1,4 +1,4 @@
-5891a4c0615f469edcefc6d7a85a88984ba940aa
+3bd90ea170b9c9aecedd37796acdd2712b29922b
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 96c142c6eab91344ec1def04bfa4dd670a89e647..40b437382f020ef74a2f5e751fcfb3905f455d4e 100644 (file)
@@ -348,7 +348,15 @@ Statement::make_variable_declaration(Named_object* var)
 Type*
 Temporary_statement::type() const
 {
-  return this->type_ != NULL ? this->type_ : this->init_->type();
+  Type* type = this->type_ != NULL ? this->type_ : this->init_->type();
+
+  // Temporary variables cannot have a void type.
+  if (type->is_void_type())
+    {
+      go_assert(saw_errors());
+      return Type::make_error_type();
+    }
+  return type;
 }
 
 // Traversal.