Fixes #12667.
Change-Id: I68e73e26da9938606304163ae2637e3c6bacd6f6
Reviewed-on: https://go-review.googlesource.com/14722
Reviewed-by: Alan Donovan <adonovan@google.com>
{"testdata/errors.src"},
{"testdata/importdecl0a.src", "testdata/importdecl0b.src"},
{"testdata/importdecl1a.src", "testdata/importdecl1b.src"},
+ {"testdata/importC.src"}, // special handling in checkFiles
{"testdata/cycles.src"},
{"testdata/cycles1.src"},
{"testdata/cycles2.src"},
// typecheck and collect typechecker errors
var conf Config
+ // special case for importC.src
+ if len(testfiles) == 1 && testfiles[0] == "testdata/importC.src" {
+ conf.FakeImportC = true
+ }
conf.Importer = importer.Default()
conf.Error = func(err error) {
if *listErrors {
name := imp.name
if s.Name != nil {
name = s.Name.Name
+ if path == "C" {
+ // match cmd/compile (not prescribed by spec)
+ check.errorf(s.Name.Pos(), `cannot rename import "C"`)
+ continue
+ }
if name == "init" {
check.errorf(s.Name.Pos(), "cannot declare init - must be func")
continue
check.recordImplicit(s, obj)
}
+ if path == "C" {
+ // match cmd/compile (not prescribed by spec)
+ obj.used = true
+ }
+
// add import to file scope
if name == "." {
// merge imported scope with file scope
--- /dev/null
+// 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.
+
+package importC
+
+import "C"
+import _ /* ERROR cannot rename import "C" */ "C"
+import foo /* ERROR cannot rename import "C" */ "C"
+import . /* ERROR cannot rename import "C" */ "C"