]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix imported and not used error for import .
authorRuss Cox <rsc@golang.org>
Fri, 20 Sep 2013 19:25:43 +0000 (15:25 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 20 Sep 2013 19:25:43 +0000 (15:25 -0400)
Fixes issues 6420.

R=ken2
CC=golang-dev
https://golang.org/cl/13703044

src/cmd/gc/lex.c
test/import1.go

index 414456adf2e84fc4f511667d2f4ca1eb7e30347c..a1473eb407fad67a38c1efeab2bcca4bbc7e244b 100644 (file)
@@ -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;
index 56b29d58c066e0987bd6b46b89b6c1703f2c8953..d2bb55cbff5a85db88223adb00a738a11a3a4851 100644 (file)
@@ -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$"
 )