Skip to content

Commit

Permalink
compiler: Don't make void-typed temporaries.
Browse files Browse the repository at this point in the history
Fixes golang/go#11568.

Change-Id: Ic1384bcb770a959320808c847bf0e8e12380a659
Reviewed-on: https://go-review.googlesource.com/12653
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Aug 11, 2015
1 parent 5891a4c commit 3bd90ea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion go/statements.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3bd90ea

Please sign in to comment.