]> Cypherpunks repositories - gostls13.git/commitdiff
test: add test that gccgo compiled incorrectly
authorIan Lance Taylor <iant@golang.org>
Tue, 6 May 2014 13:01:38 +0000 (09:01 -0400)
committerIan Lance Taylor <iant@golang.org>
Tue, 6 May 2014 13:01:38 +0000 (09:01 -0400)
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/94100045

test/fixedbugs/bug485.go [new file with mode: 0644]

diff --git a/test/fixedbugs/bug485.go b/test/fixedbugs/bug485.go
new file mode 100644 (file)
index 0000000..1544753
--- /dev/null
@@ -0,0 +1,39 @@
+// run
+
+// 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.
+
+// Gccgo chose the wrong embedded method when the same type appeared
+// at different levels and the correct choice was not the first
+// appearance of the type in a depth-first search.
+
+package main
+
+type embedded string
+
+func (s embedded) val() string {
+       return string(s)
+}
+
+type A struct {
+       embedded
+}
+
+type B struct {
+       A
+       embedded
+}
+
+func main() {
+       b := &B{
+               A: A{
+                       embedded: "a",
+               },
+               embedded: "b",
+       }
+       s := b.val()
+       if s != "b" {
+               panic(s)
+       }
+}