mirror of
https://github.com/golang/go
synced 2024-09-15 14:10:17 +00:00
cmd/gc: fix imported and not used error for import .
Fixes issues 6420. R=ken2 CC=golang-dev https://golang.org/cl/13703044
This commit is contained in:
parent
36f8480965
commit
5be1821a31
|
@ -2296,7 +2296,7 @@ pkgnotused(int lineno, Strlit *path, char *name)
|
|||
elem++;
|
||||
else
|
||||
elem = path->s;
|
||||
if(strcmp(elem, name) == 0)
|
||||
if(name == nil || strcmp(elem, name) == 0)
|
||||
yyerrorl(lineno, "imported and not used: \"%Z\"", path);
|
||||
else
|
||||
yyerrorl(lineno, "imported and not used: \"%Z\" as %s", path, name);
|
||||
|
@ -2335,7 +2335,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) {
|
||||
pkgnotused(s->def->pack->lineno, s->def->pack->pkg->path, s->name);
|
||||
pkgnotused(s->def->pack->lineno, s->def->pack->pkg->path, nil);
|
||||
s->def->pack->used = 1;
|
||||
}
|
||||
s->def = N;
|
||||
|
|
|
@ -14,5 +14,6 @@ import bufio "os" // ERROR "redeclared|redefinition|incompatible" "imported and
|
|||
|
||||
import (
|
||||
"fmt" // GCCGO_ERROR "previous|not used"
|
||||
fmt "math" // ERROR "redeclared|redefinition|incompatible" "imported and not used"
|
||||
fmt "math" // ERROR "redeclared|redefinition|incompatible" "imported and not used: \x22math\x22 as fmt"
|
||||
. "math" // ERROR "imported and not used: \x22math\x22$"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue