]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix some C to Go translation leftovers
authorDidier Spezia <didier.06@gmail.com>
Wed, 7 Oct 2015 22:25:25 +0000 (22:25 +0000)
committerMinux Ma <minux@golang.org>
Thu, 8 Oct 2015 01:51:24 +0000 (01:51 +0000)
Following the C to Go translation, some useless variables
were left in the code. In fmt.go, this was harmless.
In lex.go, it broke the error message related to
non-canonical import paths.

Fix it, and remove the useless variables.

The added test case is ignored in the go/types tests, since
the behavior of the non-canonical import path check seems
to be different.

Fixes #11362

Change-Id: Ic9129139ede90357dc79ebf167af638cf44536fa
Reviewed-on: https://go-review.googlesource.com/15580
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/lex.go
src/go/types/stdlib_test.go
test/fixedbugs/issue11362.go [new file with mode: 0644]

index e5ddf9f50a790cbb83b1d3093582cb8030d71bcd..b6d44d5fc39d97f6b76d3f78553e811370ef799d 100644 (file)
@@ -1595,8 +1595,6 @@ func Sconv(s *Sym, flag int) string {
 
        sf := flag
        sm := setfmode(&flag)
-       var r int
-       _ = r
        str := symfmt(s, flag)
        flag = sf
        fmtmode = sm
@@ -1631,8 +1629,6 @@ func Tconv(t *Type, flag int) string {
                flag |= obj.FmtUnsigned
        }
 
-       var r int
-       _ = r
        str := typefmt(t, flag)
 
        if fmtmode == FTypeId && (sf&obj.FmtUnsigned != 0) {
@@ -1659,8 +1655,6 @@ func Nconv(n *Node, flag int) string {
        sf := flag
        sm := setfmode(&flag)
 
-       var r int
-       _ = r
        var str string
        switch fmtmode {
        case FErr, FExp:
@@ -1693,8 +1687,6 @@ func Hconv(l *NodeList, flag int) string {
 
        sf := flag
        sm := setfmode(&flag)
-       var r int
-       _ = r
        sep := "; "
        if fmtmode == FDbg {
                sep = "\n"
index 1fafdf453c77d6517d4e22fa761bd5921f34d4a6..340e37fc6b1fa58d264fdaffe1355f9a4fa16c42 100644 (file)
@@ -595,9 +595,7 @@ func findpkg(name string) (file string, ok bool) {
        // local imports should be canonicalized already.
        // don't want to see "encoding/../encoding/base64"
        // as different from "encoding/base64".
-       var q string
-       _ = q
-       if path.Clean(name) != name {
+       if q := path.Clean(name); q != name {
                Yyerror("non-canonical import path %q (should be %q)", name, q)
                return "", false
        }
index c6c946e976a349d85b280b3d796f7f5f7b8de55e..8fc2ee145109feac53dbc1c8d6943b060551ebb4 100644 (file)
@@ -150,6 +150,7 @@ func TestStdFixed(t *testing.T) {
                "issue7746.go",   // large constants - consumes too much memory
                "issue11326.go",  // large constants
                "issue11326b.go", // large constants
+               "issue11362.go",  // canonical import path check
        )
 }
 
diff --git a/test/fixedbugs/issue11362.go b/test/fixedbugs/issue11362.go
new file mode 100644 (file)
index 0000000..680b0e5
--- /dev/null
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2015 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.
+
+// Issue 11362: prints empty canonical import path
+
+package main
+
+import _ "unicode//utf8" // ERROR "non-canonical import path .unicode//utf8. \(should be .unicode/utf8.\)" "can't find import: .unicode//utf8."
+
+func main() {
+}
+