diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-27 20:51:55 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-27 20:51:55 +0000 |
commit | 4a197d64cbb29606c45e52b66dcab8ba287c9177 (patch) | |
tree | 9671a37b42e4daa0938b753c69f2e6fcc7d9ee77 /gcc/go | |
parent | ea16999619a352c06b27b289dd5426c7a4dd76eb (diff) | |
download | gcc-4a197d64cbb29606c45e52b66dcab8ba287c9177.zip gcc-4a197d64cbb29606c45e52b66dcab8ba287c9177.tar.gz gcc-4a197d64cbb29606c45e52b66dcab8ba287c9177.tar.bz2 |
compiler: structs inherit all methods from embedded pointer fields.
Previously if a struct S contained an embedded field *T,
a method with receiver *T would not be promoted to a method
with value receiver S.
From-SVN: r200493
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/types.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 3fe2090..0a86d47 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -9396,13 +9396,18 @@ Type::find_field_or_method(const Type* type, fnt = pf->type()->deref()->named_type(); go_assert(fnt != NULL); + // Methods with pointer receivers on embedded field are + // inherited by the pointer to struct, and also by the struct + // type if the field itself is a pointer. + bool can_be_pointer = (receiver_can_be_pointer + || pf->type()->points_to() != NULL); int sublevel = level == NULL ? 1 : *level + 1; bool sub_is_method; std::string subambig1; std::string subambig2; bool subfound = Type::find_field_or_method(fnt, name, - receiver_can_be_pointer, + can_be_pointer, seen, &sublevel, &sub_is_method, |