Skip to content

Commit

Permalink
compiler: Report unused variables initialized to function literals.
Browse files Browse the repository at this point in the history
    
    Fixes golang/go#12317.
    
    Reviewed-on: https://go-review.googlesource.com/13908


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227285 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ian committed Aug 27, 2015
1 parent 1b8b2b2 commit 9f2ed78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gcc/go/gofrontend/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
9ae5835a010a55fba875103be5f4e61485a97099
3aa2ea272e475010da8b480fc3095d0cd7254d12

The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
15 changes: 8 additions & 7 deletions gcc/go/gofrontend/gogo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3156,6 +3156,7 @@ Check_types_traverse::variable(Named_object* named_object)
error_at(var->location(),
"incompatible type in initialization (%s)",
reason.c_str());
init = Expression::make_error(named_object->location());
var->clear_init();
}
else if (init != NULL
Expand All @@ -3180,13 +3181,13 @@ Check_types_traverse::variable(Named_object* named_object)
no->message_name().c_str());
}
}
else if (!var->is_used()
&& !var->is_global()
&& !var->is_parameter()
&& !var->is_receiver()
&& !var->type()->is_error()
&& (init == NULL || !init->is_error_expression())
&& !Lex::is_invalid_identifier(named_object->name()))
if (!var->is_used()
&& !var->is_global()
&& !var->is_parameter()
&& !var->is_receiver()
&& !var->type()->is_error()
&& (init == NULL || !init->is_error_expression())
&& !Lex::is_invalid_identifier(named_object->name()))
error_at(var->location(), "%qs declared and not used",
named_object->message_name().c_str());
}
Expand Down

0 comments on commit 9f2ed78

Please sign in to comment.