]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove incannedimport
authorMatthew Dempsky <mdempsky@google.com>
Mon, 12 Sep 2016 20:39:54 +0000 (13:39 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 12 Sep 2016 21:35:10 +0000 (21:35 +0000)
This used to be used to give special semantics to the builtin
definitions of package runtime and unsafe, but none of those are
relevant anymore:

- The builtin runtime and unsafe packages do not risk triggering false
  import cycles since they no longer contain `import "runtime"`.

- bimport.go never creates ODCLTYPE, so no need to special case them.

- "incannedimport != 0" is only true when "importpkg != nil" anyway,
  so "incannedimport == 0 && importpkg == nil" is equivalent to just
  "importpkg == nil".

Change-Id: I076f15dd705d4962e7a4c33972e304ef67e7effb
Reviewed-on: https://go-review.googlesource.com/29084
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/typecheck.go

index 713a7f4610ab8d2ac5a1ddeee6a73d7199de2922..cde3476271026af46614984e1570134ac2323009 100644 (file)
@@ -289,7 +289,7 @@ func (p *importer) pkg() *Pkg {
        } else if pkg.Name != name {
                Yyerror("conflicting package names %s and %s for path %q", pkg.Name, name, path)
        }
-       if incannedimport == 0 && myimportpath != "" && path == myimportpath {
+       if myimportpath != "" && path == myimportpath {
                Yyerror("import %q: package depends on %q (import cycle)", importpkg.Path, path)
                errorexit()
        }
index 5c273bbd30dedf5cbb8e90c2b82cf49d877d0ec4..756c4d73588bc65b806833796f0568a282e03ce5 100644 (file)
@@ -231,8 +231,6 @@ var funcsyms []*Node
 
 var dclcontext Class // PEXTERN/PAUTO
 
-var incannedimport int
-
 var statuniqgen int // name generator for static temps
 
 var iota_ int32
index 42dfbdc773cbd434d46848c9972aaee84b62a4de..a52ad8cc50f82598758c9f3bc1383d8585f50856 100644 (file)
@@ -685,15 +685,12 @@ func loadsys() {
 
        block = 1
        iota_ = -1000000
-       incannedimport = 1
 
        importpkg = Runtimepkg
        Import(bufio.NewReader(strings.NewReader(runtimeimport)))
        importpkg = unsafepkg
        Import(bufio.NewReader(strings.NewReader(unsafeimport)))
-
        importpkg = nil
-       incannedimport = 0
 }
 
 func importfile(f *Val, indent []byte) {
index 49685cf13c18ed80da56949649f30ba7caa91078..aee38874ad470ee8ab4db957c42cf7ceaef0fc6f 100644 (file)
@@ -2096,9 +2096,7 @@ OpSwitch:
        case ODCLTYPE:
                ok |= Etop
                n.Left = typecheck(n.Left, Etype)
-               if incannedimport == 0 {
-                       checkwidth(n.Left.Type)
-               }
+               checkwidth(n.Left.Type)
                break OpSwitch
        }
 
@@ -2114,7 +2112,7 @@ OpSwitch:
                }
        }
 
-       if safemode && incannedimport == 0 && importpkg == nil && compiling_wrappers == 0 && t != nil && t.Etype == TUNSAFEPTR {
+       if safemode && importpkg == nil && compiling_wrappers == 0 && t != nil && t.Etype == TUNSAFEPTR {
                Yyerror("cannot use unsafe.Pointer")
        }