test: add some test cases that were miscompiled by gccgo

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/40310043
This commit is contained in:
Ian Lance Taylor 2013-12-10 10:47:30 -08:00
parent 4321beba85
commit 9bea6f3b2c
8 changed files with 113 additions and 0 deletions

View file

@ -0,0 +1,17 @@
// Copyright 2013 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 S interface{
F() T
}
type T struct {
S
}
type U struct {
error
}

View file

@ -0,0 +1,13 @@
// Copyright 2013 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 t a.T
func F() error {
return a.U{}
}

9
test/fixedbugs/bug480.go Normal file
View file

@ -0,0 +1,9 @@
// compiledir
// Copyright 2013 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 mishandled an import of a forward declared type.
package ignored

18
test/fixedbugs/bug481.go Normal file
View file

@ -0,0 +1,18 @@
// compile
// Copyright 2013 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.
// Returning an index into a conversion from string to slice caused a
// compilation error when using gccgo.
package p
func F1(s string) byte {
return []byte(s)[0]
}
func F2(s string) rune {
return []rune(s)[0]
}

20
test/fixedbugs/bug482.go Normal file
View file

@ -0,0 +1,20 @@
// compile
// Copyright 2013 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.
// Using the same name for a field in a composite literal and for a
// global variable that depends on the variable being initialized
// caused gccgo to erroneously report "variable initializer refers to
// itself".
package p
type S struct {
F int
}
var V = S{F: 1}
var F = V.F

View file

@ -0,0 +1,14 @@
// Copyright 2013 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 unexported struct {
a int
b bool
}
type Struct struct {
unexported
}

View file

@ -0,0 +1,12 @@
// Copyright 2013 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 "./a"
type s a.Struct
func main() {
}

View file

@ -0,0 +1,10 @@
// rundir
// Copyright 2013 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 6789: gccgo failed to find the hash function for an
// unexported struct embedded in an exported struct.
package ignored