From: Cherry Zhang Date: Tue, 2 Jul 2019 19:36:59 +0000 (-0400) Subject: test: add a test for gccgo bug #32901 X-Git-Tag: go1.13rc1~128 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1c1e517005786daeca0e77f2be6769e9b8e1f5a5;p=gostls13.git test: add a test for gccgo bug #32901 This CL adds a test for gccgo bug #32901: not all the type descriptors are registered and thus deduplicated with types created by reflection. It needs a few levels of indirect imports to trigger this bug. Updates #32901. Change-Id: Idbd89bedd63fea746769f2687f3f31c9767e5ec0 Reviewed-on: https://go-review.googlesource.com/c/go/+/184718 Reviewed-by: Ian Lance Taylor --- diff --git a/test/fixedbugs/issue32901.dir/a.go b/test/fixedbugs/issue32901.dir/a.go new file mode 100644 index 0000000000..54ed7713f6 --- /dev/null +++ b/test/fixedbugs/issue32901.dir/a.go @@ -0,0 +1,15 @@ +// Copyright 2019 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 + +type T struct { x int } + +func F() interface{} { + return [2]T{} +} + +func P() interface{} { + return &[2]T{} +} diff --git a/test/fixedbugs/issue32901.dir/b.go b/test/fixedbugs/issue32901.dir/b.go new file mode 100644 index 0000000000..932d7b0afa --- /dev/null +++ b/test/fixedbugs/issue32901.dir/b.go @@ -0,0 +1,15 @@ +// Copyright 2019 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" + +func F() interface{} { + return a.F() +} + +func P() interface{} { + return a.P() +} diff --git a/test/fixedbugs/issue32901.dir/c.go b/test/fixedbugs/issue32901.dir/c.go new file mode 100644 index 0000000000..5f31c7ff02 --- /dev/null +++ b/test/fixedbugs/issue32901.dir/c.go @@ -0,0 +1,17 @@ +// Copyright 2019 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 c + +import "./b" + +func F() interface{} { + go func(){}() // make it non-inlineable + return b.F() +} + +func P() interface{} { + go func(){}() // make it non-inlineable + return b.P() +} diff --git a/test/fixedbugs/issue32901.dir/main.go b/test/fixedbugs/issue32901.dir/main.go new file mode 100644 index 0000000000..28bb8cde28 --- /dev/null +++ b/test/fixedbugs/issue32901.dir/main.go @@ -0,0 +1,18 @@ +// Copyright 2019 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 "./c" +import "reflect" + +func main() { + x := c.F() + p := c.P() + t := reflect.PtrTo(reflect.TypeOf(x)) + tp := reflect.TypeOf(p) + if t != tp { + panic("FAIL") + } +} diff --git a/test/fixedbugs/issue32901.go b/test/fixedbugs/issue32901.go new file mode 100644 index 0000000000..004c3da79e --- /dev/null +++ b/test/fixedbugs/issue32901.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2019 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 32901: type descriptor equality bug in gccgo. + +package ignored