aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-06-25 22:09:16 -0700
committerIan Lance Taylor <iant@golang.org>2022-06-28 10:24:59 -0700
commit74956337e8276e5bc9524104b01c147374dd94e7 (patch)
tree8dc0c411ab96c58e6913ebbb39c6dede11061d87 /gcc/go
parent53c4ef1e3cc103ce5bdf1d9923144e93b523102a (diff)
downloadgcc-74956337e8276e5bc9524104b01c147374dd94e7.zip
gcc-74956337e8276e5bc9524104b01c147374dd94e7.tar.gz
gcc-74956337e8276e5bc9524104b01c147374dd94e7.tar.bz2
compiler: use package path with embedded builtin type
The test case is https://go.dev/cl/414235. Fixes golang/go#52856 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/414294
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/names.cc29
2 files changed, 22 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 551ea65..13cb6ea 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d5b4abed2f206e492890acc20738e89617ea542c
+c7238f58a26131b7611eff6f555cab02af8a623c
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/names.cc b/gcc/go/gofrontend/names.cc
index f85d84c..dac7f20 100644
--- a/gcc/go/gofrontend/names.cc
+++ b/gcc/go/gofrontend/names.cc
@@ -831,15 +831,28 @@ Struct_type::do_mangled_name(Gogo* gogo, std::string* ret,
ret->push_back(' ');
}
- // For an anonymous field with an alias type, the field name
- // is the alias name.
- if (p->is_anonymous()
- && p->type()->named_type() != NULL
- && p->type()->named_type()->is_alias())
- p->type()->named_type()->append_symbol_type_name(gogo, true, ret,
- is_non_identifier);
+ const Type* ft = p->type();
+ const Named_type* nt = ft->named_type();
+
+ if (p->is_anonymous() && nt != NULL && nt->is_builtin())
+ {
+ // For an embedded field with a builtin type, we must
+ // include a package path. Otherwise embedding builtin
+ // types in different packages will produce identical
+ // types, which shouldn't happen because the builtin
+ // types are not exported.
+ ret->append(gogo->pkgpath());
+ ret->push_back('.');
+ nt->append_symbol_type_name(gogo, true, ret, is_non_identifier);
+ }
+ else if (p->is_anonymous() && nt != NULL && nt->is_alias())
+ {
+ // For an anonymous field with an alias type, the field name
+ // is the alias name.
+ nt->append_symbol_type_name(gogo, true, ret, is_non_identifier);
+ }
else
- this->append_mangled_name(p->type(), gogo, ret, is_non_identifier);
+ this->append_mangled_name(ft, gogo, ret, is_non_identifier);
if (p->has_tag())
{