Commit 5be1821a authored by Russ Cox's avatar Russ Cox

cmd/gc: fix imported and not used error for import .

Fixes issues 6420.

R=ken2
CC=golang-dev
https://golang.org/cl/13703044
parent 36f84809
......@@ -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$"
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment