aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEoghan Sherry <ejsherry@gmail.com>2010-12-07 16:16:01 -0500
committerRuss Cox <rsc@golang.org>2010-12-07 16:16:01 -0500
commitcab83650d17c004e041ba8f3f6ace1f2a125f9d8 (patch)
tree0022acd69cfe0049b415b75cd443a036b0222447
parentb15c4245c59e5658937d38b605a87394d8f3fe63 (diff)
downloadgo-cab83650d17c004e041ba8f3f6ace1f2a125f9d8.tar.gz
go-cab83650d17c004e041ba8f3f6ace1f2a125f9d8.zip
gc: skip undefined symbols in import .
Fixes #1284. R=ken3, rsc CC=golang-dev https://golang.org/cl/3210041
-rw-r--r--src/cmd/gc/subr.c2
-rw-r--r--test/fixedbugs/bug313.dir/a.go11
-rw-r--r--test/fixedbugs/bug313.dir/b.go11
-rw-r--r--test/fixedbugs/bug313.go19
4 files changed, 43 insertions, 0 deletions
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index 2ebacba6eb..8acf1cdfec 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -363,6 +363,8 @@ importdot(Pkg *opkg, Node *pack)
for(s = hash[h]; s != S; s = s->link) {
if(s->pkg != opkg)
continue;
+ if(s->def == N)
+ continue;
if(!exportname(s->name) || utfrune(s->name, 0xb7)) // 0xb7 = center dot
continue;
s1 = lookup(s->name);
diff --git a/test/fixedbugs/bug313.dir/a.go b/test/fixedbugs/bug313.dir/a.go
new file mode 100644
index 0000000000..cb4ca7256b
--- /dev/null
+++ b/test/fixedbugs/bug313.dir/a.go
@@ -0,0 +1,11 @@
+// Copyright 2010 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 main
+
+import "fmt"
+
+func a() {
+ fmt.DoesNotExist() // ERROR "undefined"
+}
diff --git a/test/fixedbugs/bug313.dir/b.go b/test/fixedbugs/bug313.dir/b.go
new file mode 100644
index 0000000000..7eda72b4f8
--- /dev/null
+++ b/test/fixedbugs/bug313.dir/b.go
@@ -0,0 +1,11 @@
+// Copyright 2010 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 main
+
+import . "fmt"
+
+func b() {
+ Println()
+}
diff --git a/test/fixedbugs/bug313.go b/test/fixedbugs/bug313.go
new file mode 100644
index 0000000000..eb2a0223b6
--- /dev/null
+++ b/test/fixedbugs/bug313.go
@@ -0,0 +1,19 @@
+// errchk $G -e $D/$F.dir/[ab].go
+
+// Copyright 2010 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 1284
+
+package bug313
+
+/*
+6g bug313.dir/[ab].go
+
+Before:
+bug313.dir/b.go:7: internal compiler error: fault
+
+Now:
+bug313.dir/a.go:10: undefined: fmt.DoesNotExist
+*/