Commit 2abb463f by Ian Lance Taylor

compiler: Don't make void-typed temporaries.

    
    Fixes golang/go#11568.
    
    Reviewed-on: https://go-review.googlesource.com/12653

From-SVN: r226788
parent d2be285b
5891a4c0615f469edcefc6d7a85a88984ba940aa 3bd90ea170b9c9aecedd37796acdd2712b29922b
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -348,7 +348,15 @@ Statement::make_variable_declaration(Named_object* var) ...@@ -348,7 +348,15 @@ Statement::make_variable_declaration(Named_object* var)
Type* Type*
Temporary_statement::type() const 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. // Traversal.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment