aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-10-18 23:26:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-10-18 23:26:20 +0000
commit083e9210dba3a36111f8d2de740678b798e4b6d5 (patch)
treea564c70583ef6c7b92584b6ab06154508da26be6 /gcc/go
parentdbf9376f9ed37bc98218adde4e17d6ee34701179 (diff)
downloadgcc-083e9210dba3a36111f8d2de740678b798e4b6d5.zip
gcc-083e9210dba3a36111f8d2de740678b798e4b6d5.tar.gz
gcc-083e9210dba3a36111f8d2de740678b798e4b6d5.tar.bz2
compiler: add COMPARE_ALIASES flag for type compare and hash
Normally aliases compare as identical to the underlying type. Add a COMPARE_ALIASES flag to let them compare (and hash) differently. This will be used by later patches in this series. Reviewed-on: https://go-review.googlesource.com/c/143021 From-SVN: r265297
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/types.cc30
-rw-r--r--gcc/go/gofrontend/types.h3
3 files changed, 25 insertions, 10 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 28b3984..bb7ab78 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-9c985ce6f76dd65b8eb0e4b03c09ad0100712e04
+6f4bce815786ff3803741355f7f280e4e2c89668
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/types.cc b/gcc/go/gofrontend/types.cc
index e766c77..94b332a 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -349,9 +349,16 @@ Type::are_identical(const Type* t1, const Type* t2, int flags,
return (flags & COMPARE_ERRORS) == 0 ? true : t1 == t2;
}
- // Skip defined forward declarations. Ignore aliases.
- t1 = t1->unalias();
- t2 = t2->unalias();
+ // Skip defined forward declarations.
+ t1 = t1->forwarded();
+ t2 = t2->forwarded();
+
+ if ((flags & COMPARE_ALIASES) == 0)
+ {
+ // Ignore aliases.
+ t1 = t1->unalias();
+ t2 = t2->unalias();
+ }
if (t1 == t2)
return true;
@@ -923,12 +930,17 @@ Type::copy_expressions()
unsigned int
Type::hash_for_method(Gogo* gogo, int flags) const
{
- if (this->named_type() != NULL && this->named_type()->is_alias())
- return this->named_type()->real_type()->hash_for_method(gogo, flags);
- unsigned int ret = 0;
- if (this->classification_ != TYPE_FORWARD)
- ret += this->classification_;
- return ret + this->do_hash_for_method(gogo, flags);
+ const Type* t = this->forwarded();
+ if (t->named_type() != NULL && t->named_type()->is_alias())
+ {
+ unsigned int r =
+ t->named_type()->real_type()->hash_for_method(gogo, flags);
+ if ((flags & Type::COMPARE_ALIASES) != 0)
+ r += TYPE_FORWARD;
+ return r;
+ }
+ unsigned int ret = t->classification_;
+ return ret + t->do_hash_for_method(gogo, flags);
}
// Default implementation of do_hash_for_method. This is appropriate
diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h
index 18cc257..c99b08a 100644
--- a/gcc/go/gofrontend/types.h
+++ b/gcc/go/gofrontend/types.h
@@ -574,6 +574,9 @@ class Type
// struct field tags for purposes of type conversion.
static const int COMPARE_TAGS = 2;
+ // Compare aliases: treat an alias to T as distinct from T.
+ static const int COMPARE_ALIASES = 4;
+
// Return true if two types are identical. If this returns false,
// and REASON is not NULL, it may set *REASON.
static bool