From: Ian Lance Taylor Date: Mon, 4 Jul 2022 19:20:36 +0000 (-0700) Subject: compiler: better error message for unknown package name X-Git-Tag: basepoints/gcc-14~5694 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccc39d9e97ce24623aefae2097bff791e01619d9;p=thirdparty%2Fgcc.git compiler: better error message for unknown package name Fixes golang/go#51237 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415994 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 7b1d3011fffe..461e2fdf2715 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -6479d5976c5d848ec6f5843041275723a00006b0 +a209dca9ec918535977dcab99fd9bb60986ffacd 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/parse.cc b/gcc/go/gofrontend/parse.cc index a3c6f630a093..c93d82bba395 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -191,7 +191,11 @@ Parse::qualified_ident(std::string* pname, Named_object** ppackage) Named_object* package = this->gogo_->lookup(name, NULL); if (package == NULL || !package->is_package()) { - go_error_at(this->location(), "expected package"); + if (package == NULL) + go_error_at(this->location(), "reference to undefined name %qs", + Gogo::message_name(name).c_str()); + else + go_error_at(this->location(), "expected package"); // We expect . IDENTIFIER; skip both. if (this->advance_token()->is_identifier()) this->advance_token(); diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue27938.go b/gcc/testsuite/go.test/test/fixedbugs/issue27938.go index ed974e642df5..aecc67678ac2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue27938.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue27938.go @@ -11,13 +11,13 @@ package p type _ struct { - F sync.Mutex // ERROR "undefined: sync|expected package" + F sync.Mutex // ERROR "undefined: sync|expected package|reference to undefined name" } type _ struct { - sync.Mutex // ERROR "undefined: sync|expected package" + sync.Mutex // ERROR "undefined: sync|expected package|reference to undefined name" } type _ interface { - sync.Mutex // ERROR "undefined: sync|expected package|expected signature or type name" + sync.Mutex // ERROR "undefined: sync|expected package|expected signature or type name|reference to undefined name" }