Skip to content

Commit 9f2ed78

Browse files
author
ian
committed
compiler: Report unused variables initialized to function literals.
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
1 parent 1b8b2b2 commit 9f2ed78

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

gcc/go/gofrontend/MERGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
9ae5835a010a55fba875103be5f4e61485a97099
1+
3aa2ea272e475010da8b480fc3095d0cd7254d12
22

33
The first line of this file holds the git revision number of the last
44
merge done from the gofrontend repository.

gcc/go/gofrontend/gogo.cc

+8-7
Original file line numberDiff line numberDiff line change
@@ -3156,6 +3156,7 @@ Check_types_traverse::variable(Named_object* named_object)
31563156
error_at(var->location(),
31573157
"incompatible type in initialization (%s)",
31583158
reason.c_str());
3159+
init = Expression::make_error(named_object->location());
31593160
var->clear_init();
31603161
}
31613162
else if (init != NULL
@@ -3180,13 +3181,13 @@ Check_types_traverse::variable(Named_object* named_object)
31803181
no->message_name().c_str());
31813182
}
31823183
}
3183-
else if (!var->is_used()
3184-
&& !var->is_global()
3185-
&& !var->is_parameter()
3186-
&& !var->is_receiver()
3187-
&& !var->type()->is_error()
3188-
&& (init == NULL || !init->is_error_expression())
3189-
&& !Lex::is_invalid_identifier(named_object->name()))
3184+
if (!var->is_used()
3185+
&& !var->is_global()
3186+
&& !var->is_parameter()
3187+
&& !var->is_receiver()
3188+
&& !var->type()->is_error()
3189+
&& (init == NULL || !init->is_error_expression())
3190+
&& !Lex::is_invalid_identifier(named_object->name()))
31903191
error_at(var->location(), "%qs declared and not used",
31913192
named_object->message_name().c_str());
31923193
}

0 commit comments

Comments
 (0)