aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-06-22 16:40:24 -0700
committerIan Lance Taylor <iant@golang.org>2022-06-23 12:22:05 -0700
commit038a7150ec07770174907b93bc93caaa1e019f92 (patch)
tree58f3a7346fb1160912a2918dd688e0a54eb316ad /gcc
parent0b14f590e3e9d95b8211b77d992589d5ab4c25f0 (diff)
downloadgcc-038a7150ec07770174907b93bc93caaa1e019f92.zip
gcc-038a7150ec07770174907b93bc93caaa1e019f92.tar.gz
gcc-038a7150ec07770174907b93bc93caaa1e019f92.tar.bz2
compiler: unalias types for hash/equality functions
Test case is https://go.dev/cl/413694. Fixes golang/go#52846 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413660
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/gogo.cc2
-rw-r--r--gcc/go/gofrontend/types.cc17
3 files changed, 14 insertions, 7 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 737bc48..629bc66 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-77821de1a149c2e6ef9c154ae384c16292173039
+6c3752315dc9b82d0f3f3ac646a1e7376818f84a
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 d35c6ba..e13df0d 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -2811,7 +2811,7 @@ Specific_type_functions::type(Type* t)
case Type::TYPE_MAP:
{
- Type* key_type = t->map_type()->key_type();
+ Type* key_type = t->map_type()->key_type()->unalias();
if (key_type->needs_specific_type_functions(this->gogo_))
key_type->hash_function(this->gogo_, NULL);
}
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index eb3afd9..39aea76 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -1764,6 +1764,9 @@ Type::needs_specific_type_functions(Gogo* gogo)
Named_object*
Type::hash_function(Gogo* gogo, Function_type* hash_fntype)
{
+ if (this->named_type() != NULL)
+ go_assert(!this->named_type()->is_alias());
+
if (!this->is_comparable())
return NULL;
@@ -2067,6 +2070,9 @@ Type::write_identity_hash(Gogo* gogo, int64_t size)
Named_object*
Type::equal_function(Gogo* gogo, Named_type* name, Function_type* equal_fntype)
{
+ if (this->named_type() != NULL)
+ go_assert(!this->named_type()->is_alias());
+
// If the unaliased type is not a named type, then the type does not
// have a name after all.
if (name != NULL)
@@ -6700,7 +6706,8 @@ Struct_type::write_hash_function(Gogo* gogo, Function_type* hash_fntype)
subkey = Expression::make_cast(key_arg_type, subkey, bloc);
// Get the hash function to use for the type of this field.
- Named_object* hash_fn = pf->type()->hash_function(gogo, hash_fntype);
+ Named_object* hash_fn =
+ pf->type()->unalias()->hash_function(gogo, hash_fntype);
// Call the hash function for the field, passing retval as the seed.
ref = Expression::make_temporary_reference(retval, bloc);
@@ -7553,8 +7560,8 @@ Array_type::write_hash_function(Gogo* gogo, Function_type* hash_fntype)
gogo->start_block(bloc);
// Get the hash function for the element type.
- Named_object* hash_fn = this->element_type_->hash_function(gogo,
- hash_fntype);
+ Named_object* hash_fn =
+ this->element_type_->unalias()->hash_function(gogo, hash_fntype);
// Get a pointer to this element in the loop.
Expression* subkey = Expression::make_temporary_reference(key, bloc);
@@ -8441,8 +8448,8 @@ Map_type::do_type_descriptor(Gogo* gogo, Named_type* name)
++p;
go_assert(p->is_field_name("hasher"));
Function_type* hasher_fntype = p->type()->function_type();
- Named_object* hasher_fn = this->key_type_->hash_function(gogo,
- hasher_fntype);
+ Named_object* hasher_fn =
+ this->key_type_->unalias()->hash_function(gogo, hasher_fntype);
if (hasher_fn == NULL)
vals->push_back(Expression::make_cast(hasher_fntype,
Expression::make_nil(bloc),