From f739dae7db61e748c1a23e1fae32274e5431bbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Oudompheng?= Date: Fri, 10 Jan 2014 01:33:24 +0100 Subject: [PATCH] cmd/gc: mark OGOTO as a statement for formatters. Nodes of goto statements were corrupted when written to export data. Fixes #7023. R=rsc, dave, minux.ma CC=golang-codereviews https://golang.org/cl/46190043 --- src/cmd/gc/fmt.c | 1 + test/fixedbugs/issue7023.dir/a.go | 10 ++++++++++ test/fixedbugs/issue7023.dir/b.go | 11 +++++++++++ test/fixedbugs/issue7023.go | 10 ++++++++++ 4 files changed, 32 insertions(+) create mode 100644 test/fixedbugs/issue7023.dir/a.go create mode 100644 test/fixedbugs/issue7023.dir/b.go create mode 100644 test/fixedbugs/issue7023.go diff --git a/src/cmd/gc/fmt.c b/src/cmd/gc/fmt.c index 4217321831b9e5..6f40c7ff305e0f 100644 --- a/src/cmd/gc/fmt.c +++ b/src/cmd/gc/fmt.c @@ -1039,6 +1039,7 @@ static int opprec[] = { [OEMPTY] = -1, [OFALL] = -1, [OFOR] = -1, + [OGOTO] = -1, [OIF] = -1, [OLABEL] = -1, [OPROC] = -1, diff --git a/test/fixedbugs/issue7023.dir/a.go b/test/fixedbugs/issue7023.dir/a.go new file mode 100644 index 00000000000000..cdb54320955b83 --- /dev/null +++ b/test/fixedbugs/issue7023.dir/a.go @@ -0,0 +1,10 @@ +// Copyright 2014 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 a + +func Foo() { + goto bar +bar: +} diff --git a/test/fixedbugs/issue7023.dir/b.go b/test/fixedbugs/issue7023.dir/b.go new file mode 100644 index 00000000000000..c6fe40dfa27307 --- /dev/null +++ b/test/fixedbugs/issue7023.dir/b.go @@ -0,0 +1,11 @@ +// Copyright 2014 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 b + +import ( + "./a" +) + +var f = a.Foo diff --git a/test/fixedbugs/issue7023.go b/test/fixedbugs/issue7023.go new file mode 100644 index 00000000000000..f18c6113ef1a61 --- /dev/null +++ b/test/fixedbugs/issue7023.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2014 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 7023: corrupted export data when an inlined function +// contains a goto. + +package ignored