Commit 054a721d authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: read safemode bit from package header

Ignore respective bit in export data, but leave the info to
minimize format changes for 1.7. Scheduled to remove by 1.8.

For #15772.

Change-Id: Ifb3beea655367308a4e2d5dc8cb625915f904287
Reviewed-on: https://go-review.googlesource.com/23285
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent cc0d8c86
......@@ -103,7 +103,9 @@ func Import(in *bufio.Reader) {
// --- compiler-specific export data ---
// read compiler-specific flags
importpkg.Safe = p.bool()
// read but ignore safemode bit (see issue #15772)
p.bool() // formerly: importpkg.Safe = p.bool()
// phase 2
objcount = 0
......
......@@ -784,6 +784,21 @@ func importfile(f *Val, indent []byte) {
}
}
// process header lines
for {
p, err = imp.ReadString('\n')
if err != nil {
log.Fatalf("reading input: %v", err)
}
if p == "\n" {
break // header ends with blank line
}
if strings.HasPrefix(p, "safe") {
importpkg.Safe = true
break // ok to ignore rest
}
}
// assume files move (get installed)
// so don't record the full path.
linehistpragma(file[len(file)-len(path_)-2:]) // acts as #pragma lib
......
......@@ -398,11 +398,8 @@ func (p *parser) import_package() {
p.import_error()
}
importsafe := false
// read but skip "safe" bit (see issue #15772)
if p.tok == LNAME {
if p.sym_.Name == "safe" {
importsafe = true
}
p.next()
}
p.want(';')
......@@ -413,7 +410,6 @@ func (p *parser) import_package() {
} else if importpkg.Name != name {
Yyerror("conflicting names %s and %s for package %q", importpkg.Name, name, importpkg.Path)
}
importpkg.Safe = importsafe
typecheckok = true
defercheckwidth()
......
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