FAQ
Reviewers: golang-dev_googlegroups.com, rsc, lvd,

Message:
Hello golang-dev@googlegroups.com, rsc@golang.org, lvd@google.com (cc:
golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
cmd/gc: fix incomplete export data when inlining with local variables.

When local declarations needed unexported types, these could
be missing in the export data.

Fixes build with -gcflags -lll, except for exp/gotype.

Please review this at http://codereview.appspot.com/6813067/

Affected files:
M src/cmd/gc/export.c
A test/fixedbugs/bug467.dir/p1.go
A test/fixedbugs/bug467.dir/p2.go
A test/fixedbugs/bug467.dir/p3.go
A test/fixedbugs/bug467.go


Index: src/cmd/gc/export.c
===================================================================
--- a/src/cmd/gc/export.c
+++ b/src/cmd/gc/export.c
@@ -119,6 +119,17 @@
}
break;

+ case ODCL:
+ // Local variables in the bodies need their type.
+ t = n->left->type;
+ if(t != types[t->etype] && t != idealbool && t != idealstring) {
+ if(isptr[t->etype])
+ t = t->type;
+ if (t && t->sym && t->sym->def && t->sym->pkg != localpkg &&
t->sym->pkg != builtinpkg) {
+ exportlist = list(exportlist, t->sym->def);
+ }
+ }
+ break;

case OLITERAL:
t = n->type;
Index: test/fixedbugs/bug467.dir/p1.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/bug467.dir/p1.go
@@ -0,0 +1,5 @@
+package p1
+
+type SockaddrUnix int
+
+func (s SockaddrUnix) Error() string { return "blah" }
Index: test/fixedbugs/bug467.dir/p2.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/bug467.dir/p2.go
@@ -0,0 +1,5 @@
+package p2
+
+import "./p1"
+
+func SockUnix() error { var s *p1.SockaddrUnix; return s }
Index: test/fixedbugs/bug467.dir/p3.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/bug467.dir/p3.go
@@ -0,0 +1,7 @@
+package main
+
+import "./p2"
+
+func main() {
+ _ = p2.SockUnix()
+}
Index: test/fixedbugs/bug467.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/bug467.go
@@ -0,0 +1,10 @@
+// compiledir
+
+// Copyright 2012 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.
+
+// Exported data for inlining could forget types of
+// local variables declared in inlinable bodies.
+
+package ignored

Search Discussions

  • Russ Cox at Nov 1, 2012 at 5:17 pm
    LGTM
  • Remyoudompheng at Nov 1, 2012 at 6:06 pm
    *** Submitted as
    http://code.google.com/p/go/source/detail?r=d9a624c22a62 ***

    cmd/gc: fix incomplete export data when inlining with local variables.

    When local declarations needed unexported types, these could
    be missing in the export data.

    Fixes build with -gcflags -lll, except for exp/gotype.

    R=golang-dev, rsc, lvd
    CC=golang-dev
    http://codereview.appspot.com/6813067


    http://codereview.appspot.com/6813067/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 31, '12 at 9:53p
activeNov 1, '12 at 6:06p
posts3
users2
websitegolang.org

2 users in discussion

Remyoudompheng: 2 posts Russ Cox: 1 post

People

Translate

site design / logo © 2021 Grokbase