This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Fix bug leading to invalid initializer loop report
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Thu, 20 Mar 2014 12:37:52 -0700
- Subject: Go patch committed: Fix bug leading to invalid initializer loop report
- Authentication-results: sourceware.org; auth=none
This patch by Chris Manghane fixes a bug in which gccgo could
incorrectly report an invalid initializer loop when a struct field name
is confused with a variable name. This is http://golang.org/issue/7590.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
diff -r d43179a88410 go/expressions.cc
--- a/go/expressions.cc Mon Mar 17 21:25:04 2014 -0700
+++ b/go/expressions.cc Thu Mar 20 11:49:49 2014 -0700
@@ -12993,6 +12993,20 @@
{
// The type may not be resolvable at this point.
Type* type = this->type_;
+
+ for (int depth = this->depth_; depth > 0; --depth)
+ {
+ if (type->array_type() != NULL)
+ type = type->array_type()->element_type();
+ else if (type->map_type() != NULL)
+ type = type->map_type()->val_type();
+ else
+ {
+ // This error will be reported during lowering.
+ return TRAVERSE_CONTINUE;
+ }
+ }
+
while (true)
{
if (type->classification() == Type::TYPE_NAMED)