This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Fix some type reflection strings
- 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: Tue, 02 Oct 2012 16:51:35 -0700
- Subject: Go patch committed: Fix some type reflection strings
This patch to the Go frontend fixes the type reflection strings in a
couple of cases to match those generated by the gc compiler. For an
empty struct, this generates "struct {}" rather than "struct { }". For
a type defined within a function, this generates pkg.type rather than
pkg.function_name$type. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch.
Ian
diff -r 83133095b520 go/types.cc
--- a/go/types.cc Tue Oct 02 15:19:17 2012 -0700
+++ b/go/types.cc Tue Oct 02 16:27:18 2012 -0700
@@ -4919,14 +4919,15 @@
void
Struct_type::do_reflection(Gogo* gogo, std::string* ret) const
{
- ret->append("struct { ");
+ ret->append("struct {");
for (Struct_field_list::const_iterator p = this->fields_->begin();
p != this->fields_->end();
++p)
{
if (p != this->fields_->begin())
- ret->append("; ");
+ ret->push_back(';');
+ ret->push_back(' ');
if (p->is_anonymous())
ret->push_back('?');
else
@@ -4959,7 +4960,10 @@
}
}
- ret->append(" }");
+ if (!this->fields_->empty())
+ ret->push_back(' ');
+
+ ret->push_back('}');
}
// Mangled name.
@@ -8390,6 +8394,7 @@
}
if (this->in_function_ != NULL)
{
+ ret->push_back('\t');
ret->append(Gogo::unpack_hidden_name(this->in_function_->name()));
ret->push_back('$');
if (this->in_function_index_ > 0)
@@ -8399,6 +8404,7 @@
ret->append(buf);
ret->push_back('$');
}
+ ret->push_back('\t');
}
ret->append(Gogo::unpack_hidden_name(this->named_object_->name()));
}