]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gc: fix imported and not used message - show path
authorRuss Cox <rsc@golang.org>
Thu, 4 Mar 2010 01:23:47 +0000 (17:23 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 4 Mar 2010 01:23:47 +0000 (17:23 -0800)
R=ken2
CC=golang-dev
https://golang.org/cl/229046

src/cmd/gc/lex.c
src/cmd/gc/subr.c
src/cmd/gc/walk.c
test/import4.go [new file with mode: 0644]

index e6db4e7a7a3a59295abe4792efa8a389b74898f6..8afc737f38ddbc3ea1d449d7704ee7c6e5416af3 100644 (file)
@@ -1610,7 +1610,7 @@ mkpackage(char* pkgname)
                                        // errors if a conflicting top-level name is
                                        // introduced by a different file.
                                        if(!s->def->used && !nsyntaxerrors)
-                                               yyerrorl(s->def->lineno, "imported and not used: %s", s->def->sym->name);
+                                               yyerrorl(s->def->lineno, "imported and not used: %Z", s->def->pkg->path);
                                        s->def = N;
                                        continue;
                                }
@@ -1618,7 +1618,7 @@ mkpackage(char* pkgname)
                                        // throw away top-level name left over
                                        // from previous import . "x"
                                        if(s->def->pack != N && !s->def->pack->used && !nsyntaxerrors) {
-                                               yyerrorl(s->def->pack->lineno, "imported and not used: %s", s->def->pack->sym->name);
+                                               yyerrorl(s->def->pack->lineno, "imported and not used: %Z", s->def->pack->pkg->path);
                                                s->def->pack->used = 1;
                                        }
                                        s->def = N;
index f6ca359e890b7bb1229527c0a415979a991fa2ab..d3354c904b5224ca919e2c5235dddaadc3c4ec50 100644 (file)
@@ -360,7 +360,7 @@ importdot(Pkg *opkg, Node *pack)
        }
        if(n == 0) {
                // can't possibly be used - there were no symbols
-               yyerrorl(pack->lineno, "imported and not used: %s", pack->sym->name);
+               yyerrorl(pack->lineno, "imported and not used: %Z", opkg->path);
        }
 }
 
index fa63646c50dea21c27afe07c13527ff6bd5fac85..2f151307abdf15e57da7568efe2bed5c16dc89b6 100644 (file)
@@ -1128,7 +1128,6 @@ walkexpr(Node **np, NodeList **init)
        case OARRAYLIT:
        case OMAPLIT:
        case OSTRUCTLIT:
-       arraylit:
                nvar = nod(OXXX, N, N);
                tempname(nvar, n->type);
                anylit(n, nvar, init);
diff --git a/test/import4.go b/test/import4.go
new file mode 100644 (file)
index 0000000..1ae1d0e
--- /dev/null
@@ -0,0 +1,24 @@
+// $G $D/empty.go && errchk $G $D/$F.go
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// various kinds of imported and not used
+
+// standard
+import "fmt"   // ERROR "imported and not used.*fmt"
+
+// renamed
+import X "math"        // ERROR "imported and not used.*math"
+
+// import dot
+import . "bufio"       // ERROR "imported and not used.*bufio"
+
+// again, package without anything in it
+import "./empty"       // ERROR "imported and not used.*empty"
+import Z "./empty"     // ERROR "imported and not used.*empty"
+import . "./empty"     // ERROR "imported and not used.*empty"
+