diff mbox

Go patch committed: Don't create void-typed temporaries

Message ID CAOyqgcV0PvBd4A1hfNnV7yJErx4uEwf2-cbnJLp2ZR-gDX_e8w@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 11, 2015, 9:56 p.m. UTC
This patch by Chris Manghane changes the Go frontend to not create a
temporary with void type.  This fixes https://golang.org/issue/11568 .
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 226719)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -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: gcc/go/gofrontend/statements.cc
===================================================================
--- gcc/go/gofrontend/statements.cc	(revision 226510)
+++ gcc/go/gofrontend/statements.cc	(working copy)
@@ -348,7 +348,15 @@  Statement::make_variable_declaration(Nam
 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.