aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-08-27 23:09:37 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-08-27 23:09:37 +0000
commitb281000393220c7ce754f42c8d73b4ea9efe5657 (patch)
treeff8e1e8088a82aa764a04cc7c779b01cff468d9d /gcc/go
parent26343eaf9d25412f6deba7eae9117fc5e9bc02cc (diff)
downloadgcc-b281000393220c7ce754f42c8d73b4ea9efe5657.zip
gcc-b281000393220c7ce754f42c8d73b4ea9efe5657.tar.gz
gcc-b281000393220c7ce754f42c8d73b4ea9efe5657.tar.bz2
compiler: Report unused variables initialized to function literals.
Fixes golang/go#12317. Reviewed-on: https://go-review.googlesource.com/13908 From-SVN: r227285
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/gogo.cc15
2 files changed, 9 insertions, 8 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index dc519b2..beb095a 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -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.
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index ea9104f..233ee27 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -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
@@ -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());
}