diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-11-28 12:41:06 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-30 12:03:25 -0800 |
commit | 38f10841817a9fee28ee97c7115b6f4d24f5245d (patch) | |
tree | 1467d4540985e0a2b4bd566c685a5d90a25f38ea /gcc/go | |
parent | 4f32eced9d01c610bd53e8c59b83bcb5402eddb5 (diff) | |
download | gcc-38f10841817a9fee28ee97c7115b6f4d24f5245d.zip gcc-38f10841817a9fee28ee97c7115b6f4d24f5245d.tar.gz gcc-38f10841817a9fee28ee97c7115b6f4d24f5245d.tar.bz2 |
compiler: better error messages for missing interface method
For golang/go#10700
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273886
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index c14a10f..af4d052 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -534fb907c821b052dc430330708d7fa555b91fe3 +68b1c7659a6b25d537a4ff3365ab070fa6215b0b 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 286ecc1..23d1647 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -12052,6 +12052,15 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr, ambig2.c_str()); else if (found_pointer_method) go_error_at(location, "method requires a pointer receiver"); + else if (it != NULL && it->is_empty()) + go_error_at(location, + "reference to method %qs in interface with no methods", + Gogo::message_name(name).c_str()); + else if (it == NULL && type->deref()->interface_type() != NULL) + go_error_at(location, + ("reference to method %qs in type that is " + "pointer to interface, not interface"), + Gogo::message_name(name).c_str()); else if (nt == NULL && st == NULL && it == NULL) go_error_at(location, ("reference to field %qs in object which " |