]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: better error message for unknown package name
authorIan Lance Taylor <iant@golang.org>
Mon, 4 Jul 2022 19:20:36 +0000 (12:20 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Jul 2022 00:08:02 +0000 (17:08 -0700)
Fixes golang/go#51237

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415994

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/parse.cc
gcc/testsuite/go.test/test/fixedbugs/issue27938.go

index 7b1d3011fffe93eeed5fffa47e3caee133c71425..461e2fdf271548220fa305c024834059da5750fc 100644 (file)
@@ -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.
index a3c6f630a093ac9edc84693915027697f69b5368..c93d82bba39590421d577c9a969b3a1ad5ef9292 100644 (file)
@@ -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();
index ed974e642df576a34a1fdfca8e7b55672eecf819..aecc67678ac28159d2265a68b0d4e553fe34fcf7 100644 (file)
 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"
 }