]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgo: update to go1.8rc2
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Jan 2017 22:18:42 +0000 (22:18 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 23 Jan 2017 22:18:42 +0000 (22:18 +0000)
    Fix a bug in the generation of the hash value in reflect.FuncOf.

    The merge script missed a bunch of testdata files over the years.
    Copy them over.

    Reviewed-on: https://go-review.googlesource.com/35570

From-SVN: r244835

121 files changed:
gcc/go/gofrontend/MERGE
libgo/MERGE
libgo/VERSION
libgo/go/cmd/go/bug.go
libgo/go/cmd/go/test.go
libgo/go/cmd/go/testdata/failssh/ssh [new file with mode: 0644]
libgo/go/cmd/go/testdata/src/badc/x.c [new file with mode: 0644]
libgo/go/cmd/go/testdata/src/canonical/a/vendor/c/c.go [moved from libgo/go/cmd/go/testdata/src/canonical/a/c/c.go with 100% similarity]
libgo/go/cmd/go/testdata/src/dupload/vendor/p/p.go [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/emptydecl.golden [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/emptydecl.input [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/ranges.golden [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/ranges.input [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin5.golden [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin5.input [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin6.golden [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin6.input [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin7.golden [new file with mode: 0644]
libgo/go/cmd/gofmt/testdata/stdin7.input [new file with mode: 0644]
libgo/go/compress/bzip2/bzip2_test.go
libgo/go/compress/flate/deflate.go
libgo/go/compress/flate/deflate_test.go
libgo/go/compress/flate/deflatefast.go
libgo/go/compress/gzip/issue14937_test.go
libgo/go/crypto/ecdsa/testdata/SigVer.rsp.bz2 [new file with mode: 0644]
libgo/go/crypto/tls/cipher_suites.go
libgo/go/crypto/tls/tls.go
libgo/go/crypto/x509/cert_pool.go
libgo/go/crypto/x509/root_windows.go
libgo/go/crypto/x509/x509_test.go
libgo/go/go/ast/scope.go
libgo/go/go/doc/doc_test.go
libgo/go/go/internal/gccgoimporter/testdata/complexnums.gox [new file with mode: 0644]
libgo/go/go/internal/gccgoimporter/testdata/conversions.gox [new file with mode: 0644]
libgo/go/go/internal/gccgoimporter/testdata/imports.gox [new file with mode: 0644]
libgo/go/go/internal/gccgoimporter/testdata/pointer.gox [new file with mode: 0644]
libgo/go/go/internal/gccgoimporter/testdata/time.gox [new file with mode: 0644]
libgo/go/go/internal/gccgoimporter/testdata/unicode.gox [new file with mode: 0644]
libgo/go/go/parser/performance_test.go
libgo/go/go/types/testdata/blank.src [new file with mode: 0644]
libgo/go/go/types/testdata/builtins.src [new file with mode: 0644]
libgo/go/go/types/testdata/const0.src [new file with mode: 0644]
libgo/go/go/types/testdata/const1.src [new file with mode: 0644]
libgo/go/go/types/testdata/constdecl.src [new file with mode: 0644]
libgo/go/go/types/testdata/conversions.src [new file with mode: 0644]
libgo/go/go/types/testdata/conversions2.src [new file with mode: 0644]
libgo/go/go/types/testdata/cycles.src [new file with mode: 0644]
libgo/go/go/types/testdata/cycles1.src [new file with mode: 0644]
libgo/go/go/types/testdata/cycles2.src [new file with mode: 0644]
libgo/go/go/types/testdata/cycles3.src [new file with mode: 0644]
libgo/go/go/types/testdata/cycles4.src [new file with mode: 0644]
libgo/go/go/types/testdata/decls0.src [new file with mode: 0644]
libgo/go/go/types/testdata/decls1.src [new file with mode: 0644]
libgo/go/go/types/testdata/decls2a.src [new file with mode: 0644]
libgo/go/go/types/testdata/decls2b.src [new file with mode: 0644]
libgo/go/go/types/testdata/decls3.src [new file with mode: 0644]
libgo/go/go/types/testdata/errors.src [new file with mode: 0644]
libgo/go/go/types/testdata/expr0.src [new file with mode: 0644]
libgo/go/go/types/testdata/expr1.src [new file with mode: 0644]
libgo/go/go/types/testdata/expr2.src [new file with mode: 0644]
libgo/go/go/types/testdata/expr3.src [new file with mode: 0644]
libgo/go/go/types/testdata/gotos.src [new file with mode: 0644]
libgo/go/go/types/testdata/importC.src [new file with mode: 0644]
libgo/go/go/types/testdata/importdecl0a.src [new file with mode: 0644]
libgo/go/go/types/testdata/importdecl0b.src [new file with mode: 0644]
libgo/go/go/types/testdata/importdecl1a.src [new file with mode: 0644]
libgo/go/go/types/testdata/importdecl1b.src [new file with mode: 0644]
libgo/go/go/types/testdata/init0.src [new file with mode: 0644]
libgo/go/go/types/testdata/init1.src [new file with mode: 0644]
libgo/go/go/types/testdata/init2.src [new file with mode: 0644]
libgo/go/go/types/testdata/issues.src [new file with mode: 0644]
libgo/go/go/types/testdata/labels.src [new file with mode: 0644]
libgo/go/go/types/testdata/methodsets.src [new file with mode: 0644]
libgo/go/go/types/testdata/shifts.src [new file with mode: 0644]
libgo/go/go/types/testdata/stmt0.src [new file with mode: 0644]
libgo/go/go/types/testdata/stmt1.src [new file with mode: 0644]
libgo/go/go/types/testdata/vardecl.src [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g01.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g01.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g02.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g02.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g04.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn0g04.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn2c16.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn2c16.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbbn3p08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbgn2c16.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbgn2c16.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbgn3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbgn3p08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbrn2c08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbrn2c08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbwn0g16.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbwn0g16.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbwn3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbwn3p08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbyn3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftbyn3p08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n0g08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n0g08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n2c08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n2c08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp0n3p08.sng [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp1n3p08.png [new file with mode: 0644]
libgo/go/image/png/testdata/pngsuite/ftp1n3p08.sng [new file with mode: 0644]
libgo/go/mime/testdata/test.types.plan9 [new file with mode: 0644]
libgo/go/net/http/serve_test.go
libgo/go/net/http/server.go
libgo/go/net/http/transport_test.go
libgo/go/os/os_test.go
libgo/go/reflect/all_test.go
libgo/go/reflect/type.go
libgo/go/runtime/testdata/testprogcgo/threadpanic_unix.c [new file with mode: 0644]
libgo/go/runtime/testdata/testprogcgo/threadpanic_windows.c [new file with mode: 0644]
libgo/go/runtime/testdata/testprogcgo/tracebackctxt_c.c [new file with mode: 0644]
libgo/go/testing/benchmark.go
libgo/go/testing/sub_test.go
libgo/go/testing/testing.go
libgo/merge.sh

index 03586265b45d73d4fb8cf1b68e74da1aecefcf19..f29acdf595d4ef230f388e17b3c846b6509b4012 100644 (file)
@@ -1,4 +1,4 @@
-0655e25d8e4acfac50c6b1422dc32eca3e30803a
+fb609ff6d940768cf4db4ab7deb93b2ab686e45d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index a126b52ed78969060fb5c2b73a53f83a1e6da70f..92541dfc6e31523adf76f74b0d4743479b7d2350 100644 (file)
@@ -1,4 +1,4 @@
-3de6e96e4b8147f5267a2e8218a7c780b09a434f
+59f181b6fda68ece22882945853ca2df9dbf1c88
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
index 3076f40768f2dedd87439587793efd680b895a7e..212211f54d1c9a3652e99bea8a65faaf8875ea5f 100644 (file)
@@ -1 +1 @@
-go1.8rc1
+go1.8rc2
index cbd258b80bde5f030f5f791ec831e368c89bed6a..658f6dabd90417b7c4efd8608948560f5f0365b2 100644 (file)
@@ -20,11 +20,10 @@ import (
 var cmdBug = &Command{
        Run:       runBug,
        UsageLine: "bug",
-       Short:     "print information for bug reports",
+       Short:     "start a bug report",
        Long: `
-Bug prints information that helps file effective bug reports.
-
-Bugs may be reported at https://golang.org/issue/new.
+Bug opens the default browser and starts a new bug report.
+The report includes useful system information.
        `,
 }
 
index 37f6327fffe2bf6b79058f34dfb50802bdef3856..5c13b653f014f689577be89b148d1e0156d2515e 100644 (file)
@@ -906,9 +906,13 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
 
        if buildContext.GOOS == "darwin" {
                if buildContext.GOARCH == "arm" || buildContext.GOARCH == "arm64" {
-                       t.NeedCgo = true
+                       t.IsIOS = true
+                       t.NeedOS = true
                }
        }
+       if t.TestMain == nil {
+               t.NeedOS = true
+       }
 
        for _, cp := range pmain.imports {
                if len(cp.coverVars) > 0 {
@@ -1355,7 +1359,8 @@ type testFuncs struct {
        NeedTest    bool
        ImportXtest bool
        NeedXtest   bool
-       NeedCgo     bool
+       NeedOS      bool
+       IsIOS       bool
        Cover       []coverInfo
 }
 
@@ -1456,7 +1461,7 @@ var testmainTmpl = template.Must(template.New("main").Parse(`
 package main
 
 import (
-{{if not .TestMain}}
+{{if .NeedOS}}
        "os"
 {{end}}
        "testing"
@@ -1472,8 +1477,10 @@ import (
        _cover{{$i}} {{$p.Package.ImportPath | printf "%q"}}
 {{end}}
 
-{{if .NeedCgo}}
+{{if .IsIOS}}
+       "os/signal"
        _ "runtime/cgo"
+       "syscall"
 {{end}}
 )
 
@@ -1535,6 +1542,32 @@ func coverRegisterFile(fileName string, counter []uint32, pos []uint32, numStmts
 {{end}}
 
 func main() {
+{{if .IsIOS}}
+       // Send a SIGUSR2, which will be intercepted by LLDB to
+       // tell the test harness that installation was successful.
+       // See misc/ios/go_darwin_arm_exec.go.
+       signal.Notify(make(chan os.Signal), syscall.SIGUSR2)
+       syscall.Kill(0, syscall.SIGUSR2)
+       signal.Reset(syscall.SIGUSR2)
+
+       // The first argument supplied to an iOS test is an offset
+       // suffix for the current working directory.
+       // Process it here, and remove it from os.Args.
+       const hdr = "cwdSuffix="
+       if len(os.Args) < 2 || len(os.Args[1]) <= len(hdr) || os.Args[1][:len(hdr)] != hdr {
+               panic("iOS test not passed a working directory suffix")
+       }
+       suffix := os.Args[1][len(hdr):]
+       dir, err := os.Getwd()
+       if err != nil {
+               panic(err)
+       }
+       if err := os.Chdir(dir + "/" + suffix); err != nil {
+               panic(err)
+       }
+       os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
+{{end}}
+
 {{if .CoverEnabled}}
        testing.RegisterCover(testing.Cover{
                Mode: {{printf "%q" .CoverMode}},
diff --git a/libgo/go/cmd/go/testdata/failssh/ssh b/libgo/go/cmd/go/testdata/failssh/ssh
new file mode 100644 (file)
index 0000000..ecdbef9
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+exit 1
diff --git a/libgo/go/cmd/go/testdata/src/badc/x.c b/libgo/go/cmd/go/testdata/src/badc/x.c
new file mode 100644 (file)
index 0000000..f6cbf69
--- /dev/null
@@ -0,0 +1 @@
+// C code!
diff --git a/libgo/go/cmd/go/testdata/src/dupload/vendor/p/p.go b/libgo/go/cmd/go/testdata/src/dupload/vendor/p/p.go
new file mode 100644 (file)
index 0000000..c89cd18
--- /dev/null
@@ -0,0 +1 @@
+package p
diff --git a/libgo/go/cmd/gofmt/testdata/emptydecl.golden b/libgo/go/cmd/gofmt/testdata/emptydecl.golden
new file mode 100644 (file)
index 0000000..33d6435
--- /dev/null
@@ -0,0 +1,14 @@
+//gofmt -s
+
+// Test case for issue 7631.
+
+package main
+
+// Keep this declaration
+var ()
+
+const (
+// Keep this declaration
+)
+
+func main() {}
diff --git a/libgo/go/cmd/gofmt/testdata/emptydecl.input b/libgo/go/cmd/gofmt/testdata/emptydecl.input
new file mode 100644 (file)
index 0000000..4948a61
--- /dev/null
@@ -0,0 +1,16 @@
+//gofmt -s
+
+// Test case for issue 7631.
+
+package main
+
+// Keep this declaration
+var ()
+
+const (
+// Keep this declaration
+)
+
+type ()
+
+func main() {}
\ No newline at end of file
diff --git a/libgo/go/cmd/gofmt/testdata/ranges.golden b/libgo/go/cmd/gofmt/testdata/ranges.golden
new file mode 100644 (file)
index 0000000..506b3a0
--- /dev/null
@@ -0,0 +1,30 @@
+//gofmt -s
+
+// Test cases for range simplification.
+package p
+
+func _() {
+       for a, b = range x {
+       }
+       for a = range x {
+       }
+       for _, b = range x {
+       }
+       for range x {
+       }
+
+       for a = range x {
+       }
+       for range x {
+       }
+
+       for a, b := range x {
+       }
+       for a := range x {
+       }
+       for _, b := range x {
+       }
+
+       for a := range x {
+       }
+}
diff --git a/libgo/go/cmd/gofmt/testdata/ranges.input b/libgo/go/cmd/gofmt/testdata/ranges.input
new file mode 100644 (file)
index 0000000..df5f833
--- /dev/null
@@ -0,0 +1,20 @@
+//gofmt -s
+
+// Test cases for range simplification.
+package p
+
+func _() {
+       for a, b = range x {}
+       for a, _ = range x {}
+       for _, b = range x {}
+       for _, _ = range x {}
+
+       for a = range x {}
+       for _ = range x {}
+
+       for a, b := range x {}
+       for a, _ := range x {}
+       for _, b := range x {}
+
+       for a := range x {}
+}
diff --git a/libgo/go/cmd/gofmt/testdata/stdin5.golden b/libgo/go/cmd/gofmt/testdata/stdin5.golden
new file mode 100644 (file)
index 0000000..31ce6b2
--- /dev/null
@@ -0,0 +1,3 @@
+//gofmt -stdin
+
+i := 5 // Line comment without newline.
\ No newline at end of file
diff --git a/libgo/go/cmd/gofmt/testdata/stdin5.input b/libgo/go/cmd/gofmt/testdata/stdin5.input
new file mode 100644 (file)
index 0000000..0a7c97d
--- /dev/null
@@ -0,0 +1,3 @@
+//gofmt -stdin
+
+i  :=5// Line comment without newline.
\ No newline at end of file
diff --git a/libgo/go/cmd/gofmt/testdata/stdin6.golden b/libgo/go/cmd/gofmt/testdata/stdin6.golden
new file mode 100644 (file)
index 0000000..ffcea80
--- /dev/null
@@ -0,0 +1,19 @@
+       //gofmt -stdin
+
+       if err != nil {
+               source := strings.NewReader(`line 1.
+line 2.
+`)
+               return source
+       }
+
+       f := func(hat, tail string) {
+
+               fmt.Println(hat+`
+foo
+
+
+`+tail,
+                       "more",
+                       "and more")
+       }
diff --git a/libgo/go/cmd/gofmt/testdata/stdin6.input b/libgo/go/cmd/gofmt/testdata/stdin6.input
new file mode 100644 (file)
index 0000000..7833002
--- /dev/null
@@ -0,0 +1,21 @@
+       //gofmt -stdin
+
+       if err != nil {
+               source := strings.NewReader(`line 1.
+line 2.
+`)
+               return source
+       }
+
+       f:=func(  hat, tail string){
+
+
+
+                  fmt.  Println  (   hat+   `
+foo
+
+
+`+ tail  ,
+ "more" ,
+               "and more"   )
+       }
diff --git a/libgo/go/cmd/gofmt/testdata/stdin7.golden b/libgo/go/cmd/gofmt/testdata/stdin7.golden
new file mode 100644 (file)
index 0000000..bbac713
--- /dev/null
@@ -0,0 +1,19 @@
+                                                                                                                       //gofmt -stdin
+
+                                                                                                                       if err != nil {
+                                                                                                                               source := strings.NewReader(`line 1.
+line 2.
+`)
+                                                                                                                               return source
+                                                                                                                       }
+
+                                                                                                                       f := func(hat, tail string) {
+
+                                                                                                                               fmt.Println(hat+`
+               foo
+
+
+       `+tail,
+                                                                                                                                       "more",
+                                                                                                                                       "and more")
+                                                                                                                       }
diff --git a/libgo/go/cmd/gofmt/testdata/stdin7.input b/libgo/go/cmd/gofmt/testdata/stdin7.input
new file mode 100644 (file)
index 0000000..fd772a3
--- /dev/null
@@ -0,0 +1,21 @@
+                                                                                                                       //gofmt -stdin
+
+                                                                                                                       if err != nil {
+                                                               source := strings.NewReader(`line 1.
+line 2.
+`)
+                                                               return source
+                                                       }
+
+                                                       f:=func(  hat, tail string){
+
+
+
+                                                                  fmt.  Println  (   hat+   `
+               foo
+
+
+       `+ tail  ,
+                                                "more" ,
+                                                               "and more"   )
+                                                       }
index a6c3080db3efe5f49467b28e703aed888e560b02..95fb18958561b311a6d545cdc4cb976f34ab6cf4 100644 (file)
@@ -204,12 +204,6 @@ func TestMTF(t *testing.T) {
        }
 }
 
-var (
-       digits = mustLoadFile("testdata/e.txt.bz2")
-       twain  = mustLoadFile("testdata/Mark.Twain-Tom.Sawyer.txt.bz2")
-       random = mustLoadFile("testdata/random.data.bz2")
-)
-
 func benchmarkDecode(b *testing.B, compressed []byte) {
        // Determine the uncompressed size of testfile.
        uncompressedSize, err := io.Copy(ioutil.Discard, NewReader(bytes.NewReader(compressed)))
@@ -227,6 +221,18 @@ func benchmarkDecode(b *testing.B, compressed []byte) {
        }
 }
 
-func BenchmarkDecodeDigits(b *testing.B) { benchmarkDecode(b, digits) }
-func BenchmarkDecodeTwain(b *testing.B)  { benchmarkDecode(b, twain) }
-func BenchmarkDecodeRand(b *testing.B)   { benchmarkDecode(b, random) }
+func BenchmarkDecodeDigits(b *testing.B) {
+       digits := mustLoadFile("testdata/e.txt.bz2")
+       b.ResetTimer()
+       benchmarkDecode(b, digits)
+}
+func BenchmarkDecodeTwain(b *testing.B) {
+       twain := mustLoadFile("testdata/Mark.Twain-Tom.Sawyer.txt.bz2")
+       b.ResetTimer()
+       benchmarkDecode(b, twain)
+}
+func BenchmarkDecodeRand(b *testing.B) {
+       random := mustLoadFile("testdata/random.data.bz2")
+       b.ResetTimer()
+       benchmarkDecode(b, random)
+}
index 97265b3ca27ad091af42e7bf2ff120dd5e54f277..4d6a5357d881da4d90aba22d65728c60c075e287 100644 (file)
@@ -136,14 +136,17 @@ func (d *compressor) fillDeflate(b []byte) int {
                        delta := d.hashOffset - 1
                        d.hashOffset -= delta
                        d.chainHead -= delta
-                       for i, v := range d.hashPrev {
+
+                       // Iterate over slices instead of arrays to avoid copying
+                       // the entire table onto the stack (Issue #18625).
+                       for i, v := range d.hashPrev[:] {
                                if int(v) > delta {
                                        d.hashPrev[i] = uint32(int(v) - delta)
                                } else {
                                        d.hashPrev[i] = 0
                                }
                        }
-                       for i, v := range d.hashHead {
+                       for i, v := range d.hashHead[:] {
                                if int(v) > delta {
                                        d.hashHead[i] = uint32(int(v) - delta)
                                } else {
index 521a2603658b9bba53c7138f2c950750a2eecba9..fbea761721a3e4115437c0bf244068daf86cfca7 100644 (file)
@@ -12,6 +12,7 @@ import (
        "io"
        "io/ioutil"
        "reflect"
+       "runtime/debug"
        "sync"
        "testing"
 )
@@ -864,3 +865,33 @@ func TestBestSpeedMaxMatchOffset(t *testing.T) {
                }
        }
 }
+
+func TestMaxStackSize(t *testing.T) {
+       // This test must not run in parallel with other tests as debug.SetMaxStack
+       // affects all goroutines.
+       n := debug.SetMaxStack(1 << 16)
+       defer debug.SetMaxStack(n)
+
+       var wg sync.WaitGroup
+       defer wg.Wait()
+
+       b := make([]byte, 1<<20)
+       for level := HuffmanOnly; level <= BestCompression; level++ {
+               // Run in separate goroutine to increase probability of stack regrowth.
+               wg.Add(1)
+               go func(level int) {
+                       defer wg.Done()
+                       zw, err := NewWriter(ioutil.Discard, level)
+                       if err != nil {
+                               t.Errorf("level %d, NewWriter() = %v, want nil", level, err)
+                       }
+                       if n, err := zw.Write(b); n != len(b) || err != nil {
+                               t.Errorf("level %d, Write() = (%d, %v), want (%d, nil)", level, n, err, len(b))
+                       }
+                       if err := zw.Close(); err != nil {
+                               t.Errorf("level %d, Close() = %v, want nil", level, err)
+                       }
+                       zw.Reset(ioutil.Discard)
+               }(level)
+       }
+}
index a1636a37d67cfa9826e78de10618c94faa12f5d6..08298b76bbb2da5a7882d439d61d8428b28f632a 100644 (file)
@@ -60,7 +60,7 @@ func newDeflateFast() *deflateFast {
 func (e *deflateFast) encode(dst []token, src []byte) []token {
        // Ensure that e.cur doesn't wrap.
        if e.cur > 1<<30 {
-               *e = deflateFast{cur: maxStoreBlockSize, prev: e.prev[:0]}
+               e.resetAll()
        }
 
        // This check isn't in the Snappy implementation, but there, the caller
@@ -265,6 +265,21 @@ func (e *deflateFast) reset() {
 
        // Protect against e.cur wraparound.
        if e.cur > 1<<30 {
-               *e = deflateFast{cur: maxStoreBlockSize, prev: e.prev[:0]}
+               e.resetAll()
+       }
+}
+
+// resetAll resets the deflateFast struct and is only called in rare
+// situations to prevent integer overflow. It manually resets each field
+// to avoid causing large stack growth.
+//
+// See https://golang.org/issue/18636.
+func (e *deflateFast) resetAll() {
+       // This is equivalent to:
+       //      *e = deflateFast{cur: maxStoreBlockSize, prev: e.prev[:0]}
+       e.cur = maxStoreBlockSize
+       e.prev = e.prev[:0]
+       for i := range e.table {
+               e.table[i] = tableEntry{}
        }
 }
index e76d47cc4ee5700d9faedfeb8b94a3c7370ac3ae..30c1390dfd7faf0ca4d2e1e37c8868db2f9e2089 100644 (file)
@@ -9,11 +9,17 @@ import (
        "testing"
 )
 
-// Per golang.org/issue/14937, check that every .gz file
-// in the tree has a zero mtime.
+// TestGZIPFilesHaveZeroMTimes checks that every .gz file in the tree
+// has a zero MTIME. This is a requirement for the Debian maintainers
+// to be able to have deterministic packages.
+//
+// See https://golang.org/issue/14937.
 func TestGZIPFilesHaveZeroMTimes(t *testing.T) {
-       if testing.Short() && testenv.Builder() == "" {
-               t.Skip("skipping in short mode")
+       // To avoid spurious false positives due to untracked GZIP files that
+       // may be in the user's GOROOT (Issue 18604), we only run this test on
+       // the builders, which should have a clean checkout of the tree.
+       if testenv.Builder() == "" {
+               t.Skip("skipping test on non-builder")
        }
        goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
        if err != nil {
diff --git a/libgo/go/crypto/ecdsa/testdata/SigVer.rsp.bz2 b/libgo/go/crypto/ecdsa/testdata/SigVer.rsp.bz2
new file mode 100644 (file)
index 0000000..09fe2b4
Binary files /dev/null and b/libgo/go/crypto/ecdsa/testdata/SigVer.rsp.bz2 differ
index 05146743acbba6010f3ac868bf2184303e11cf92..beb0f1926d89947d9603f0dbc2561ae08320d67f 100644 (file)
@@ -84,15 +84,15 @@ var cipherSuites = []*cipherSuite{
        {TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, nil, nil, aeadAESGCM},
        {TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
        {TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
-       {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheRSAKA, suiteECDHE | suiteTLS12, cipherAES, macSHA256, nil},
+       {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheRSAKA, suiteECDHE | suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
        {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
-       {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12, cipherAES, macSHA256, nil},
+       {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
        {TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
        {TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
        {TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
        {TLS_RSA_WITH_AES_128_GCM_SHA256, 16, 0, 4, rsaKA, suiteTLS12, nil, nil, aeadAESGCM},
        {TLS_RSA_WITH_AES_256_GCM_SHA384, 32, 0, 4, rsaKA, suiteTLS12 | suiteSHA384, nil, nil, aeadAESGCM},
-       {TLS_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, rsaKA, suiteTLS12, cipherAES, macSHA256, nil},
+       {TLS_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, rsaKA, suiteTLS12 | suiteDefaultOff, cipherAES, macSHA256, nil},
        {TLS_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
        {TLS_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
        {TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, ecdheRSAKA, suiteECDHE, cipher3DES, macSHA1, nil},
index f2e5aea2bce5ed6d7305c2d8fdfd233b0d63c2fd..615d1e5576fdaab8c772eadae62a3d146757cc6d 100644 (file)
@@ -6,8 +6,8 @@
 package tls
 
 // BUG(agl): The crypto/tls package only implements some countermeasures
-// against Lucky13 attacks on CBC-mode encryption. See
-// http://www.isg.rhul.ac.uk/tls/TLStiming.pdf and
+// against Lucky13 attacks on CBC-mode encryption, and only on SHA1
+// variants. See http://www.isg.rhul.ac.uk/tls/TLStiming.pdf and
 // https://www.imperialviolet.org/2013/02/04/luckythirteen.html.
 
 import (
index fea33df379aebdce57f78c6cc6a412e61acea99d..71ffbdf0e0460bd2df3d2a4e269f6056e3bd6b0d 100644 (file)
@@ -4,7 +4,11 @@
 
 package x509
 
-import "encoding/pem"
+import (
+       "encoding/pem"
+       "errors"
+       "runtime"
+)
 
 // CertPool is a set of certificates.
 type CertPool struct {
@@ -26,6 +30,11 @@ func NewCertPool() *CertPool {
 // Any mutations to the returned pool are not written to disk and do
 // not affect any other pool.
 func SystemCertPool() (*CertPool, error) {
+       if runtime.GOOS == "windows" {
+               // Issue 16736, 18609:
+               return nil, errors.New("crypto/x509: system root pool is not available on Windows")
+       }
+
        return loadSystemRoots()
 }
 
index ca2fba5cb421fe7b7925358fa50d15061da99cc5..a936fec7d8447dbc27669b4ff9aae4f2a32288e2 100644 (file)
@@ -226,6 +226,11 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
 }
 
 func loadSystemRoots() (*CertPool, error) {
+       // TODO: restore this functionality on Windows. We tried to do
+       // it in Go 1.8 but had to revert it. See Issue 18609.
+       // Returning (nil, nil) was the old behavior, prior to CL 30578.
+       return nil, nil
+
        const CRYPT_E_NOT_FOUND = 0x80092004
 
        store, err := syscall.CertOpenSystemStore(0, syscall.StringToUTF16Ptr("ROOT"))
index aa30d85b7da06de25236732d0536b7c572831454..b085dad90f06a5f78a21e91d0f4ea5f2ef102522 100644 (file)
@@ -24,6 +24,7 @@ import (
        "net"
        "os/exec"
        "reflect"
+       "runtime"
        "strings"
        "testing"
        "time"
@@ -1477,6 +1478,9 @@ func TestMultipleRDN(t *testing.T) {
 }
 
 func TestSystemCertPool(t *testing.T) {
+       if runtime.GOOS == "windows" {
+               t.Skip("not implemented on Windows; Issue 16736, 18609")
+       }
        _, err := SystemCertPool()
        if err != nil {
                t.Fatal(err)
index 1ce5e2e84b5da1a7c4f9ee74666783c8a0add675..a400c7152a668a3e28e89ef9f18ff90d5357269a 100644 (file)
@@ -70,10 +70,8 @@ func (s *Scope) String() string {
 // The Data fields contains object-specific data:
 //
 //     Kind    Data type         Data value
-//     Pkg     *types.Package    package scope
+//     Pkg     *Scope            package scope
 //     Con     int               iota for the respective declaration
-//     Con     != nil            constant value
-//     Typ     *Scope            (used as method scope during type checking - transient)
 //
 type Object struct {
        Kind ObjKind
index ad8ba5378f3f13f7db193b5416bebb4439d0c18c..82e63100d4764d68516070e2e0e7fec2ac314011 100644 (file)
@@ -25,7 +25,7 @@ var files = flag.String("files", "", "consider only Go test files matching this
 
 const dataDir = "testdata"
 
-var templateTxt = readTemplate("template.txt")
+var templateTxt *template.Template
 
 func readTemplate(filename string) *template.Template {
        t := template.New(filename)
@@ -96,6 +96,9 @@ func test(t *testing.T, mode Mode) {
        if err != nil {
                t.Fatal(err)
        }
+       if templateTxt == nil {
+               templateTxt = readTemplate("template.txt")
+       }
 
        // test packages
        for _, pkg := range pkgs {
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/complexnums.gox b/libgo/go/go/internal/gccgoimporter/testdata/complexnums.gox
new file mode 100644 (file)
index 0000000..b66524f
--- /dev/null
@@ -0,0 +1,8 @@
+v1;
+package complexnums;
+pkgpath complexnums;
+priority 1;
+const NN = -0.1E1-0.1E1i ;
+const NP = -0.1E1+0.1E1i ;
+const PN = 0.1E1-0.1E1i ;
+const PP = 0.1E1+0.1E1i ;
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/conversions.gox b/libgo/go/go/internal/gccgoimporter/testdata/conversions.gox
new file mode 100644 (file)
index 0000000..7de6cda
--- /dev/null
@@ -0,0 +1,6 @@
+v2;
+package conversions;
+prefix go;
+package conversions go.conversions go.conversions;
+const Bits <type 1 "Units" <type -16>> = convert(<type 1>, "bits");
+type <type 1>;
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/imports.gox b/libgo/go/go/internal/gccgoimporter/testdata/imports.gox
new file mode 100644 (file)
index 0000000..958a4f5
--- /dev/null
@@ -0,0 +1,7 @@
+v1;
+package imports;
+pkgpath imports;
+priority 7;
+import fmt fmt "fmt";
+init imports imports..import 7 math math..import 1 runtime runtime..import 1 strconv strconv..import 2 io io..import 3 reflect reflect..import 3 syscall syscall..import 3 time time..import 4 os os..import 5 fmt fmt..import 6;
+var Hello <type -16>;
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/pointer.gox b/libgo/go/go/internal/gccgoimporter/testdata/pointer.gox
new file mode 100644 (file)
index 0000000..d96ebbd
--- /dev/null
@@ -0,0 +1,4 @@
+v1;
+package pointer;
+pkgpath pointer;
+type <type 1 "Int8Ptr" <type 2 *<type -1>>>;
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/time.gox b/libgo/go/go/internal/gccgoimporter/testdata/time.gox
new file mode 100644 (file)
index 0000000..80c2dbc
Binary files /dev/null and b/libgo/go/go/internal/gccgoimporter/testdata/time.gox differ
diff --git a/libgo/go/go/internal/gccgoimporter/testdata/unicode.gox b/libgo/go/go/internal/gccgoimporter/testdata/unicode.gox
new file mode 100644 (file)
index 0000000..e70e539
Binary files /dev/null and b/libgo/go/go/internal/gccgoimporter/testdata/unicode.gox differ
index f2732c0e2b18d142c121d98bf22de920f4b57eef..b2e1c11e9d538ed6c317e07740ce03c0d64f7866 100644 (file)
@@ -10,17 +10,12 @@ import (
        "testing"
 )
 
-var src = readFile("parser.go")
-
-func readFile(filename string) []byte {
-       data, err := ioutil.ReadFile(filename)
+func BenchmarkParse(b *testing.B) {
+       src, err := ioutil.ReadFile("parser.go")
        if err != nil {
-               panic(err)
+               b.Fatal(err)
        }
-       return data
-}
-
-func BenchmarkParse(b *testing.B) {
+       b.ResetTimer()
        b.SetBytes(int64(len(src)))
        for i := 0; i < b.N; i++ {
                if _, err := ParseFile(token.NewFileSet(), "", src, ParseComments); err != nil {
diff --git a/libgo/go/go/types/testdata/blank.src b/libgo/go/go/types/testdata/blank.src
new file mode 100644 (file)
index 0000000..6a2507f
--- /dev/null
@@ -0,0 +1,5 @@
+// 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 _ /* ERROR invalid package name */
diff --git a/libgo/go/go/types/testdata/builtins.src b/libgo/go/go/types/testdata/builtins.src
new file mode 100644 (file)
index 0000000..7fb7b58
--- /dev/null
@@ -0,0 +1,901 @@
+// 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.
+
+// builtin calls
+
+package builtins
+
+import "unsafe"
+
+func f0() {}
+
+func append1() {
+       var b byte
+       var x int
+       var s []byte
+       _ = append() // ERROR not enough arguments
+       _ = append("foo" /* ERROR not a slice */ )
+       _ = append(nil /* ERROR not a slice */ , s)
+       _ = append(x /* ERROR not a slice */ , s)
+       _ = append(s)
+       append /* ERROR not used */ (s)
+
+       _ = append(s, b)
+       _ = append(s, x /* ERROR cannot use x */ )
+       _ = append(s, s /* ERROR cannot use s */ )
+       _ = append(s... /* ERROR can only use ... with matching parameter */ )
+       _ = append(s, b, s... /* ERROR can only use ... with matching parameter */ )
+       _ = append(s, 1, 2, 3)
+       _ = append(s, 1, 2, 3, x /* ERROR cannot use x */ , 5, 6, 6)
+       _ = append(s, 1, 2, s... /* ERROR can only use ... with matching parameter */ )
+       _ = append([]interface{}(nil), 1, 2, "foo", x, 3.1425, false)
+
+       type S []byte
+       type T string
+       var t T
+       _ = append(s, "foo" /* ERROR cannot convert */ )
+       _ = append(s, "foo"...)
+       _ = append(S(s), "foo" /* ERROR cannot convert */ )
+       _ = append(S(s), "foo"...)
+       _ = append(s, t /* ERROR cannot use t */ )
+       _ = append(s, t...)
+       _ = append(s, T("foo")...)
+       _ = append(S(s), t /* ERROR cannot use t */ )
+       _ = append(S(s), t...)
+       _ = append(S(s), T("foo")...)
+       _ = append([]string{}, t /* ERROR cannot use t */ , "foo")
+       _ = append([]T{}, t, "foo")
+}
+
+// from the spec
+func append2() {
+       s0 := []int{0, 0}
+       s1 := append(s0, 2)                // append a single element     s1 == []int{0, 0, 2}
+       s2 := append(s1, 3, 5, 7)          // append multiple elements    s2 == []int{0, 0, 2, 3, 5, 7}
+       s3 := append(s2, s0...)            // append a slice              s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
+       s4 := append(s3[3:6], s3[2:]...)   // append overlapping slice    s4 == []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
+
+       var t []interface{}
+       t = append(t, 42, 3.1415, "foo")   //                             t == []interface{}{42, 3.1415, "foo"}
+
+       var b []byte
+       b = append(b, "bar"...)            // append string contents      b == []byte{'b', 'a', 'r' }
+
+       _ = s4
+}
+
+func append3() {
+       f1 := func() (s []int) { return }
+       f2 := func() (s []int, x int) { return }
+       f3 := func() (s []int, x, y int) { return }
+       f5 := func() (s []interface{}, x int, y float32, z string, b bool) { return }
+       ff := func() (int, float32) { return 0, 0 }
+       _ = append(f0 /* ERROR used as value */ ())
+       _ = append(f1())
+       _ = append(f2())
+       _ = append(f3())
+       _ = append(f5())
+       _ = append(ff /* ERROR not a slice */ ()) // TODO(gri) better error message
+}
+
+func cap1() {
+       var a [10]bool
+       var p *[20]int
+       var c chan string
+       _ = cap() // ERROR not enough arguments
+       _ = cap(1, 2) // ERROR too many arguments
+       _ = cap(42 /* ERROR invalid */)
+       const _3 = cap(a)
+       assert(_3 == 10)
+       const _4 = cap(p)
+       assert(_4 == 20)
+       _ = cap(c)
+       cap /* ERROR not used */ (c)
+
+       // issue 4744
+       type T struct{ a [10]int }
+       const _ = cap(((*T)(nil)).a)
+
+       var s [][]byte
+       _ = cap(s)
+       _ = cap(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func cap2() {
+       f1a := func() (a [10]int) { return }
+       f1s := func() (s []int) { return }
+       f2 := func() (s []int, x int) { return }
+       _ = cap(f0 /* ERROR used as value */ ())
+       _ = cap(f1a())
+       _ = cap(f1s())
+       _ = cap(f2()) // ERROR too many arguments
+}
+
+// test cases for issue 7387
+func cap3() {
+       var f = func() int { return 0 }
+       var x = f()
+       const (
+               _ = cap([4]int{})
+               _ = cap([4]int{x})
+               _ = cap /* ERROR not constant */ ([4]int{f()})
+               _ = cap /* ERROR not constant */ ([4]int{cap([]int{})})
+               _ = cap([4]int{cap([4]int{})})
+       )
+       var y float64
+       var z complex128
+       const (
+               _ = cap([4]float64{})
+               _ = cap([4]float64{y})
+               _ = cap([4]float64{real(2i)})
+               _ = cap /* ERROR not constant */ ([4]float64{real(z)})
+       )
+       var ch chan [10]int
+       const (
+               _ = cap /* ERROR not constant */ (<-ch)
+               _ = cap /* ERROR not constant */ ([4]int{(<-ch)[0]})
+       )
+}
+
+func close1() {
+       var c chan int
+       var r <-chan int
+       close() // ERROR not enough arguments
+       close(1, 2) // ERROR too many arguments
+       close(42 /* ERROR not a channel */)
+       close(r /* ERROR receive-only channel */)
+       close(c)
+       _ = close /* ERROR used as value */ (c)
+
+       var s []chan int
+       close(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func close2() {
+       f1 := func() (ch chan int) { return }
+       f2 := func() (ch chan int, x int) { return }
+       close(f0 /* ERROR used as value */ ())
+       close(f1())
+       close(f2()) // ERROR too many arguments
+}
+
+func complex1() {
+       var i32 int32
+       var f32 float32
+       var f64 float64
+       var c64 complex64
+       var c128 complex128
+       _ = complex() // ERROR not enough arguments
+       _ = complex(1) // ERROR not enough arguments
+       _ = complex(true /* ERROR mismatched types */ , 0)
+       _ = complex(i32 /* ERROR expected floating-point */ , 0)
+       _ = complex("foo" /* ERROR mismatched types */ , 0)
+       _ = complex(c64 /* ERROR expected floating-point */ , 0)
+       _ = complex(0 /* ERROR mismatched types */ , true)
+       _ = complex(0 /* ERROR expected floating-point */ , i32)
+       _ = complex(0 /* ERROR mismatched types */ , "foo")
+       _ = complex(0 /* ERROR expected floating-point */ , c64)
+       _ = complex(f32, f32)
+       _ = complex(f32, 1)
+       _ = complex(f32, 1.0)
+       _ = complex(f32, 'a')
+       _ = complex(f64, f64)
+       _ = complex(f64, 1)
+       _ = complex(f64, 1.0)
+       _ = complex(f64, 'a')
+       _ = complex(f32 /* ERROR mismatched types */ , f64)
+       _ = complex(f64 /* ERROR mismatched types */ , f32)
+       _ = complex(1, 1)
+       _ = complex(1, 1.1)
+       _ = complex(1, 'a')
+       complex /* ERROR not used */ (1, 2)
+
+       var _ complex64 = complex(f32, f32)
+       var _ complex64 = complex /* ERROR cannot use .* in variable declaration */ (f64, f64)
+
+       var _ complex128 = complex /* ERROR cannot use .* in variable declaration */ (f32, f32)
+       var _ complex128 = complex(f64, f64)
+
+       // untyped constants
+       const _ int = complex(1, 0)
+       const _ float32 = complex(1, 0)
+       const _ complex64 = complex(1, 0)
+       const _ complex128 = complex(1, 0)
+       const _ = complex(0i, 0i)
+       const _ = complex(0i, 0)
+       const _ int = 1.0 + complex(1, 0i)
+
+       const _ int = complex /* ERROR int */ (1.1, 0)
+       const _ float32 = complex /* ERROR float32 */ (1, 2)
+
+       // untyped values
+       var s uint
+       _ = complex(1 /* ERROR integer */ <<s, 0)
+       const _ = complex /* ERROR not constant */ (1 /* ERROR integer */ <<s, 0)
+       var _ int = complex /* ERROR cannot use .* in variable declaration */ (1 /* ERROR integer */ <<s, 0)
+
+       // floating-point argument types must be identical
+       type F32 float32
+       type F64 float64
+       var x32 F32
+       var x64 F64
+       c64 = complex(x32, x32)
+       _ = complex(x32 /* ERROR mismatched types */ , f32)
+       _ = complex(f32 /* ERROR mismatched types */ , x32)
+       c128 = complex(x64, x64)
+       _ = c128
+       _ = complex(x64 /* ERROR mismatched types */ , f64)
+       _ = complex(f64 /* ERROR mismatched types */ , x64)
+
+       var t []float32
+       _ = complex(t... /* ERROR invalid use of \.\.\. */ )
+}
+
+func complex2() {
+       f1 := func() (x float32) { return }
+       f2 := func() (x, y float32) { return }
+       f3 := func() (x, y, z float32) { return }
+       _ = complex(f0 /* ERROR used as value */ ())
+       _ = complex(f1()) // ERROR not enough arguments
+       _ = complex(f2())
+       _ = complex(f3()) // ERROR too many arguments
+}
+
+func copy1() {
+       copy() // ERROR not enough arguments
+       copy("foo") // ERROR not enough arguments
+       copy([ /* ERROR copy expects slice arguments */ ...]int{}, []int{})
+       copy([ /* ERROR copy expects slice arguments */ ]int{}, [...]int{})
+       copy([ /* ERROR different element types */ ]int8{}, "foo")
+
+       // spec examples
+       var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
+       var s = make([]int, 6)
+       var b = make([]byte, 5)
+       n1 := copy(s, a[0:])            // n1 == 6, s == []int{0, 1, 2, 3, 4, 5}
+       n2 := copy(s, s[2:])            // n2 == 4, s == []int{2, 3, 4, 5, 4, 5}
+       n3 := copy(b, "Hello, World!")  // n3 == 5, b == []byte("Hello")
+       _, _, _ = n1, n2, n3
+
+       var t [][]int
+       copy(t, t)
+       copy(t /* ERROR copy expects slice arguments */ , nil)
+       copy(nil /* ERROR copy expects slice arguments */ , t)
+       copy(nil /* ERROR copy expects slice arguments */ , nil)
+       copy(t... /* ERROR invalid use of \.\.\. */ )
+}
+
+func copy2() {
+       f1 := func() (a []int) { return }
+       f2 := func() (a, b []int) { return }
+       f3 := func() (a, b, c []int) { return }
+       copy(f0 /* ERROR used as value */ ())
+       copy(f1()) // ERROR not enough arguments
+       copy(f2())
+       copy(f3()) // ERROR too many arguments
+}
+
+func delete1() {
+       var m map[string]int
+       var s string
+       delete() // ERROR not enough arguments
+       delete(1) // ERROR not enough arguments
+       delete(1, 2, 3) // ERROR too many arguments
+       delete(m, 0 /* ERROR not assignable */)
+       delete(m, s)
+       _ = delete /* ERROR used as value */ (m, s)
+
+       var t []map[string]string
+       delete(t... /* ERROR invalid use of \.\.\. */ )
+}
+
+func delete2() {
+       f1 := func() (m map[string]int) { return }
+       f2 := func() (m map[string]int, k string) { return }
+       f3 := func() (m map[string]int, k string, x float32) { return }
+       delete(f0 /* ERROR used as value */ ())
+       delete(f1()) // ERROR not enough arguments
+       delete(f2())
+       delete(f3()) // ERROR too many arguments
+}
+
+func imag1() {
+       var f32 float32
+       var f64 float64
+       var c64 complex64
+       var c128 complex128
+       _ = imag() // ERROR not enough arguments
+       _ = imag(1, 2) // ERROR too many arguments
+       _ = imag(10)
+       _ = imag(2.7182818)
+       _ = imag("foo" /* ERROR expected complex */)
+       _ = imag('a')
+       const _5 = imag(1 + 2i)
+       assert(_5 == 2)
+       f32 = _5
+       f64 = _5
+       const _6 = imag(0i)
+       assert(_6 == 0)
+       f32 = imag(c64)
+       f64 = imag(c128)
+       f32 = imag /* ERROR cannot use .* in assignment */ (c128)
+       f64 = imag /* ERROR cannot use .* in assignment */ (c64)
+       imag /* ERROR not used */ (c64)
+       _, _ = f32, f64
+
+       // complex type may not be predeclared
+       type C64 complex64
+       type C128 complex128
+       var x64 C64
+       var x128 C128
+       f32 = imag(x64)
+       f64 = imag(x128)
+
+       var a []complex64
+       _ = imag(a... /* ERROR invalid use of \.\.\. */ )
+
+       // if argument is untyped, result is untyped
+       const _ byte = imag(1.2 + 3i)
+       const _ complex128 = imag(1.2 + 3i)
+
+       // lhs constant shift operands are typed as complex128
+       var s uint
+       _ = imag(1 /* ERROR must be integer */ << s)
+}
+
+func imag2() {
+       f1 := func() (x complex128) { return }
+       f2 := func() (x, y complex128) { return }
+       _ = imag(f0 /* ERROR used as value */ ())
+       _ = imag(f1())
+       _ = imag(f2()) // ERROR too many arguments
+}
+
+func len1() {
+       const c = "foobar"
+       var a [10]bool
+       var p *[20]int
+       var m map[string]complex128
+       _ = len() // ERROR not enough arguments
+       _ = len(1, 2) // ERROR too many arguments
+       _ = len(42 /* ERROR invalid */)
+       const _3 = len(c)
+       assert(_3 == 6)
+       const _4 = len(a)
+       assert(_4 == 10)
+       const _5 = len(p)
+       assert(_5 == 20)
+       _ = len(m)
+       len /* ERROR not used */ (c)
+
+       // esoteric case
+       var t string
+       var hash map[interface{}][]*[10]int
+       const n = len /* ERROR not constant */ (hash[recover()][len(t)])
+       assert(n == 10) // ok because n has unknown value and no error is reported
+       var ch <-chan int
+       const nn = len /* ERROR not constant */ (hash[<-ch][len(t)])
+
+       // issue 4744
+       type T struct{ a [10]int }
+       const _ = len(((*T)(nil)).a)
+
+       var s [][]byte
+       _ = len(s)
+       _ = len(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func len2() {
+       f1 := func() (x []int) { return }
+       f2 := func() (x, y []int) { return }
+       _ = len(f0 /* ERROR used as value */ ())
+       _ = len(f1())
+       _ = len(f2()) // ERROR too many arguments
+}
+
+// test cases for issue 7387
+func len3() {
+       var f = func() int { return 0 }
+       var x = f()
+       const (
+               _ = len([4]int{})
+               _ = len([4]int{x})
+               _ = len /* ERROR not constant */ ([4]int{f()})
+               _ = len /* ERROR not constant */ ([4]int{len([]int{})})
+               _ = len([4]int{len([4]int{})})
+       )
+       var y float64
+       var z complex128
+       const (
+               _ = len([4]float64{})
+               _ = len([4]float64{y})
+               _ = len([4]float64{real(2i)})
+               _ = len /* ERROR not constant */ ([4]float64{real(z)})
+       )
+       var ch chan [10]int
+       const (
+               _ = len /* ERROR not constant */ (<-ch)
+               _ = len /* ERROR not constant */ ([4]int{(<-ch)[0]})
+       )
+}
+
+func make1() {
+       var n int
+       var m float32
+       var s uint
+
+       _ = make() // ERROR not enough arguments
+       _ = make(1 /* ERROR not a type */)
+       _ = make(int /* ERROR cannot make */)
+
+       // slices
+       _ = make/* ERROR arguments */ ([]int)
+       _ = make/* ERROR arguments */ ([]int, 2, 3, 4)
+       _ = make([]int, int /* ERROR not an expression */)
+       _ = make([]int, 10, float32 /* ERROR not an expression */)
+       _ = make([]int, "foo" /* ERROR cannot convert */)
+       _ = make([]int, 10, 2.3 /* ERROR truncated */)
+       _ = make([]int, 5, 10.0)
+       _ = make([]int, 0i)
+       _ = make([]int, 1.0)
+       _ = make([]int, 1.0<<s)
+       _ = make([]int, 1.1 /* ERROR int */ <<s)
+       _ = make([]int, - /* ERROR must not be negative */ 1, 10)
+       _ = make([]int, 0, - /* ERROR must not be negative */ 1)
+       _ = make([]int, - /* ERROR must not be negative */ 1, - /* ERROR must not be negative */ 1)
+       _ = make([]int, 1 /* ERROR overflows */ <<100, 1 /* ERROR overflows */ <<100)
+       _ = make([]int, 10 /* ERROR length and capacity swapped */ , 9)
+       _ = make([]int, 1 /* ERROR overflows */ <<100, 12345)
+       _ = make([]int, m /* ERROR must be integer */ )
+        _ = &make /* ERROR cannot take address */ ([]int, 0)
+
+       // maps
+       _ = make /* ERROR arguments */ (map[int]string, 10, 20)
+       _ = make(map[int]float32, int /* ERROR not an expression */)
+       _ = make(map[int]float32, "foo" /* ERROR cannot convert */)
+       _ = make(map[int]float32, 10)
+       _ = make(map[int]float32, n)
+       _ = make(map[int]float32, int64(n))
+       _ = make(map[string]bool, 10.0)
+       _ = make(map[string]bool, 10.0<<s)
+        _ = &make /* ERROR cannot take address */ (map[string]bool)
+
+       // channels
+       _ = make /* ERROR arguments */ (chan int, 10, 20)
+       _ = make(chan int, int /* ERROR not an expression */)
+       _ = make(chan<- int, "foo" /* ERROR cannot convert */)
+       _ = make(chan int, - /* ERROR must not be negative */ 10)
+       _ = make(<-chan float64, 10)
+       _ = make(chan chan int, n)
+       _ = make(chan string, int64(n))
+       _ = make(chan bool, 10.0)
+       _ = make(chan bool, 10.0<<s)
+        _ = &make /* ERROR cannot take address */ (chan bool)
+
+       make /* ERROR not used */ ([]int, 10)
+
+       var t []int
+       _ = make([]int, t[0], t[1])
+       _ = make([]int, t... /* ERROR invalid use of \.\.\. */ )
+}
+
+func make2() {
+       f1 /* ERROR not used */ := func() (x []int) { return }
+       _ = make(f0 /* ERROR not a type */ ())
+       _ = make(f1 /* ERROR not a type */ ())
+}
+
+func new1() {
+       _ = new() // ERROR not enough arguments
+       _ = new(1, 2) // ERROR too many arguments
+       _ = new("foo" /* ERROR not a type */)
+       p := new(float64)
+       _ = new(struct{ x, y int })
+       q := new(*float64)
+       _ = *p == **q
+       new /* ERROR not used */ (int)
+        _ = &new /* ERROR cannot take address */ (int)
+
+       _ = new(int... /* ERROR invalid use of \.\.\. */ )
+}
+
+func new2() {
+       f1 /* ERROR not used */ := func() (x []int) { return }
+       _ = new(f0 /* ERROR not a type */ ())
+       _ = new(f1 /* ERROR not a type */ ())
+}
+
+func panic1() {
+       panic() // ERROR not enough arguments
+       panic(1, 2) // ERROR too many arguments
+       panic(0)
+       panic("foo")
+       panic(false)
+       panic(1<<10)
+       panic(1 /* ERROR overflows */ <<1000)
+       _ = panic /* ERROR used as value */ (0)
+
+       var s []byte
+       panic(s)
+       panic(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func panic2() {
+       f1 := func() (x int) { return }
+       f2 := func() (x, y int) { return }
+       panic(f0 /* ERROR used as value */ ())
+       panic(f1())
+       panic(f2()) // ERROR too many arguments
+}
+
+func print1() {
+       print()
+       print(1)
+       print(1, 2)
+       print("foo")
+       print(2.718281828)
+       print(false)
+       print(1<<10)
+       print(1 /* ERROR overflows */ <<1000)
+       println(nil /* ERROR untyped nil */ )
+
+       var s []int
+       print(s... /* ERROR invalid use of \.\.\. */ )
+       _ = print /* ERROR used as value */ ()
+}
+
+func print2() {
+       f1 := func() (x int) { return }
+       f2 := func() (x, y int) { return }
+       f3 := func() (x int, y float32, z string) { return }
+       print(f0 /* ERROR used as value */ ())
+       print(f1())
+       print(f2())
+       print(f3())
+}
+
+func println1() {
+       println()
+       println(1)
+       println(1, 2)
+       println("foo")
+       println(2.718281828)
+       println(false)
+       println(1<<10)
+       println(1 /* ERROR overflows */ <<1000)
+       println(nil /* ERROR untyped nil */ )
+
+       var s []int
+       println(s... /* ERROR invalid use of \.\.\. */ )
+       _ = println /* ERROR used as value */ ()
+}
+
+func println2() {
+       f1 := func() (x int) { return }
+       f2 := func() (x, y int) { return }
+       f3 := func() (x int, y float32, z string) { return }
+       println(f0 /* ERROR used as value */ ())
+       println(f1())
+       println(f2())
+       println(f3())
+}
+
+func real1() {
+       var f32 float32
+       var f64 float64
+       var c64 complex64
+       var c128 complex128
+       _ = real() // ERROR not enough arguments
+       _ = real(1, 2) // ERROR too many arguments
+       _ = real(10)
+       _ = real(2.7182818)
+       _ = real("foo" /* ERROR expected complex */)
+       const _5 = real(1 + 2i)
+       assert(_5 == 1)
+       f32 = _5
+       f64 = _5
+       const _6 = real(0i)
+       assert(_6 == 0)
+       f32 = real(c64)
+       f64 = real(c128)
+       f32 = real /* ERROR cannot use .* in assignment */ (c128)
+       f64 = real /* ERROR cannot use .* in assignment */ (c64)
+       real /* ERROR not used */ (c64)
+
+       // complex type may not be predeclared
+       type C64 complex64
+       type C128 complex128
+       var x64 C64
+       var x128 C128
+       f32 = imag(x64)
+       f64 = imag(x128)
+       _, _ = f32, f64
+
+       var a []complex64
+       _ = real(a... /* ERROR invalid use of \.\.\. */ )
+
+       // if argument is untyped, result is untyped
+       const _ byte = real(1 + 2.3i)
+       const _ complex128 = real(1 + 2.3i)
+
+       // lhs constant shift operands are typed as complex128
+       var s uint
+       _ = real(1 /* ERROR must be integer */ << s)
+}
+
+func real2() {
+       f1 := func() (x complex128) { return }
+       f2 := func() (x, y complex128) { return }
+       _ = real(f0 /* ERROR used as value */ ())
+       _ = real(f1())
+       _ = real(f2()) // ERROR too many arguments
+}
+
+func recover1() {
+       _ = recover()
+       _ = recover(10) // ERROR too many arguments
+       recover()
+
+       var s []int
+       recover(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func recover2() {
+       f1 := func() (x int) { return }
+       f2 := func() (x, y int) { return }
+       _ = recover(f0 /* ERROR used as value */ ())
+       _ = recover(f1()) // ERROR too many arguments
+       _ = recover(f2()) // ERROR too many arguments
+}
+
+// assuming types.DefaultPtrSize == 8
+type S0 struct{      // offset
+       a bool       //  0
+       b rune       //  4
+       c *int       //  8
+       d bool       // 16
+       e complex128 // 24
+}                    // 40
+
+type S1 struct{   // offset
+       x float32 //  0
+       y string  //  8
+       z *S1     // 24
+       S0        // 32
+}                 // 72
+
+type S2 struct{ // offset
+       *S1     //  0
+}               //  8
+
+type S3 struct { // offset
+       a int64  //  0
+       b int32  //  8
+}                // 12
+
+type S4 struct { // offset
+       S3       //  0
+       int32    // 12
+}                // 16
+
+type S5 struct {   // offset
+       a [3]int32 //  0
+       b int32    // 12
+}                  // 16
+
+func (S2) m() {}
+
+func Alignof1() {
+       var x int
+       _ = unsafe.Alignof() // ERROR not enough arguments
+       _ = unsafe.Alignof(1, 2) // ERROR too many arguments
+       _ = unsafe.Alignof(int /* ERROR not an expression */)
+       _ = unsafe.Alignof(42)
+       _ = unsafe.Alignof(new(struct{}))
+       _ = unsafe.Alignof(1<<10)
+       _ = unsafe.Alignof(1 /* ERROR overflows */ <<1000)
+       _ = unsafe.Alignof(nil /* ERROR "untyped nil */ )
+       unsafe /* ERROR not used */ .Alignof(x)
+
+       var y S0
+       assert(unsafe.Alignof(y.a) == 1)
+       assert(unsafe.Alignof(y.b) == 4)
+       assert(unsafe.Alignof(y.c) == 8)
+       assert(unsafe.Alignof(y.d) == 1)
+       assert(unsafe.Alignof(y.e) == 8)
+
+       var s []byte
+       _ = unsafe.Alignof(s)
+       _ = unsafe.Alignof(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func Alignof2() {
+       f1 := func() (x int32) { return }
+       f2 := func() (x, y int32) { return }
+       _ = unsafe.Alignof(f0 /* ERROR used as value */ ())
+       assert(unsafe.Alignof(f1()) == 4)
+       _ = unsafe.Alignof(f2()) // ERROR too many arguments
+}
+
+func Offsetof1() {
+       var x struct{ f int }
+       _ = unsafe.Offsetof() // ERROR not enough arguments
+       _ = unsafe.Offsetof(1, 2) // ERROR too many arguments
+       _ = unsafe.Offsetof(int /* ERROR not a selector expression */ )
+       _ = unsafe.Offsetof(x /* ERROR not a selector expression */ )
+       _ = unsafe.Offsetof(nil /* ERROR not a selector expression */ )
+       _ = unsafe.Offsetof(x.f)
+       _ = unsafe.Offsetof((x.f))
+       _ = unsafe.Offsetof((((((((x))).f)))))
+       unsafe /* ERROR not used */ .Offsetof(x.f)
+
+       var y0 S0
+       assert(unsafe.Offsetof(y0.a) == 0)
+       assert(unsafe.Offsetof(y0.b) == 4)
+       assert(unsafe.Offsetof(y0.c) == 8)
+       assert(unsafe.Offsetof(y0.d) == 16)
+       assert(unsafe.Offsetof(y0.e) == 24)
+
+       var y1 S1
+       assert(unsafe.Offsetof(y1.x) == 0)
+       assert(unsafe.Offsetof(y1.y) == 8)
+       assert(unsafe.Offsetof(y1.z) == 24)
+       assert(unsafe.Offsetof(y1.S0) == 32)
+
+       assert(unsafe.Offsetof(y1.S0.a) == 0) // relative to S0
+       assert(unsafe.Offsetof(y1.a) == 32)   // relative to S1
+       assert(unsafe.Offsetof(y1.b) == 36)   // relative to S1
+       assert(unsafe.Offsetof(y1.c) == 40)   // relative to S1
+       assert(unsafe.Offsetof(y1.d) == 48)   // relative to S1
+       assert(unsafe.Offsetof(y1.e) == 56)   // relative to S1
+
+       var y1p *S1
+       assert(unsafe.Offsetof(y1p.S0) == 32)
+
+       type P *S1
+       var p P = y1p
+       assert(unsafe.Offsetof(p.S0) == 32)
+
+       var y2 S2
+       assert(unsafe.Offsetof(y2.S1) == 0)
+       _ = unsafe.Offsetof(y2 /* ERROR embedded via a pointer */ .x)
+       _ = unsafe.Offsetof(y2 /* ERROR method value */ .m)
+
+       var s []byte
+       _ = unsafe.Offsetof(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func Offsetof2() {
+       f1 := func() (x int32) { return }
+       f2 := func() (x, y int32) { return }
+       _ = unsafe.Offsetof(f0 /* ERROR not a selector expression */ ())
+       _ = unsafe.Offsetof(f1 /* ERROR not a selector expression */ ())
+       _ = unsafe.Offsetof(f2 /* ERROR not a selector expression */ ())
+}
+
+func Sizeof1() {
+       var x int
+       _ = unsafe.Sizeof() // ERROR not enough arguments
+       _ = unsafe.Sizeof(1, 2) // ERROR too many arguments
+       _ = unsafe.Sizeof(int /* ERROR not an expression */)
+       _ = unsafe.Sizeof(42)
+       _ = unsafe.Sizeof(new(complex128))
+       _ = unsafe.Sizeof(1<<10)
+       _ = unsafe.Sizeof(1 /* ERROR overflows */ <<1000)
+       _ = unsafe.Sizeof(nil /* ERROR untyped nil */ )
+       unsafe /* ERROR not used */ .Sizeof(x)
+
+       // basic types have size guarantees
+       assert(unsafe.Sizeof(byte(0)) == 1)
+       assert(unsafe.Sizeof(uint8(0)) == 1)
+       assert(unsafe.Sizeof(int8(0)) == 1)
+       assert(unsafe.Sizeof(uint16(0)) == 2)
+       assert(unsafe.Sizeof(int16(0)) == 2)
+       assert(unsafe.Sizeof(uint32(0)) == 4)
+       assert(unsafe.Sizeof(int32(0)) == 4)
+       assert(unsafe.Sizeof(float32(0)) == 4)
+       assert(unsafe.Sizeof(uint64(0)) == 8)
+       assert(unsafe.Sizeof(int64(0)) == 8)
+       assert(unsafe.Sizeof(float64(0)) == 8)
+       assert(unsafe.Sizeof(complex64(0)) == 8)
+       assert(unsafe.Sizeof(complex128(0)) == 16)
+
+       var y0 S0
+       assert(unsafe.Sizeof(y0.a) == 1)
+       assert(unsafe.Sizeof(y0.b) == 4)
+       assert(unsafe.Sizeof(y0.c) == 8)
+       assert(unsafe.Sizeof(y0.d) == 1)
+       assert(unsafe.Sizeof(y0.e) == 16)
+       assert(unsafe.Sizeof(y0) == 40)
+
+       var y1 S1
+       assert(unsafe.Sizeof(y1) == 72)
+
+       var y2 S2
+       assert(unsafe.Sizeof(y2) == 8)
+
+       var y3 S3
+       assert(unsafe.Sizeof(y3) == 12)
+
+       var y4 S4
+       assert(unsafe.Sizeof(y4) == 16)
+
+       var y5 S5
+       assert(unsafe.Sizeof(y5) == 16)
+
+       var a3 [10]S3
+       assert(unsafe.Sizeof(a3) == 156)
+
+       // test case for issue 5670
+       type T struct {
+               a int32
+               _ int32
+               c int32
+       }
+       assert(unsafe.Sizeof(T{}) == 12)
+
+       var s []byte
+       _ = unsafe.Sizeof(s)
+       _ = unsafe.Sizeof(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func Sizeof2() {
+       f1 := func() (x int64) { return }
+       f2 := func() (x, y int64) { return }
+       _ = unsafe.Sizeof(f0 /* ERROR used as value */ ())
+       assert(unsafe.Sizeof(f1()) == 8)
+       _ = unsafe.Sizeof(f2()) // ERROR too many arguments
+}
+
+// self-testing only
+func assert1() {
+       var x int
+       assert() /* ERROR not enough arguments */
+       assert(1, 2) /* ERROR too many arguments */
+       assert("foo" /* ERROR boolean constant */ )
+       assert(x /* ERROR boolean constant */)
+       assert(true)
+       assert /* ERROR failed */ (false)
+       _ = assert(true)
+
+       var s []byte
+       assert(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func assert2() {
+       f1 := func() (x bool) { return }
+       f2 := func() (x bool) { return }
+       assert(f0 /* ERROR used as value */ ())
+       assert(f1 /* ERROR boolean constant */ ())
+       assert(f2 /* ERROR boolean constant */ ())
+}
+
+// self-testing only
+func trace1() {
+       // Uncomment the code below to test trace - will produce console output
+       // _ = trace /* ERROR no value */ ()
+       // _ = trace(1)
+       // _ = trace(true, 1.2, '\'', "foo", 42i, "foo" <= "bar")
+
+       var s []byte
+       trace(s... /* ERROR invalid use of \.\.\. */ )
+}
+
+func trace2() {
+       f1 := func() (x int) { return }
+       f2 := func() (x int, y string) { return }
+       f3 := func() (x int, y string, z []int) { return }
+       _ = f1
+       _ = f2
+       _ = f3
+       // Uncomment the code below to test trace - will produce console output
+       // trace(f0())
+       // trace(f1())
+       // trace(f2())
+       // trace(f3())
+       // trace(f0(), 1)
+       // trace(f1(), 1, 2)
+       // trace(f2(), 1, 2, 3)
+       // trace(f3(), 1, 2, 3, 4)
+}
diff --git a/libgo/go/go/types/testdata/const0.src b/libgo/go/go/types/testdata/const0.src
new file mode 100644 (file)
index 0000000..a617178
--- /dev/null
@@ -0,0 +1,295 @@
+// 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.
+
+// constant declarations
+
+package const0
+
+// constants declarations must be initialized by constants
+var x = 0
+const c0 = x /* ERROR "not constant" */
+
+// typed constants must have constant types
+const _ interface /* ERROR invalid constant type */ {} = 0
+
+func _ () {
+       const _ interface /* ERROR invalid constant type */ {} = 0
+       for i := 0; i < 10; i++ {} // don't crash with non-nil iota here
+}
+
+// untyped constants
+const (
+       // boolean values
+       ub0 = false
+       ub1 = true
+       ub2 = 2 < 1
+       ub3 = ui1 == uf1
+       ub4 = true /* ERROR "cannot convert" */ == 0
+
+       // integer values
+       ui0 = 0
+       ui1 = 1
+       ui2 = 42
+       ui3 = 3141592653589793238462643383279502884197169399375105820974944592307816406286
+       ui4 = -10
+
+       ui5 = ui0 + ui1
+       ui6 = ui1 - ui1
+       ui7 = ui2 * ui1
+       ui8 = ui3 / ui3
+       ui9 = ui3 % ui3
+
+       ui10 = 1 / 0 /* ERROR "division by zero" */
+       ui11 = ui1 / 0 /* ERROR "division by zero" */
+       ui12 = ui3 / ui0 /* ERROR "division by zero" */
+       ui13 = 1 % 0 /* ERROR "division by zero" */
+       ui14 = ui1 % 0 /* ERROR "division by zero" */
+       ui15 = ui3 % ui0 /* ERROR "division by zero" */
+
+       ui16 = ui2 & ui3
+       ui17 = ui2 | ui3
+       ui18 = ui2 ^ ui3
+       ui19 = 1 /* ERROR "invalid operation" */ % 1.0
+
+       // floating point values
+       uf0 = 0.
+       uf1 = 1.
+       uf2 = 4.2e1
+       uf3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
+       uf4 = 1e-1
+
+       uf5 = uf0 + uf1
+       uf6 = uf1 - uf1
+       uf7 = uf2 * uf1
+       uf8 = uf3 / uf3
+       uf9 = uf3 /* ERROR "not defined" */ % uf3
+
+       uf10 = 1 / 0 /* ERROR "division by zero" */
+       uf11 = uf1 / 0 /* ERROR "division by zero" */
+       uf12 = uf3 / uf0 /* ERROR "division by zero" */
+
+       uf16 = uf2 /* ERROR "not defined" */ & uf3
+       uf17 = uf2 /* ERROR "not defined" */ | uf3
+       uf18 = uf2 /* ERROR "not defined" */ ^ uf3
+
+       // complex values
+       uc0 = 0.i
+       uc1 = 1.i
+       uc2 = 4.2e1i
+       uc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i
+       uc4 = 1e-1i
+
+       uc5 = uc0 + uc1
+       uc6 = uc1 - uc1
+       uc7 = uc2 * uc1
+       uc8 = uc3 / uc3
+       uc9 = uc3 /* ERROR "not defined" */ % uc3
+
+       uc10 = 1 / 0 /* ERROR "division by zero" */
+       uc11 = uc1 / 0 /* ERROR "division by zero" */
+       uc12 = uc3 / uc0 /* ERROR "division by zero" */
+
+       uc16 = uc2 /* ERROR "not defined" */ & uc3
+       uc17 = uc2 /* ERROR "not defined" */ | uc3
+       uc18 = uc2 /* ERROR "not defined" */ ^ uc3
+)
+
+type (
+       mybool bool
+       myint int
+       myfloat float64
+       mycomplex complex128
+)
+
+// typed constants
+const (
+       // boolean values
+       tb0 bool = false
+       tb1 bool = true
+       tb2 mybool = 2 < 1
+       tb3 mybool = ti1 /* ERROR "mismatched types" */ == tf1
+
+       // integer values
+       ti0 int8 = ui0
+       ti1 int32 = ui1
+       ti2 int64 = ui2
+       ti3 myint = ui3 /* ERROR "overflows" */
+       ti4 myint = ui4
+
+       ti5 = ti0 /* ERROR "mismatched types" */ + ti1
+       ti6 = ti1 - ti1
+       ti7 = ti2 /* ERROR "mismatched types" */ * ti1
+       ti8 = ti3 / ti3
+       ti9 = ti3 % ti3
+
+       ti10 = 1 / 0 /* ERROR "division by zero" */
+       ti11 = ti1 / 0 /* ERROR "division by zero" */
+       ti12 = ti3 /* ERROR "mismatched types" */ / ti0
+       ti13 = 1 % 0 /* ERROR "division by zero" */
+       ti14 = ti1 % 0 /* ERROR "division by zero" */
+       ti15 = ti3 /* ERROR "mismatched types" */ % ti0
+
+       ti16 = ti2 /* ERROR "mismatched types" */ & ti3
+       ti17 = ti2 /* ERROR "mismatched types" */ | ti4
+       ti18 = ti2 ^ ti5 // no mismatched types error because the type of ti5 is unknown
+
+       // floating point values
+       tf0 float32 = 0.
+       tf1 float32 = 1.
+       tf2 float64 = 4.2e1
+       tf3 myfloat = 3.141592653589793238462643383279502884197169399375105820974944592307816406286
+       tf4 myfloat = 1e-1
+
+       tf5 = tf0 + tf1
+       tf6 = tf1 - tf1
+       tf7 = tf2 /* ERROR "mismatched types" */ * tf1
+       tf8 = tf3 / tf3
+       tf9 = tf3 /* ERROR "not defined" */ % tf3
+
+       tf10 = 1 / 0 /* ERROR "division by zero" */
+       tf11 = tf1 / 0 /* ERROR "division by zero" */
+       tf12 = tf3 /* ERROR "mismatched types" */ / tf0
+
+       tf16 = tf2 /* ERROR "mismatched types" */ & tf3
+       tf17 = tf2 /* ERROR "mismatched types" */ | tf3
+       tf18 = tf2 /* ERROR "mismatched types" */ ^ tf3
+
+       // complex values
+       tc0 = 0.i
+       tc1 = 1.i
+       tc2 = 4.2e1i
+       tc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i
+       tc4 = 1e-1i
+
+       tc5 = tc0 + tc1
+       tc6 = tc1 - tc1
+       tc7 = tc2 * tc1
+       tc8 = tc3 / tc3
+       tc9 = tc3 /* ERROR "not defined" */ % tc3
+
+       tc10 = 1 / 0 /* ERROR "division by zero" */
+       tc11 = tc1 / 0 /* ERROR "division by zero" */
+       tc12 = tc3 / tc0 /* ERROR "division by zero" */
+
+       tc16 = tc2 /* ERROR "not defined" */ & tc3
+       tc17 = tc2 /* ERROR "not defined" */ | tc3
+       tc18 = tc2 /* ERROR "not defined" */ ^ tc3
+)
+
+// initialization cycles
+const (
+       a /* ERROR "initialization cycle" */ = a
+       b /* ERROR "initialization cycle" */ , c /* ERROR "initialization cycle" */, d, e = e, d, c, b // TODO(gri) should only have one cycle error
+       f float64 = d
+)
+
+// multiple initialization
+const (
+       a1, a2, a3 = 7, 3.1415926, "foo"
+       b1, b2, b3 = b3, b1, 42
+       c1, c2, c3  /* ERROR "missing init expr for c3" */ = 1, 2
+       d1, d2, d3 = 1, 2, 3, 4 /* ERROR "extra init expr 4" */
+       _p0 = assert(a1 == 7)
+       _p1 = assert(a2 == 3.1415926)
+       _p2 = assert(a3 == "foo")
+       _p3 = assert(b1 == 42)
+       _p4 = assert(b2 == 42)
+       _p5 = assert(b3 == 42)
+)
+
+func _() {
+       const (
+               a1, a2, a3 = 7, 3.1415926, "foo"
+               b1, b2, b3 = b3, b1, 42
+               c1, c2, c3  /* ERROR "missing init expr for c3" */ = 1, 2
+               d1, d2, d3 = 1, 2, 3, 4 /* ERROR "extra init expr 4" */
+               _p0 = assert(a1 == 7)
+               _p1 = assert(a2 == 3.1415926)
+               _p2 = assert(a3 == "foo")
+               _p3 = assert(b1 == 42)
+               _p4 = assert(b2 == 42)
+               _p5 = assert(b3 == 42)
+       )
+}
+
+// iota
+const (
+       iota0 = iota
+       iota1 = iota
+       iota2 = iota*2
+       _a0 = assert(iota0 == 0)
+       _a1 = assert(iota1 == 1)
+       _a2 = assert(iota2 == 4)
+       iota6 = iota*3
+
+       iota7
+       iota8
+       _a3 = assert(iota7 == 21)
+       _a4 = assert(iota8 == 24)
+)
+
+const (
+       _b0 = iota
+       _b1 = assert(iota + iota2 == 5)
+       _b2 = len([iota]int{}) // iota may appear in a type!
+       _b3 = assert(_b2 == 2)
+       _b4 = len(A{})
+)
+
+type A [iota /* ERROR "cannot use iota" */ ]int
+
+// constant expressions with operands across different
+// constant declarations must use the right iota values
+const (
+       _c0 = iota
+       _c1
+       _c2
+       _x = _c2 + _d1 + _e0 // 3
+)
+
+const (
+       _d0 = iota
+       _d1
+)
+
+const (
+       _e0 = iota
+)
+
+var _ = assert(_x == 3)
+
+// special cases
+const (
+       _n0 = nil /* ERROR "not constant" */
+       _n1 = [ /* ERROR "not constant" */ ]int{}
+)
+
+// iotas must not be usable in expressions outside constant declarations
+type _ [iota /* ERROR "iota outside constant decl" */ ]byte
+var _ = iota /* ERROR "iota outside constant decl" */
+func _() {
+       _ = iota /* ERROR "iota outside constant decl" */
+       const _ = iota
+       _ = iota /* ERROR "iota outside constant decl" */
+}
+
+func _() {
+       iota := 123
+       const x = iota /* ERROR "is not constant" */
+       var y = iota
+       _ = y
+}
+
+// constant arithmetic precision and rounding must lead to expected (integer) results
+var _ = []int64{
+       0.0005 * 1e9,
+       0.001 * 1e9,
+       0.005 * 1e9,
+       0.01 * 1e9,
+       0.05 * 1e9,
+       0.1 * 1e9,
+       0.5 * 1e9,
+       1 * 1e9,
+       5 * 1e9,
+}
diff --git a/libgo/go/go/types/testdata/const1.src b/libgo/go/go/types/testdata/const1.src
new file mode 100644 (file)
index 0000000..d827704
--- /dev/null
@@ -0,0 +1,322 @@
+// 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.
+
+// constant conversions
+
+package const1
+
+const(
+       mi = ^int(0)
+       mu = ^uint(0)
+       mp = ^uintptr(0)
+
+       logSizeofInt     = uint(mi>>8&1 + mi>>16&1 + mi>>32&1)
+       logSizeofUint    = uint(mu>>8&1 + mu>>16&1 + mu>>32&1)
+       logSizeofUintptr = uint(mp>>8&1 + mp>>16&1 + mp>>32&1)
+)
+
+const (
+       minInt8 = -1<<(8<<iota - 1)
+       minInt16
+       minInt32
+       minInt64
+       minInt = -1<<(8<<logSizeofInt - 1)
+)
+
+const (
+       maxInt8 = 1<<(8<<iota - 1) - 1
+       maxInt16
+       maxInt32
+       maxInt64
+       maxInt = 1<<(8<<logSizeofInt - 1) - 1
+)
+
+const (
+       maxUint8 = 1<<(8<<iota) - 1
+       maxUint16
+       maxUint32
+       maxUint64
+       maxUint    = 1<<(8<<logSizeofUint) - 1
+       maxUintptr = 1<<(8<<logSizeofUintptr) - 1
+)
+
+const (
+       smallestFloat32 = 1.0 / (1<<(127 - 1 + 23))
+       smallestFloat64 = 1.0 / (1<<(1023 - 1 + 52))
+)
+
+const (
+       _ = assert(smallestFloat32 > 0)
+       _ = assert(smallestFloat64 > 0)
+)
+
+const (
+       maxFloat32 = 1<<127 * (1<<24 - 1) / (1.0<<23)
+       maxFloat64 = 1<<1023 * (1<<53 - 1) / (1.0<<52)
+)
+
+const (
+       _ int8 = minInt8 /* ERROR "overflows" */ - 1
+       _ int8 = minInt8
+       _ int8 = maxInt8
+       _ int8 = maxInt8 /* ERROR "overflows" */ + 1
+       _ int8 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = int8(minInt8 /* ERROR "cannot convert" */ - 1)
+       _ = int8(minInt8)
+       _ = int8(maxInt8)
+       _ = int8(maxInt8 /* ERROR "cannot convert" */ + 1)
+       _ = int8(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ int16 = minInt16 /* ERROR "overflows" */ - 1
+       _ int16 = minInt16
+       _ int16 = maxInt16
+       _ int16 = maxInt16 /* ERROR "overflows" */ + 1
+       _ int16 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = int16(minInt16 /* ERROR "cannot convert" */ - 1)
+       _ = int16(minInt16)
+       _ = int16(maxInt16)
+       _ = int16(maxInt16 /* ERROR "cannot convert" */ + 1)
+       _ = int16(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ int32 = minInt32 /* ERROR "overflows" */ - 1
+       _ int32 = minInt32
+       _ int32 = maxInt32
+       _ int32 = maxInt32 /* ERROR "overflows" */ + 1
+       _ int32 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = int32(minInt32 /* ERROR "cannot convert" */ - 1)
+       _ = int32(minInt32)
+       _ = int32(maxInt32)
+       _ = int32(maxInt32 /* ERROR "cannot convert" */ + 1)
+       _ = int32(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ int64 = minInt64 /* ERROR "overflows" */ - 1
+       _ int64 = minInt64
+       _ int64 = maxInt64
+       _ int64 = maxInt64 /* ERROR "overflows" */ + 1
+       _ int64 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = int64(minInt64 /* ERROR "cannot convert" */ - 1)
+       _ = int64(minInt64)
+       _ = int64(maxInt64)
+       _ = int64(maxInt64 /* ERROR "cannot convert" */ + 1)
+       _ = int64(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ int = minInt /* ERROR "overflows" */ - 1
+       _ int = minInt
+       _ int = maxInt
+       _ int = maxInt /* ERROR "overflows" */ + 1
+       _ int = smallestFloat64 /* ERROR "truncated" */
+
+       _ = int(minInt /* ERROR "cannot convert" */ - 1)
+       _ = int(minInt)
+       _ = int(maxInt)
+       _ = int(maxInt /* ERROR "cannot convert" */ + 1)
+       _ = int(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uint8 = 0 /* ERROR "overflows" */ - 1
+       _ uint8 = 0
+       _ uint8 = maxUint8
+       _ uint8 = maxUint8 /* ERROR "overflows" */ + 1
+       _ uint8 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uint8(0 /* ERROR "cannot convert" */ - 1)
+       _ = uint8(0)
+       _ = uint8(maxUint8)
+       _ = uint8(maxUint8 /* ERROR "cannot convert" */ + 1)
+       _ = uint8(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uint16 = 0 /* ERROR "overflows" */ - 1
+       _ uint16 = 0
+       _ uint16 = maxUint16
+       _ uint16 = maxUint16 /* ERROR "overflows" */ + 1
+       _ uint16 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uint16(0 /* ERROR "cannot convert" */ - 1)
+       _ = uint16(0)
+       _ = uint16(maxUint16)
+       _ = uint16(maxUint16 /* ERROR "cannot convert" */ + 1)
+       _ = uint16(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uint32 = 0 /* ERROR "overflows" */ - 1
+       _ uint32 = 0
+       _ uint32 = maxUint32
+       _ uint32 = maxUint32 /* ERROR "overflows" */ + 1
+       _ uint32 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uint32(0 /* ERROR "cannot convert" */ - 1)
+       _ = uint32(0)
+       _ = uint32(maxUint32)
+       _ = uint32(maxUint32 /* ERROR "cannot convert" */ + 1)
+       _ = uint32(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uint64 = 0 /* ERROR "overflows" */ - 1
+       _ uint64 = 0
+       _ uint64 = maxUint64
+       _ uint64 = maxUint64 /* ERROR "overflows" */ + 1
+       _ uint64 = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uint64(0 /* ERROR "cannot convert" */ - 1)
+       _ = uint64(0)
+       _ = uint64(maxUint64)
+       _ = uint64(maxUint64 /* ERROR "cannot convert" */ + 1)
+       _ = uint64(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uint = 0 /* ERROR "overflows" */ - 1
+       _ uint = 0
+       _ uint = maxUint
+       _ uint = maxUint /* ERROR "overflows" */ + 1
+       _ uint = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uint(0 /* ERROR "cannot convert" */ - 1)
+       _ = uint(0)
+       _ = uint(maxUint)
+       _ = uint(maxUint /* ERROR "cannot convert" */ + 1)
+       _ = uint(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ uintptr = 0 /* ERROR "overflows" */ - 1
+       _ uintptr = 0
+       _ uintptr = maxUintptr
+       _ uintptr = maxUintptr /* ERROR "overflows" */ + 1
+       _ uintptr = smallestFloat64 /* ERROR "truncated" */
+
+       _ = uintptr(0 /* ERROR "cannot convert" */ - 1)
+       _ = uintptr(0)
+       _ = uintptr(maxUintptr)
+       _ = uintptr(maxUintptr /* ERROR "cannot convert" */ + 1)
+       _ = uintptr(smallestFloat64 /* ERROR "cannot convert" */)
+)
+
+const (
+       _ float32 = minInt64
+       _ float64 = minInt64
+       _ complex64 = minInt64
+       _ complex128 = minInt64
+
+       _ = float32(minInt64)
+       _ = float64(minInt64)
+       _ = complex64(minInt64)
+       _ = complex128(minInt64)
+)
+
+const (
+       _ float32 = maxUint64
+       _ float64 = maxUint64
+       _ complex64 = maxUint64
+       _ complex128 = maxUint64
+
+       _ = float32(maxUint64)
+       _ = float64(maxUint64)
+       _ = complex64(maxUint64)
+       _ = complex128(maxUint64)
+)
+
+// TODO(gri) find smaller deltas below
+
+const delta32 = maxFloat32/(1 << 23)
+
+const (
+       _ float32 = - /* ERROR "overflow" */ (maxFloat32 + delta32)
+       _ float32 = -maxFloat32
+       _ float32 = maxFloat32
+       _ float32 = maxFloat32 /* ERROR "overflow" */ + delta32
+
+       _ = float32(- /* ERROR "cannot convert" */ (maxFloat32 + delta32))
+       _ = float32(-maxFloat32)
+       _ = float32(maxFloat32)
+       _ = float32(maxFloat32 /* ERROR "cannot convert" */ + delta32)
+
+       _ = assert(float32(smallestFloat32) == smallestFloat32)
+       _ = assert(float32(smallestFloat32/2) == 0)
+       _ = assert(float32(smallestFloat64) == 0)
+       _ = assert(float32(smallestFloat64/2) == 0)
+)
+
+const delta64 = maxFloat64/(1 << 52)
+
+const (
+       _ float64 = - /* ERROR "overflow" */ (maxFloat64 + delta64)
+       _ float64 = -maxFloat64
+       _ float64 = maxFloat64
+       _ float64 = maxFloat64 /* ERROR "overflow" */ + delta64
+
+       _ = float64(- /* ERROR "cannot convert" */ (maxFloat64 + delta64))
+       _ = float64(-maxFloat64)
+       _ = float64(maxFloat64)
+       _ = float64(maxFloat64 /* ERROR "cannot convert" */ + delta64)
+
+       _ = assert(float64(smallestFloat32) == smallestFloat32)
+       _ = assert(float64(smallestFloat32/2) == smallestFloat32/2)
+       _ = assert(float64(smallestFloat64) == smallestFloat64)
+       _ = assert(float64(smallestFloat64/2) == 0)
+)
+
+const (
+       _ complex64 = - /* ERROR "overflow" */ (maxFloat32 + delta32)
+       _ complex64 = -maxFloat32
+       _ complex64 = maxFloat32
+       _ complex64 = maxFloat32 /* ERROR "overflow" */ + delta32
+
+       _ = complex64(- /* ERROR "cannot convert" */ (maxFloat32 + delta32))
+       _ = complex64(-maxFloat32)
+       _ = complex64(maxFloat32)
+       _ = complex64(maxFloat32 /* ERROR "cannot convert" */ + delta32)
+)
+
+const (
+       _ complex128 = - /* ERROR "overflow" */ (maxFloat64 + delta64)
+       _ complex128 = -maxFloat64
+       _ complex128 = maxFloat64
+       _ complex128 = maxFloat64 /* ERROR "overflow" */ + delta64
+
+       _ = complex128(- /* ERROR "cannot convert" */ (maxFloat64 + delta64))
+       _ = complex128(-maxFloat64)
+       _ = complex128(maxFloat64)
+       _ = complex128(maxFloat64 /* ERROR "cannot convert" */ + delta64)
+)
+
+// Initialization of typed constant and conversion are the same:
+const (
+       f32 = 1 + smallestFloat32
+       x32 float32 = f32
+       y32 = float32(f32)
+       _ = assert(x32 - y32 == 0)
+)
+
+const (
+       f64 = 1 + smallestFloat64
+       x64 float64 = f64
+       y64 = float64(f64)
+       _ = assert(x64 - y64 == 0)
+)
+
+const (
+       _ = int8(-1) << 7
+       _ = int8 /* ERROR "overflows" */ (-1) << 8
+
+       _ = uint32(1) << 31
+       _ = uint32 /* ERROR "overflows" */ (1) << 32
+)
diff --git a/libgo/go/go/types/testdata/constdecl.src b/libgo/go/go/types/testdata/constdecl.src
new file mode 100644 (file)
index 0000000..6de9b13
--- /dev/null
@@ -0,0 +1,97 @@
+// 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 constdecl
+
+import "math"
+
+var v int
+
+// Const decls must be initialized by constants.
+const _ = v /* ERROR "not constant" */
+const _ = math /* ERROR "not constant" */ .Sin(0)
+const _ = int /* ERROR "not an expression" */
+
+func _() {
+       const _ = v /* ERROR "not constant" */
+       const _ = math /* ERROR "not constant" */ .Sin(0)
+       const _ = int /* ERROR "not an expression" */
+}
+
+// Identifier and expression arity must match.
+// The first error message is produced by the parser.
+// In a real-world scenario, the type-checker would not be run
+// in this case and the 2nd error message would not appear.
+const _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */
+const _ = 1, 2 /* ERROR "extra init expr 2" */
+
+const _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */ int
+const _ int = 1, 2 /* ERROR "extra init expr 2" */
+
+const (
+       _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */
+       _ = 1, 2 /* ERROR "extra init expr 2" */
+
+       _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */ int
+       _ int = 1, 2 /* ERROR "extra init expr 2" */
+)
+
+const (
+       _ = 1
+       _
+       _, _ /* ERROR "missing init expr for _" */
+       _
+)
+
+const (
+       _, _ = 1, 2
+       _, _
+       _ /* ERROR "extra init expr at" */
+       _, _
+       _, _, _ /* ERROR "missing init expr for _" */
+       _, _
+)
+
+func _() {
+       const _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */
+       const _ = 1, 2 /* ERROR "extra init expr 2" */
+
+       const _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */ int
+       const _ int = 1, 2 /* ERROR "extra init expr 2" */
+
+       const (
+               _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */
+               _ = 1, 2 /* ERROR "extra init expr 2" */
+
+               _ /* ERROR "missing constant value" */ /* ERROR "missing init expr for _" */ int
+               _ int = 1, 2 /* ERROR "extra init expr 2" */
+       )
+
+       const (
+               _ = 1
+               _
+               _, _ /* ERROR "missing init expr for _" */
+               _
+       )
+
+       const (
+               _, _ = 1, 2
+               _, _
+               _ /* ERROR "extra init expr at" */
+               _, _
+               _, _, _ /* ERROR "missing init expr for _" */
+               _, _
+       )
+}
+
+// Test case for constant with invalid initialization.
+// Caused panic because the constant value was not set up (gri - 7/8/2014).
+func _() {
+       const (
+           x string = missing /* ERROR "undeclared name" */
+           y = x + ""
+       )
+}
+
+// TODO(gri) move extra tests from testdata/const0.src into here
diff --git a/libgo/go/go/types/testdata/conversions.src b/libgo/go/go/types/testdata/conversions.src
new file mode 100644 (file)
index 0000000..e1336c0
--- /dev/null
@@ -0,0 +1,93 @@
+// 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.
+
+// conversions
+
+package conversions
+
+import "unsafe"
+
+// argument count
+var (
+       _ = int() /* ERROR "missing argument" */
+       _ = int(1, 2 /* ERROR "too many arguments" */ )
+)
+
+// numeric constant conversions are in const1.src.
+
+func string_conversions() {
+       const A = string(65)
+       assert(A == "A")
+       const E = string(-1)
+       assert(E == "\uFFFD")
+       assert(E == string(1234567890))
+
+       type myint int
+       assert(A == string(myint(65)))
+
+       type mystring string
+       const _ mystring = mystring("foo")
+
+       const _ = string(true /* ERROR "cannot convert" */ )
+       const _ = string(1.2 /* ERROR "cannot convert" */ )
+       const _ = string(nil /* ERROR "cannot convert" */ )
+
+       // issues 11357, 11353: argument must be of integer type
+       _ = string(0.0 /* ERROR "cannot convert" */ )
+       _ = string(0i /* ERROR "cannot convert" */ )
+       _ = string(1 /* ERROR "cannot convert" */ + 2i)
+}
+
+func interface_conversions() {
+       type E interface{}
+
+       type I1 interface{
+               m1()
+       }
+
+       type I2 interface{
+               m1()
+               m2(x int)
+       }
+
+       type I3 interface{
+               m1()
+               m2() int
+       }
+
+       var e E
+       var i1 I1
+       var i2 I2
+       var i3 I3
+
+       _ = E(0)
+       _ = E(nil)
+       _ = E(e)
+       _ = E(i1)
+       _ = E(i2)
+
+       _ = I1(0 /* ERROR "cannot convert" */ )
+       _ = I1(nil)
+       _ = I1(i1)
+       _ = I1(e /* ERROR "cannot convert" */ )
+       _ = I1(i2)
+
+       _ = I2(nil)
+       _ = I2(i1 /* ERROR "cannot convert" */ )
+       _ = I2(i2)
+       _ = I2(i3 /* ERROR "cannot convert" */ )
+
+       _ = I3(nil)
+       _ = I3(i1 /* ERROR "cannot convert" */ )
+       _ = I3(i2 /* ERROR "cannot convert" */ )
+       _ = I3(i3)
+
+       // TODO(gri) add more tests, improve error message
+}
+
+func issue6326() {
+       type T unsafe.Pointer
+       var x T
+       _ = uintptr(x) // see issue 6326
+}
diff --git a/libgo/go/go/types/testdata/conversions2.src b/libgo/go/go/types/testdata/conversions2.src
new file mode 100644 (file)
index 0000000..93a5f18
--- /dev/null
@@ -0,0 +1,313 @@
+// Copyright 2016 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.
+
+// Test various valid and invalid struct assignments and conversions.
+// Does not compile.
+
+package conversions2
+
+type I interface {
+       m()
+}
+
+// conversions between structs
+
+func _() {
+       type S struct{}
+       type T struct{}
+       var s S
+       var t T
+       var u struct{}
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u
+       s = S(s)
+       s = S(t)
+       s = S(u)
+       t = u
+       t = T(u)
+}
+
+func _() {
+       type S struct{ x int }
+       type T struct {
+               x int "foo"
+       }
+       var s S
+       var t T
+       var u struct {
+               x int "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = S(s)
+       s = S(t)
+       s = S(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = T(u)
+}
+
+func _() {
+       type E struct{ x int }
+       type S struct{ x E }
+       type T struct {
+               x E "foo"
+       }
+       var s S
+       var t T
+       var u struct {
+               x E "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = S(s)
+       s = S(t)
+       s = S(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = T(u)
+}
+
+func _() {
+       type S struct {
+               x struct {
+                       x int "foo"
+               }
+       }
+       type T struct {
+               x struct {
+                       x int "bar"
+               } "foo"
+       }
+       var s S
+       var t T
+       var u struct {
+               x struct {
+                       x int "bar"
+               } "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = S(s)
+       s = S(t)
+       s = S(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = T(u)
+}
+
+func _() {
+       type E1 struct {
+               x int "foo"
+       }
+       type E2 struct {
+               x int "bar"
+       }
+       type S struct{ x E1 }
+       type T struct {
+               x E2 "foo"
+       }
+       var s S
+       var t T
+       var u struct {
+               x E2 "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = S(s)
+       s = S(t /* ERROR "cannot convert" */ )
+       s = S(u /* ERROR "cannot convert" */ )
+       t = u   // ERROR "cannot use .* in assignment"
+       t = T(u)
+}
+
+func _() {
+       type E struct{ x int }
+       type S struct {
+               f func(struct {
+                       x int "foo"
+               })
+       }
+       type T struct {
+               f func(struct {
+                       x int "bar"
+               })
+       }
+       var s S
+       var t T
+       var u struct{ f func(E) }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = S(s)
+       s = S(t)
+       s = S(u /* ERROR "cannot convert" */ )
+       t = u   // ERROR "cannot use .* in assignment"
+       t = T(u /* ERROR "cannot convert" */ )
+}
+
+// conversions between pointers to structs
+
+func _() {
+       type S struct{}
+       type T struct{}
+       var s *S
+       var t *T
+       var u *struct{}
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = (*T)(u)
+}
+
+func _() {
+       type S struct{ x int }
+       type T struct {
+               x int "foo"
+       }
+       var s *S
+       var t *T
+       var u *struct {
+               x int "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = (*T)(u)
+}
+
+func _() {
+       type E struct{ x int }
+       type S struct{ x E }
+       type T struct {
+               x E "foo"
+       }
+       var s *S
+       var t *T
+       var u *struct {
+               x E "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = (*T)(u)
+}
+
+func _() {
+       type S struct {
+               x struct {
+                       x int "foo"
+               }
+       }
+       type T struct {
+               x struct {
+                       x int "bar"
+               } "foo"
+       }
+       var s *S
+       var t *T
+       var u *struct {
+               x struct {
+                       x int "bar"
+               } "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u)
+       t = u // ERROR "cannot use .* in assignment"
+       t = (*T)(u)
+}
+
+func _() {
+       type E1 struct {
+               x int "foo"
+       }
+       type E2 struct {
+               x int "bar"
+       }
+       type S struct{ x E1 }
+       type T struct {
+               x E2 "foo"
+       }
+       var s *S
+       var t *T
+       var u *struct {
+               x E2 "bar"
+       }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t /* ERROR "cannot convert" */ )
+       s = (*S)(u /* ERROR "cannot convert" */ )
+       t = u      // ERROR "cannot use .* in assignment"
+       t = (*T)(u)
+}
+
+func _() {
+       type E struct{ x int }
+       type S struct {
+               f func(struct {
+                       x int "foo"
+               })
+       }
+       type T struct {
+               f func(struct {
+                       x int "bar"
+               })
+       }
+       var s *S
+       var t *T
+       var u *struct{ f func(E) }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u /* ERROR "cannot convert" */ )
+       t = u      // ERROR "cannot use .* in assignment"
+       t = (*T)(u /* ERROR "cannot convert" */ )
+}
+
+func _() {
+       type E struct{ x int }
+       type S struct {
+               f func(*struct {
+                       x int "foo"
+               })
+       }
+       type T struct {
+               f func(*struct {
+                       x int "bar"
+               })
+       }
+       var s *S
+       var t *T
+       var u *struct{ f func(E) }
+       s = s
+       s = t // ERROR "cannot use .* in assignment"
+       s = u // ERROR "cannot use .* in assignment"
+       s = (*S)(s)
+       s = (*S)(t)
+       s = (*S)(u /* ERROR "cannot convert" */ )
+       t = u      // ERROR "cannot use .* in assignment"
+       t = (*T)(u /* ERROR "cannot convert" */ )
+}
diff --git a/libgo/go/go/types/testdata/cycles.src b/libgo/go/go/types/testdata/cycles.src
new file mode 100644 (file)
index 0000000..621d83c
--- /dev/null
@@ -0,0 +1,143 @@
+// 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 cycles
+
+type (
+       T0 int
+       T1 /* ERROR cycle */ T1
+       T2 *T2
+
+       T3 /* ERROR cycle */ T4
+       T4 T5
+       T5 T3
+
+       T6 T7
+       T7 *T8
+       T8 T6
+
+       // arrays
+       A0 /* ERROR cycle */ [10]A0
+       A1 [10]*A1
+
+       A2 /* ERROR cycle */ [10]A3
+       A3 [10]A4
+       A4 A2
+
+       A5 [10]A6
+       A6 *A5
+
+       // slices
+       L0 []L0
+
+       // structs
+       S0 /* ERROR cycle */ struct{ _ S0 }
+       S1 /* ERROR cycle */ struct{ S1 }
+       S2 struct{ _ *S2 }
+       S3 struct{ *S3 }
+
+       S4 /* ERROR cycle */ struct{ S5 }
+       S5 struct{ S6 }
+       S6 S4
+
+       // pointers
+       P0 *P0
+
+       // functions
+       F0 func(F0)
+       F1 func() F1
+       F2 func(F2) F2
+
+       // interfaces
+       I0 /* ERROR cycle */ interface{ I0 }
+
+       I1 interface{ I2 }
+       I2 interface{ I3 }
+       I3 /* ERROR cycle */ interface{ I1 }
+
+       I4 interface{ f(I4) }
+
+       // testcase for issue 5090
+       I5 interface{ f(I6) }
+       I6 interface{ I5 }
+
+       // maps
+       M0 map[M0 /* ERROR invalid map key */ ]M0
+
+       // channels
+       C0 chan C0
+)
+
+func _() {
+       type (
+               t1 /* ERROR cycle */ t1
+               t2 *t2
+
+               t3 t4 /* ERROR undeclared */
+               t4 t5 /* ERROR undeclared */
+               t5 t3
+
+               // arrays
+               a0 /* ERROR cycle */ [10]a0
+               a1 [10]*a1
+
+               // slices
+               l0 []l0
+
+               // structs
+               s0 /* ERROR cycle */ struct{ _ s0 }
+               s1 /* ERROR cycle */ struct{ s1 }
+               s2 struct{ _ *s2 }
+               s3 struct{ *s3 }
+
+               // pointers
+               p0 *p0
+
+               // functions
+               f0 func(f0)
+               f1 func() f1
+               f2 func(f2) f2
+
+               // interfaces
+               i0 /* ERROR cycle */ interface{ i0 }
+
+               // maps
+               m0 map[m0 /* ERROR invalid map key */ ]m0
+
+               // channels
+               c0 chan c0
+       )
+}
+
+// test cases for issue 6667
+
+type A [10]map[A /* ERROR invalid map key */ ]bool
+
+type S struct {
+       m map[S /* ERROR invalid map key */ ]bool
+}
+
+// test cases for issue 7236
+// (cycle detection must not be dependent on starting point of resolution)
+
+type (
+       P1 *T9
+       T9 /* ERROR cycle */ T9
+
+       T10 /* ERROR cycle */ T10
+       P2 *T10
+)
+
+func (T11) m() {}
+
+type T11 /* ERROR cycle */ struct{ T11 }
+
+type T12 /* ERROR cycle */ struct{ T12 }
+
+func (*T12) m() {}
+
+type (
+       P3 *T13
+       T13 /* ERROR cycle */ T13
+)
\ No newline at end of file
diff --git a/libgo/go/go/types/testdata/cycles1.src b/libgo/go/go/types/testdata/cycles1.src
new file mode 100644 (file)
index 0000000..ae2b38e
--- /dev/null
@@ -0,0 +1,77 @@
+// 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 p
+
+type (
+       A interface {
+               a() interface {
+                       ABC1
+               }
+       }
+       B interface {
+               b() interface {
+                       ABC2
+               }
+       }
+       C interface {
+               c() interface {
+                       ABC3
+               }
+       }
+
+       AB interface {
+               A
+               B
+       }
+       BC interface {
+               B
+               C
+       }
+
+       ABC1 interface {
+               A
+               B
+               C
+       }
+       ABC2 interface {
+               AB
+               C
+       }
+       ABC3 interface {
+               A
+               BC
+       }
+)
+
+var (
+       x1 ABC1
+       x2 ABC2
+       x3 ABC3
+)
+
+func _() {
+       // all types have the same method set
+       x1 = x2
+       x2 = x1
+
+       x1 = x3
+       x3 = x1
+
+       x2 = x3
+       x3 = x2
+
+       // all methods return the same type again
+       x1 = x1.a()
+       x1 = x1.b()
+       x1 = x1.c()
+
+       x2 = x2.a()
+       x2 = x2.b()
+       x2 = x2.c()
+
+       x3 = x3.a()
+       x3 = x3.b()
+       x3 = x3.c()
+}
diff --git a/libgo/go/go/types/testdata/cycles2.src b/libgo/go/go/types/testdata/cycles2.src
new file mode 100644 (file)
index 0000000..345ab56
--- /dev/null
@@ -0,0 +1,118 @@
+// 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 p
+
+import "unsafe"
+
+// Test case for issue 5090
+
+type t interface {
+       f(u)
+}
+
+type u interface {
+       t
+}
+
+func _() {
+       var t t
+       var u u
+
+       t.f(t)
+       t.f(u)
+       
+       u.f(t)
+       u.f(u)
+}
+
+
+// Test case for issue 6589.
+
+type A interface {
+       a() interface {
+               AB
+       }
+}
+
+type B interface {
+       a() interface {
+               AB
+       }
+}
+
+type AB interface {
+       a() interface {
+               A
+               B /* ERROR a redeclared */
+       }
+       b() interface {
+               A
+               B /* ERROR a redeclared */
+       }
+}
+
+var x AB
+var y interface {
+       A
+       B /* ERROR a redeclared */
+}
+var _ = x /* ERROR cannot compare */ == y
+
+
+// Test case for issue 6638.
+
+type T interface {
+       m() [T /* ERROR no value */ (nil).m()[0]]int
+}
+
+// Variations of this test case.
+
+type T1 interface {
+       m() [x1 /* ERROR no value */ .m()[0]]int
+}
+
+var x1 T1
+
+type T2 interface {
+       m() [len(x2 /* ERROR no value */ .m())]int
+}
+
+var x2 T2
+
+type T3 interface {
+       m() [unsafe.Sizeof(x3.m)]int
+}
+
+var x3 T3
+
+// The test case below should also report an error for
+// the cast inside the T4 interface (like it does for the
+// variable initialization). The reason why it does not is
+// that inside T4, the method x4.m depends on T4 which is not
+// fully set up yet. The x4.m method happens to have an empty
+// signature which is why the cast is permitted.
+// TODO(gri) Consider marking methods as incomplete and provide
+// a better error message in that case.
+
+type T4 interface {
+       m() [unsafe.Sizeof(cast4(x4.m))]int
+}
+
+var x4 T4
+var _ = cast4(x4 /* ERROR cannot convert */.m)
+
+type cast4 func()
+
+// This test is symmetric to the T4 case: Here the cast is
+// "correct", but it doesn't work inside the T5 interface.
+
+type T5 interface {
+       m() [unsafe.Sizeof(cast5(x5 /* ERROR cannot convert */ .m))]int
+}
+
+var x5 T5
+var _ = cast5(x5.m)
+
+type cast5 func() [0]int
diff --git a/libgo/go/go/types/testdata/cycles3.src b/libgo/go/go/types/testdata/cycles3.src
new file mode 100644 (file)
index 0000000..3da4fb5
--- /dev/null
@@ -0,0 +1,60 @@
+// 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 p
+
+import "unsafe"
+
+var (
+       _ A = A(nil).a().b().c().d().e().f()
+       _ A = A(nil).b().c().d().e().f()
+       _ A = A(nil).c().d().e().f()
+       _ A = A(nil).d().e().f()
+       _ A = A(nil).e().f()
+       _ A = A(nil).f()
+       _ A = A(nil)
+)
+
+type (
+       A interface {
+               a() B
+               B
+       }
+
+       B interface {
+               b() C
+               C
+       }
+
+       C interface {
+               c() D
+               D
+       }
+
+       D interface {
+               d() E
+               E
+       }
+
+       E interface {
+               e() F
+               F
+       }
+
+       F interface {
+               f() A
+       }
+)
+
+type (
+       U interface {
+               V
+       }
+
+       V interface {
+               v() [unsafe.Sizeof(u)]int
+       }
+)
+
+var u U
diff --git a/libgo/go/go/types/testdata/cycles4.src b/libgo/go/go/types/testdata/cycles4.src
new file mode 100644 (file)
index 0000000..445babc
--- /dev/null
@@ -0,0 +1,110 @@
+// 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 p
+
+// Check that all methods of T are collected before
+// determining the result type of m (which embeds
+// all methods of T).
+
+type T interface {
+       m() interface {T}
+       E
+}
+
+var _ = T.m(nil).m().e()
+
+type E interface {
+       e() int
+}
+
+// Check that unresolved forward chains are followed
+// (see also comment in resolver.go, checker.typeDecl).
+
+var _ = C.m(nil).m().e()
+
+type A B
+
+type B interface {
+       m() interface{C}
+       E
+}
+
+type C A
+
+// Check that interface type comparison for identity
+// does not recur endlessly.
+
+type T1 interface {
+       m() interface{T1}
+}
+
+type T2 interface {
+       m() interface{T2}
+}
+
+func _(x T1, y T2) {
+       // Checking for assignability of interfaces must check
+       // if all methods of x are present in y, and that they
+       // have identical signatures. The signatures recur via
+       // the result type, which is an interface that embeds
+       // a single method m that refers to the very interface
+       // that contains it. This requires cycle detection in
+       // identity checks for interface types.
+       x = y
+}
+
+type T3 interface {
+       m() interface{T4}
+}
+
+type T4 interface {
+       m() interface{T3}
+}
+
+func _(x T1, y T3) {
+       x = y
+}
+
+// Check that interfaces are type-checked in order of
+// (embedded interface) dependencies (was issue 7158).
+
+var x1 T5 = T7(nil)
+
+type T5 interface {
+       T6
+}
+
+type T6 interface {
+       m() T7
+}
+type T7 interface {
+       T5
+}
+
+// Actual test case from issue 7158.
+
+func wrapNode() Node {
+       return wrapElement()
+}
+
+func wrapElement() Element {
+       return nil
+}
+
+type EventTarget interface {
+       AddEventListener(Event)
+}
+
+type Node interface {
+       EventTarget
+}
+
+type Element interface {
+       Node
+}
+
+type Event interface {
+       Target() Element
+}
diff --git a/libgo/go/go/types/testdata/decls0.src b/libgo/go/go/types/testdata/decls0.src
new file mode 100644 (file)
index 0000000..d4df386
--- /dev/null
@@ -0,0 +1,210 @@
+// Copyright 2011 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.
+
+// type declarations
+
+package decls0
+
+import "unsafe"
+
+const pi = 3.1415
+
+type (
+       N undeclared /* ERROR "undeclared" */
+       B bool
+       I int32
+       A [10]P
+       T struct {
+               x, y P
+       }
+       P *T
+       R (*R)
+       F func(A) I
+       Y interface {
+               f(A) I
+       }
+       S [](((P)))
+       M map[I]F
+       C chan<- I
+
+       // blank types must be typechecked
+       _ pi /* ERROR "not a type" */
+       _ struct{}
+       _ struct{ pi /* ERROR "not a type" */ }
+)
+
+
+// declarations of init
+const _, init /* ERROR "cannot declare init" */ , _ = 0, 1, 2
+type init /* ERROR "cannot declare init" */ struct{}
+var _, init /* ERROR "cannot declare init" */ int
+
+func init() {}
+func init /* ERROR "missing function body" */ ()
+
+func _() { const init = 0 }
+func _() { type init int }
+func _() { var init int; _ = init }
+
+// invalid array types
+type (
+       iA0 [... /* ERROR "invalid use of '...'" */ ]byte
+       // The error message below could be better. At the moment
+       // we believe an integer that is too large is not an integer.
+       // But at least we get an error.
+       iA1 [1 /* ERROR "must be integer" */ <<100]int
+       iA2 [- /* ERROR "invalid array length" */ 1]complex128
+       iA3 ["foo" /* ERROR "must be integer" */ ]string
+       iA4 [float64 /* ERROR "must be integer" */ (0)]int
+)
+
+
+type (
+       p1 pi /* ERROR "no field or method foo" */ .foo
+       p2 unsafe.Pointer
+)
+
+
+type (
+       Pi pi /* ERROR "not a type" */
+
+       a /* ERROR "illegal cycle" */ a
+       a /* ERROR "redeclared" */ int
+
+       // where the cycle error appears depends on the
+       // order in which declarations are processed
+       // (which depends on the order in which a map
+       // is iterated through)
+       b /* ERROR "illegal cycle" */ c
+       c d
+       d e
+       e b
+
+       t *t
+
+       U V
+       V *W
+       W U
+
+       P1 *S2
+       P2 P1
+
+       S0 struct {
+       }
+       S1 struct {
+               a, b, c int
+               u, v, a /* ERROR "redeclared" */ float32
+       }
+       S2 struct {
+               S0 // anonymous field
+               S0 /* ERROR "redeclared" */ int
+       }
+       S3 struct {
+               x S2
+       }
+       S4/* ERROR "illegal cycle" */ struct {
+               S4
+       }
+       S5 /* ERROR "illegal cycle" */ struct {
+               S6
+       }
+       S6 struct {
+               field S7
+       }
+       S7 struct {
+               S5
+       }
+
+       L1 []L1
+       L2 []int
+
+       A1 [10.0]int
+       A2 /* ERROR "illegal cycle" */ [10]A2
+       A3 /* ERROR "illegal cycle" */ [10]struct {
+               x A4
+       }
+       A4 [10]A3
+
+       F1 func()
+       F2 func(x, y, z float32)
+       F3 func(x, y, x /* ERROR "redeclared" */ float32)
+       F4 func() (x, y, x /* ERROR "redeclared" */ float32)
+       F5 func(x int) (x /* ERROR "redeclared" */ float32)
+       F6 func(x ...int)
+
+       I1 interface{}
+       I2 interface {
+               m1()
+       }
+       I3 interface {
+               m1()
+               m1 /* ERROR "redeclared" */ ()
+       }
+       I4 interface {
+               m1(x, y, x /* ERROR "redeclared" */ float32)
+               m2() (x, y, x /* ERROR "redeclared" */ float32)
+               m3(x int) (x /* ERROR "redeclared" */ float32)
+       }
+       I5 interface {
+               m1(I5)
+       }
+       I6 interface {
+               S0 /* ERROR "not an interface" */
+       }
+       I7 interface {
+               I1
+               I1
+       }
+       I8 /* ERROR "illegal cycle" */ interface {
+               I8
+       }
+       I9 interface {
+               I10
+       }
+       I10 interface {
+               I11
+       }
+       I11 /* ERROR "illegal cycle" */ interface {
+               I9
+       }
+
+       C1 chan int
+       C2 <-chan int
+       C3 chan<- C3
+       C4 chan C5
+       C5 chan C6
+       C6 chan C4
+
+       M1 map[Last]string
+       M2 map[string]M2
+
+       Last int
+)
+
+// cycles in function/method declarations
+// (test cases for issue 5217 and variants)
+func f1(x f1 /* ERROR "not a type" */ ) {}
+func f2(x *f2 /* ERROR "not a type" */ ) {}
+func f3() (x f3 /* ERROR "not a type" */ ) { return }
+func f4() (x *f4 /* ERROR "not a type" */ ) { return }
+
+func (S0) m1(x S0 /* ERROR "field or method" */ .m1) {}
+func (S0) m2(x *S0 /* ERROR "field or method" */ .m2) {}
+func (S0) m3() (x S0 /* ERROR "field or method" */ .m3) { return }
+func (S0) m4() (x *S0 /* ERROR "field or method" */ .m4) { return }
+
+// interfaces may not have any blank methods
+type BlankI interface {
+       _ /* ERROR "invalid method name" */ ()
+       _ /* ERROR "invalid method name" */ (float32) int
+       m()
+}
+
+// non-interface types may have multiple blank methods
+type BlankT struct{}
+
+func (BlankT) _() {}
+func (BlankT) _(int) {}
+func (BlankT) _() int { return 0 }
+func (BlankT) _(int) int { return 0}
diff --git a/libgo/go/go/types/testdata/decls1.src b/libgo/go/go/types/testdata/decls1.src
new file mode 100644 (file)
index 0000000..cb162f7
--- /dev/null
@@ -0,0 +1,144 @@
+// 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.
+
+// variable declarations
+
+package decls1
+
+import (
+       "math"
+)
+
+// Global variables without initialization
+var (
+       a, b bool
+       c byte
+       d uint8
+       r rune
+       i int
+       j, k, l int
+       x, y float32
+       xx, yy float64
+       u, v complex64
+       uu, vv complex128
+       s, t string
+       array []byte
+       iface interface{}
+
+       blank _ /* ERROR "cannot use _" */
+)
+
+// Global variables with initialization
+var (
+       s1 = i + j
+       s2 = i /* ERROR "mismatched types" */ + x
+       s3 = c + d
+       s4 = s + t
+       s5 = s /* ERROR "invalid operation" */ / t
+       s6 = array[t1]
+       s7 = array[x /* ERROR "integer" */]
+       s8 = &a
+       s10 = &42 /* ERROR "cannot take address" */
+       s11 = &v
+       s12 = -(u + *t11) / *&v
+       s13 = a /* ERROR "shifted operand" */ << d
+       s14 = i << j /* ERROR "must be unsigned" */
+       s18 = math.Pi * 10.0
+       s19 = s1 /* ERROR "cannot call" */ ()
+       s20 = f0 /* ERROR "no value" */ ()
+       s21 = f6(1, s1, i)
+       s22 = f6(1, s1, uu /* ERROR "cannot use .* in argument" */ )
+
+       t1 int = i + j
+       t2 int = i /* ERROR "mismatched types" */ + x
+       t3 int = c /* ERROR "cannot use .* variable declaration" */ + d
+       t4 string = s + t
+       t5 string = s /* ERROR "invalid operation" */ / t
+       t6 byte = array[t1]
+       t7 byte = array[x /* ERROR "must be integer" */]
+       t8 *int = & /* ERROR "cannot use .* variable declaration" */ a
+       t10 *int = &42 /* ERROR "cannot take address" */
+       t11 *complex64 = &v
+       t12 complex64 = -(u + *t11) / *&v
+       t13 int = a /* ERROR "shifted operand" */ << d
+       t14 int = i << j /* ERROR "must be unsigned" */
+       t15 math /* ERROR "not in selector" */
+       t16 math /* ERROR "not declared" */ .xxx
+       t17 math /* ERROR "not a type" */ .Pi
+       t18 float64 = math.Pi * 10.0
+       t19 int = t1 /* ERROR "cannot call" */ ()
+       t20 int = f0 /* ERROR "no value" */ ()
+       t21 int = a /* ERROR "cannot use .* variable declaration" */
+)
+
+// Various more complex expressions
+var (
+       u1 = x /* ERROR "not an interface" */ .(int)
+       u2 = iface.([]int)
+       u3 = iface.(a /* ERROR "not a type" */ )
+       u4, ok = iface.(int)
+       u5, ok2, ok3 = iface /* ERROR "assignment count mismatch" */ .(int)
+)
+
+// Constant expression initializations
+var (
+       v1 = 1 /* ERROR "cannot convert" */ + "foo"
+       v2 = c + 255
+       v3 = c + 256 /* ERROR "overflows" */
+       v4 = r + 2147483647
+       v5 = r + 2147483648 /* ERROR "overflows" */
+       v6 = 42
+       v7 = v6 + 9223372036854775807
+       v8 = v6 + 9223372036854775808 /* ERROR "overflows" */
+       v9 = i + 1 << 10
+       v10 byte = 1024 /* ERROR "overflows" */
+       v11 = xx/yy*yy - xx
+       v12 = true && false
+       v13 = nil /* ERROR "use of untyped nil" */
+)
+
+// Multiple assignment expressions
+var (
+       m1a, m1b = 1, 2
+       m2a, m2b, m2c /* ERROR "missing init expr for m2c" */ = 1, 2
+       m3a, m3b = 1, 2, 3 /* ERROR "extra init expr 3" */
+)
+
+func _() {
+       var (
+               m1a, m1b = 1, 2
+               m2a, m2b, m2c /* ERROR "missing init expr for m2c" */ = 1, 2
+               m3a, m3b = 1, 2, 3 /* ERROR "extra init expr 3" */
+       )
+
+       _, _ = m1a, m1b
+       _, _, _ = m2a, m2b, m2c
+       _, _ = m3a, m3b
+}
+
+// Declaration of parameters and results
+func f0() {}
+func f1(a /* ERROR "not a type" */) {}
+func f2(a, b, c d /* ERROR "not a type" */) {}
+
+func f3() int { return 0 }
+func f4() a /* ERROR "not a type" */ { return 0 }
+func f5() (a, b, c d /* ERROR "not a type" */) { return }
+
+func f6(a, b, c int) complex128 { return 0 }
+
+// Declaration of receivers
+type T struct{}
+
+func (T) m0() {}
+func (*T) m1() {}
+func (x T) m2() {}
+func (x *T) m3() {}
+
+// Initialization functions
+func init() {}
+func /* ERROR "no arguments and no return values" */ init(int) {}
+func /* ERROR "no arguments and no return values" */ init() int { return 0 }
+func /* ERROR "no arguments and no return values" */ init(int) int { return 0 }
+func (T) init(int) int { return 0 }
diff --git a/libgo/go/go/types/testdata/decls2a.src b/libgo/go/go/types/testdata/decls2a.src
new file mode 100644 (file)
index 0000000..bdbecd9
--- /dev/null
@@ -0,0 +1,111 @@
+// 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.
+
+// method declarations
+
+package decls2
+
+import "time"
+import "unsafe"
+
+// T1 declared before its methods.
+type T1 struct{
+       f int
+}
+
+func (T1) m() {}
+func (T1) m /* ERROR "already declared" */ () {}
+func (x *T1) f /* ERROR "field and method" */ () {}
+
+// Conflict between embedded field and method name,
+// with the embedded field being a basic type.
+type T1b struct {
+       int
+}
+
+func (T1b) int /* ERROR "field and method" */ () {}
+
+type T1c struct {
+       time.Time
+}
+
+func (T1c) Time /* ERROR "field and method" */ () int { return 0 }
+
+// Disabled for now: LookupFieldOrMethod will find Pointer even though
+// it's double-declared (it would cost extra in the common case to verify
+// this). But the MethodSet computation will not find it due to the name
+// collision caused by the double-declaration, leading to an internal
+// inconsistency while we are verifying one computation against the other.
+// var _ = T1c{}.Pointer
+
+// T2's method declared before the type.
+func (*T2) f /* ERROR "field and method" */ () {}
+
+type T2 struct {
+       f int
+}
+
+// Methods declared without a declared type.
+func (undeclared /* ERROR "undeclared" */) m() {}
+func (x *undeclared /* ERROR "undeclared" */) m() {}
+
+func (pi /* ERROR "not a type" */) m1() {}
+func (x pi /* ERROR "not a type" */) m2() {}
+func (x *pi /* ERROR "not a type" */ ) m3() {}
+
+// Blank types.
+type _ struct { m int }
+type _ struct { m int }
+
+func (_ /* ERROR "cannot use _" */) m() {}
+func m(_ /* ERROR "cannot use _" */) {}
+
+// Methods with receiver base type declared in another file.
+func (T3) m1() {}
+func (*T3) m2() {}
+func (x T3) m3() {}
+func (x *T3) f /* ERROR "field and method" */ () {}
+
+// Methods of non-struct type.
+type T4 func()
+
+func (self T4) m() func() { return self }
+
+// Methods associated with an interface.
+type T5 interface {
+       m() int
+}
+
+func (T5 /* ERROR "invalid receiver" */ ) m1() {}
+func (T5 /* ERROR "invalid receiver" */ ) m2() {}
+
+// Methods associated with a named pointer type.
+type ptr *int
+func (ptr /* ERROR "invalid receiver" */ ) _() {}
+func (* /* ERROR "invalid receiver" */ ptr) _() {}
+
+// Methods with zero or multiple receivers.
+func ( /* ERROR "missing receiver" */ ) _() {}
+func (T3, * /* ERROR "exactly one receiver" */ T3) _() {}
+func (T3, T3, T3 /* ERROR "exactly one receiver" */ ) _() {}
+func (a, b /* ERROR "exactly one receiver" */ T3) _() {}
+func (a, b, c /* ERROR "exactly one receiver" */ T3) _() {}
+
+// Methods associated with non-local or unnamed types.
+func (int /* ERROR "invalid receiver" */ ) m() {}
+func ([ /* ERROR "invalid receiver" */ ]int) m() {}
+func (time /* ERROR "invalid receiver" */ .Time) m() {}
+func (* /* ERROR "invalid receiver" */ time.Time) m() {}
+func (x /* ERROR "invalid receiver" */ interface{}) m() {}
+
+// Unsafe.Pointer is treated like a pointer when used as receiver type.
+type UP unsafe.Pointer
+func (UP /* ERROR "invalid" */ ) m1() {}
+func (* /* ERROR "invalid" */ UP) m2() {}
+
+// Double declarations across package files
+const c_double = 0
+type t_double int
+var v_double int
+func f_double() {}
diff --git a/libgo/go/go/types/testdata/decls2b.src b/libgo/go/go/types/testdata/decls2b.src
new file mode 100644 (file)
index 0000000..e7bc394
--- /dev/null
@@ -0,0 +1,65 @@
+// 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.
+
+// method declarations
+
+package decls2
+
+import "io"
+
+const pi = 3.1415
+
+func (T1) m /* ERROR "already declared" */ () {}
+func (T2) m(io.Writer) {}
+
+type T3 struct {
+       f *T3
+}
+
+type T6 struct {
+       x int
+}
+
+func (t *T6) m1() int {
+       return t.x
+}
+
+func f() {
+       var t *T6
+       t.m1()
+}
+
+// Double declarations across package files
+const c_double /* ERROR "redeclared" */ = 0
+type t_double  /* ERROR "redeclared" */ int
+var v_double /* ERROR "redeclared" */ int
+func f_double /* ERROR "redeclared" */ () {}
+
+// Blank methods need to be type-checked.
+// Verify by checking that errors are reported.
+func (T /* ERROR "undeclared" */ ) _() {}
+func (T1) _(undeclared /* ERROR "undeclared" */ ) {}
+func (T1) _() int { return "foo" /* ERROR "cannot convert" */ }
+
+// Methods with undeclared receiver type can still be checked.
+// Verify by checking that errors are reported.
+func (Foo /* ERROR "undeclared" */ ) m() {}
+func (Foo /* ERROR "undeclared" */ ) m(undeclared /* ERROR "undeclared" */ ) {}
+func (Foo /* ERROR "undeclared" */ ) m() int { return "foo" /* ERROR "cannot convert" */ }
+
+func (Foo /* ERROR "undeclared" */ ) _() {}
+func (Foo /* ERROR "undeclared" */ ) _(undeclared /* ERROR "undeclared" */ ) {}
+func (Foo /* ERROR "undeclared" */ ) _() int { return "foo" /* ERROR "cannot convert" */ }
+
+// Receiver declarations are regular parameter lists;
+// receiver types may use parentheses, and the list
+// may have a trailing comma.
+type T7 struct {}
+
+func (T7) m1() {}
+func ((T7)) m2() {}
+func ((*T7)) m3() {}
+func (x *(T7),) m4() {}
+func (x (*(T7)),) m5() {}
+func (x ((*((T7)))),) m6() {}
diff --git a/libgo/go/go/types/testdata/decls3.src b/libgo/go/go/types/testdata/decls3.src
new file mode 100644 (file)
index 0000000..80d2bc8
--- /dev/null
@@ -0,0 +1,309 @@
+// 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.
+
+// embedded types
+
+package decls3
+
+import "unsafe"
+import "fmt"
+
+// fields with the same name at the same level cancel each other out
+
+func _() {
+       type (
+               T1 struct { X int }
+               T2 struct { X int }
+               T3 struct { T1; T2 } // X is embedded twice at the same level via T1->X, T2->X
+       )
+
+       var t T3
+       _ = t /* ERROR "ambiguous selector" */ .X
+}
+
+func _() {
+       type (
+               T1 struct { X int }
+               T2 struct { T1 }
+               T3 struct { T1 }
+               T4 struct { T2; T3 } // X is embedded twice at the same level via T2->T1->X, T3->T1->X
+       )
+
+       var t T4
+       _ = t /* ERROR "ambiguous selector" */ .X
+}
+
+func issue4355() {
+       type (
+           T1 struct {X int}
+           T2 struct {T1}
+           T3 struct {T2}
+           T4 struct {T2}
+           T5 struct {T3; T4} // X is embedded twice at the same level via T3->T2->T1->X, T4->T2->T1->X
+       )       
+
+       var t T5
+       _ = t /* ERROR "ambiguous selector" */ .X
+}
+
+func _() {
+       type State int
+       type A struct{ State }
+       type B struct{ fmt.State }
+       type T struct{ A; B }
+
+       var t T
+       _ = t /* ERROR "ambiguous selector" */ .State
+}
+
+// Embedded fields can be predeclared types.
+
+func _() {
+       type T0 struct{
+               int
+               float32
+               f int
+       }
+       var x T0
+       _ = x.int
+       _ = x.float32
+       _ = x.f
+
+       type T1 struct{
+               T0
+       }
+       var y T1
+       _ = y.int
+       _ = y.float32
+       _ = y.f
+}
+
+// Restrictions on embedded field types.
+
+func _() {
+       type I1 interface{}
+       type I2 interface{}
+       type P1 *int
+       type P2 *int
+       type UP unsafe.Pointer
+
+       type T1 struct {
+               I1
+               * /* ERROR "cannot be a pointer to an interface" */ I2
+               * /* ERROR "cannot be a pointer to an interface" */ error
+               P1 /* ERROR "cannot be a pointer" */
+               * /* ERROR "cannot be a pointer" */ P2
+       }
+
+       // unsafe.Pointers are treated like regular pointers when embedded
+       type T2 struct {
+               unsafe /* ERROR "cannot be unsafe.Pointer" */ .Pointer
+               */* ERROR "cannot be unsafe.Pointer" */ unsafe.Pointer
+               UP /* ERROR "cannot be unsafe.Pointer" */
+               * /* ERROR "cannot be unsafe.Pointer" */ UP
+       }
+}
+
+// Named types that are pointers.
+
+type S struct{ x int }
+func (*S) m() {}
+type P *S
+
+func _() {
+       var s *S
+       _ = s.x
+       _ = s.m
+
+       var p P
+       _ = p.x
+       _ = p /* ERROR "no field or method" */ .m
+       _ = P /* ERROR "no field or method" */ .m
+}
+
+// Borrowed from the FieldByName test cases in reflect/all_test.go.
+
+type D1 struct {
+       d int
+}
+type D2 struct {
+       d int
+}
+
+type S0 struct {
+       A, B, C int
+       D1
+       D2
+}
+
+type S1 struct {
+       B int
+       S0
+}
+
+type S2 struct {
+       A int
+       *S1
+}
+
+type S1x struct {
+       S1
+}
+
+type S1y struct {
+       S1
+}
+
+type S3 struct {
+       S1x
+       S2
+       D, E int
+       *S1y
+}
+
+type S4 struct {
+       *S4
+       A int
+}
+
+// The X in S6 and S7 annihilate, but they also block the X in S8.S9.
+type S5 struct {
+       S6
+       S7
+       S8
+}
+
+type S6 struct {
+       X int
+}
+
+type S7 S6
+
+type S8 struct {
+       S9
+}
+
+type S9 struct {
+       X int
+       Y int
+}
+
+// The X in S11.S6 and S12.S6 annihilate, but they also block the X in S13.S8.S9.
+type S10 struct {
+       S11
+       S12
+       S13
+}
+
+type S11 struct {
+       S6
+}
+
+type S12 struct {
+       S6
+}
+
+type S13 struct {
+       S8
+}
+
+func _() {
+       _ = struct /* ERROR "no field or method" */ {}{}.Foo
+       _ = S0{}.A
+       _ = S0 /* ERROR "no field or method" */ {}.D
+       _ = S1{}.A
+       _ = S1{}.B
+       _ = S1{}.S0
+       _ = S1{}.C
+       _ = S2{}.A
+       _ = S2{}.S1
+       _ = S2{}.B
+       _ = S2{}.C
+       _ = S2 /* ERROR "no field or method" */ {}.D
+       _ = S3 /* ERROR "ambiguous selector" */ {}.S1
+       _ = S3{}.A
+       _ = S3 /* ERROR "ambiguous selector" */ {}.B
+       _ = S3{}.D
+       _ = S3{}.E
+       _ = S4{}.A
+       _ = S4 /* ERROR "no field or method" */ {}.B
+       _ = S5 /* ERROR "ambiguous selector" */ {}.X
+       _ = S5{}.Y
+       _ = S10 /* ERROR "ambiguous selector" */ {}.X
+       _ = S10{}.Y
+}
+
+// Borrowed from the FieldByName benchmark in reflect/all_test.go.
+
+type R0 struct {
+       *R1
+       *R2
+       *R3
+       *R4
+}
+
+type R1 struct {
+       *R5
+       *R6
+       *R7
+       *R8
+}
+
+type R2 R1
+type R3 R1
+type R4 R1
+
+type R5 struct {
+       *R9
+       *R10
+       *R11
+       *R12
+}
+
+type R6 R5
+type R7 R5
+type R8 R5
+
+type R9 struct {
+       *R13
+       *R14
+       *R15
+       *R16
+}
+
+type R10 R9
+type R11 R9
+type R12 R9
+
+type R13 struct {
+       *R17
+       *R18
+       *R19
+       *R20
+}
+
+type R14 R13
+type R15 R13
+type R16 R13
+
+type R17 struct {
+       *R21
+       *R22
+       *R23
+       *R24
+}
+
+type R18 R17
+type R19 R17
+type R20 R17
+
+type R21 struct {
+       X int
+}
+
+type R22 R21
+type R23 R21
+type R24 R21
+
+var _ = R0 /* ERROR "ambiguous selector" */ {}.X
\ No newline at end of file
diff --git a/libgo/go/go/types/testdata/errors.src b/libgo/go/go/types/testdata/errors.src
new file mode 100644 (file)
index 0000000..29fcd8f
--- /dev/null
@@ -0,0 +1,55 @@
+// 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 errors
+
+// Testing precise operand formatting in error messages
+// (matching messages are regular expressions, hence the \'s).
+func f(x int, m map[string]int) {
+       // no values
+       _ = f /* ERROR "f\(0, m\) \(no value\) used as value" */ (0, m)
+
+       // built-ins
+       _ = println /* ERROR "println \(built-in\) must be called" */
+
+       // types
+       _ = complex128 /* ERROR "complex128 \(type\) is not an expression" */
+
+       // constants
+       const c1 = 991
+       const c2 float32 = 0.5
+       0 /* ERROR "0 \(untyped int constant\) is not used" */
+       c1 /* ERROR "c1 \(untyped int constant 991\) is not used" */
+       c2 /* ERROR "c2 \(constant 0.5 of type float32\) is not used" */
+       c1 /* ERROR "c1 \+ c2 \(constant 991.5 of type float32\) is not used" */ + c2
+
+       // variables
+       x /* ERROR "x \(variable of type int\) is not used" */
+
+       // values
+       x /* ERROR "x != x \(untyped bool value\) is not used" */ != x
+       x /* ERROR "x \+ x \(value of type int\) is not used" */ + x
+
+       // value, ok's
+       const s = "foo"
+       m /* ERROR "m\[s\] \(map index expression of type int\) is not used" */ [s]
+}
+
+// Valid ERROR comments can have a variety of forms.
+func _() {
+       0 /* ERROR "0 .* is not used" */
+       0 /* ERROR 0 .* is not used */
+       0 // ERROR "0 .* is not used"
+       0 // ERROR 0 .* is not used
+}
+
+// Don't report spurious errors as a consequence of earlier errors.
+// Add more tests as needed.
+func _() {
+       if err := foo /* ERROR undeclared */ (); err != nil /* no error here */ {}
+}
+
+// Use unqualified names for package-local objects.
+type T struct{}
+var _ int = T /* ERROR value of type T */ {} // use T in error message rather then errors.T
diff --git a/libgo/go/go/types/testdata/expr0.src b/libgo/go/go/types/testdata/expr0.src
new file mode 100644 (file)
index 0000000..1aac726
--- /dev/null
@@ -0,0 +1,180 @@
+// 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.
+
+// unary expressions
+
+package expr0 
+
+type mybool bool
+
+var (
+       // bool
+       b0 = true
+       b1 bool = b0
+       b2 = !true
+       b3 = !b1
+       b4 bool = !true
+       b5 bool = !b4
+       b6 = +b0 /* ERROR "not defined" */
+       b7 = -b0 /* ERROR "not defined" */
+       b8 = ^b0 /* ERROR "not defined" */
+       b9 = *b0 /* ERROR "cannot indirect" */
+       b10 = &true /* ERROR "cannot take address" */
+       b11 = &b0
+       b12 = <-b0 /* ERROR "cannot receive" */
+       b13 = & & /* ERROR "cannot take address" */ b0
+
+       // byte
+       _ = byte(0)
+       _ = byte(- /* ERROR "cannot convert" */ 1)
+       _ = - /* ERROR "-byte\(1\) \(constant -1 of type byte\) overflows byte" */ byte(1) // test for issue 11367
+       _ = byte /* ERROR "overflows byte" */ (0) - byte(1)
+
+       // int
+       i0 = 1
+       i1 int = i0
+       i2 = +1
+       i3 = +i0
+       i4 int = +1
+       i5 int = +i4
+       i6 = -1
+       i7 = -i0
+       i8 int = -1
+       i9 int = -i4
+       i10 = !i0 /* ERROR "not defined" */
+       i11 = ^1
+       i12 = ^i0
+       i13 int = ^1
+       i14 int = ^i4
+       i15 = *i0 /* ERROR "cannot indirect" */
+       i16 = &i0
+       i17 = *i16
+       i18 = <-i16 /* ERROR "cannot receive" */
+
+       // uint
+       u0 = uint(1)
+       u1 uint = u0
+       u2 = +1
+       u3 = +u0
+       u4 uint = +1
+       u5 uint = +u4
+       u6 = -1
+       u7 = -u0
+       u8 uint = - /* ERROR "overflows" */ 1
+       u9 uint = -u4
+       u10 = !u0 /* ERROR "not defined" */
+       u11 = ^1
+       u12 = ^i0
+       u13 uint = ^ /* ERROR "overflows" */ 1
+       u14 uint = ^u4
+       u15 = *u0 /* ERROR "cannot indirect" */
+       u16 = &u0
+       u17 = *u16
+       u18 = <-u16 /* ERROR "cannot receive" */
+       u19 = ^uint(0)
+
+       // float64
+       f0 = float64(1)
+       f1 float64 = f0
+       f2 = +1
+       f3 = +f0
+       f4 float64 = +1
+       f5 float64 = +f4
+       f6 = -1
+       f7 = -f0
+       f8 float64 = -1
+       f9 float64 = -f4
+       f10 = !f0 /* ERROR "not defined" */
+       f11 = ^1
+       f12 = ^i0
+       f13 float64 = ^1
+       f14 float64 = ^f4 /* ERROR "not defined" */
+       f15 = *f0 /* ERROR "cannot indirect" */
+       f16 = &f0
+       f17 = *u16
+       f18 = <-u16 /* ERROR "cannot receive" */
+
+       // complex128
+       c0 = complex128(1)
+       c1 complex128 = c0
+       c2 = +1
+       c3 = +c0
+       c4 complex128 = +1
+       c5 complex128 = +c4
+       c6 = -1
+       c7 = -c0
+       c8 complex128 = -1
+       c9 complex128 = -c4
+       c10 = !c0 /* ERROR "not defined" */
+       c11 = ^1
+       c12 = ^i0
+       c13 complex128 = ^1
+       c14 complex128 = ^c4 /* ERROR "not defined" */
+       c15 = *c0 /* ERROR "cannot indirect" */
+       c16 = &c0
+       c17 = *u16
+       c18 = <-u16 /* ERROR "cannot receive" */
+
+       // string
+       s0 = "foo"
+       s1 = +"foo" /* ERROR "not defined" */
+       s2 = -s0 /* ERROR "not defined" */
+       s3 = !s0 /* ERROR "not defined" */
+       s4 = ^s0 /* ERROR "not defined" */
+       s5 = *s4
+       s6 = &s4
+       s7 = *s6
+       s8 = <-s7
+
+       // channel
+       ch chan int
+       rc <-chan float64
+       sc chan <- string
+       ch0 = +ch /* ERROR "not defined" */
+       ch1 = -ch /* ERROR "not defined" */
+       ch2 = !ch /* ERROR "not defined" */
+       ch3 = ^ch /* ERROR "not defined" */
+       ch4 = *ch /* ERROR "cannot indirect" */
+       ch5 = &ch
+       ch6 = *ch5
+       ch7 = <-ch
+       ch8 = <-rc
+       ch9 = <-sc /* ERROR "cannot receive" */
+       ch10, ok = <-ch
+       // ok is of type bool
+       ch11, myok = <-ch
+       _ mybool = myok /* ERROR "cannot use .* in variable declaration" */
+)
+
+// address of composite literals
+type T struct{x, y int}
+
+func f() T { return T{} }
+
+var (
+       _ = &T{1, 2}
+       _ = &[...]int{}
+       _ = &[]int{}
+       _ = &[]int{}
+       _ = &map[string]T{}
+       _ = &(T{1, 2})
+       _ = &((((T{1, 2}))))
+       _ = &f /* ERROR "cannot take address" */ ()
+)
+
+// recursive pointer types
+type P *P
+
+var (
+       p1 P = new(P)
+       p2 P = *p1
+       p3 P = &p2
+)
+
+func g() (a, b int) { return }
+
+func _() {
+       _ = -g /* ERROR 2-valued g */ ()
+       _ = <-g /* ERROR 2-valued g */ ()
+}
diff --git a/libgo/go/go/types/testdata/expr1.src b/libgo/go/go/types/testdata/expr1.src
new file mode 100644 (file)
index 0000000..eaaf610
--- /dev/null
@@ -0,0 +1,127 @@
+// 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.
+
+// binary expressions
+
+package expr1
+
+type mybool bool
+
+func _(x, y bool, z mybool) {
+       x = x || y
+       x = x || true
+       x = x || false
+       x = x && y
+       x = x && true
+       x = x && false
+
+       z = z /* ERROR mismatched types */ || y
+       z = z || true
+       z = z || false
+       z = z /* ERROR mismatched types */ && y
+       z = z && true
+       z = z && false
+}
+
+type myint int
+
+func _(x, y int, z myint) {
+       x = x + 1
+       x = x + 1.0
+       x = x + 1.1 // ERROR truncated to int
+       x = x + y
+       x = x - y
+       x = x * y
+       x = x / y
+       x = x % y
+       x = x << y // ERROR must be unsigned integer
+       x = x >> y // ERROR must be unsigned integer
+
+       z = z + 1
+       z = z + 1.0
+       z = z + 1.1 // ERROR truncated to int
+       z = z /* ERROR mismatched types */ + y
+       z = z /* ERROR mismatched types */ - y
+       z = z /* ERROR mismatched types */ * y
+       z = z /* ERROR mismatched types */ / y
+       z = z /* ERROR mismatched types */ % y
+       z = z << y // ERROR must be unsigned integer
+       z = z >> y // ERROR must be unsigned integer
+}
+
+type myuint uint
+
+func _(x, y uint, z myuint) {
+       x = x + 1
+       x = x + - /* ERROR overflows uint */ 1
+       x = x + 1.0
+       x = x + 1.1 // ERROR truncated to uint
+       x = x + y
+       x = x - y
+       x = x * y
+       x = x / y
+       x = x % y
+       x = x << y
+       x = x >> y
+
+       z = z + 1
+       z = x + - /* ERROR overflows uint */ 1
+       z = z + 1.0
+       z = z + 1.1 // ERROR truncated to uint
+       z = z /* ERROR mismatched types */ + y
+       z = z /* ERROR mismatched types */ - y
+       z = z /* ERROR mismatched types */ * y
+       z = z /* ERROR mismatched types */ / y
+       z = z /* ERROR mismatched types */ % y
+       z = z << y
+       z = z >> y
+}
+
+type myfloat64 float64
+
+func _(x, y float64, z myfloat64) {
+       x = x + 1
+       x = x + -1
+       x = x + 1.0
+       x = x + 1.1
+       x = x + y
+       x = x - y
+       x = x * y
+       x = x / y
+       x = x /* ERROR not defined */ % y
+       x = x /* ERROR operand x .* must be integer */ << y
+       x = x /* ERROR operand x .* must be integer */ >> y
+
+       z = z + 1
+       z = z + -1
+       z = z + 1.0
+       z = z + 1.1
+       z = z /* ERROR mismatched types */ + y
+       z = z /* ERROR mismatched types */ - y
+       z = z /* ERROR mismatched types */ * y
+       z = z /* ERROR mismatched types */ / y
+       z = z /* ERROR mismatched types */ % y
+       z = z /* ERROR operand z .* must be integer */ << y
+       z = z /* ERROR operand z .* must be integer */ >> y
+}
+
+type mystring string
+
+func _(x, y string, z mystring) {
+       x = x + "foo"
+       x = x /* ERROR not defined */ - "foo"
+       x = x + 1 // ERROR cannot convert
+       x = x + y
+       x = x /* ERROR not defined */ - y
+       x = x * 10 // ERROR cannot convert
+}
+
+func f() (a, b int) { return }
+
+func _(x int) {
+       _ = f /* ERROR 2-valued f */ () + 1
+       _ = x + f /* ERROR 2-valued f */ ()
+       _ = f /* ERROR 2-valued f */ () + f
+       _ = f /* ERROR 2-valued f */ () + f /* ERROR 2-valued f */ ()
+}
diff --git a/libgo/go/go/types/testdata/expr2.src b/libgo/go/go/types/testdata/expr2.src
new file mode 100644 (file)
index 0000000..31dc5f0
--- /dev/null
@@ -0,0 +1,247 @@
+// 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.
+
+// comparisons
+
+package expr2
+
+func _bool() {
+       const t = true == true
+       const f = true == false
+       _ = t /* ERROR "cannot compare" */ < f
+       _ = 0 /* ERROR "cannot convert" */ == t
+       var b bool
+       var x, y float32
+       b = x < y
+       _ = b
+       _ = struct{b bool}{x < y}
+}
+
+// corner cases
+var (
+       v0 = nil /* ERROR "cannot compare" */ == nil
+)
+
+func arrays() {
+       // basics
+       var a, b [10]int
+       _ = a == b
+       _ = a != b
+       _ = a /* ERROR < not defined */ < b
+       _ = a == nil /* ERROR cannot convert */
+
+       type C [10]int
+       var c C
+       _ = a == c
+
+       type D [10]int
+       var d D
+       _ = c /* ERROR mismatched types */ == d
+
+       var e [10]func() int
+       _ = e /* ERROR == not defined */ == e
+}
+
+func structs() {
+       // basics
+       var s, t struct {
+               x int
+               a [10]float32
+               _ bool
+       }
+       _ = s == t
+       _ = s != t
+       _ = s /* ERROR < not defined */ < t
+       _ = s == nil /* ERROR cannot convert */
+
+       type S struct {
+               x int
+               a [10]float32
+               _ bool
+       }
+       type T struct {
+               x int
+               a [10]float32
+               _ bool
+       }
+       var ss S
+       var tt T
+       _ = s == ss
+       _ = ss /* ERROR mismatched types */ == tt
+
+       var u struct {
+               x int
+               a [10]map[string]int
+       }
+       _ = u /* ERROR cannot compare */ == u
+}
+
+func pointers() {
+       // nil
+       _ = nil /* ERROR == not defined */ == nil
+       _ = nil /* ERROR != not defined */ != nil
+       _ = nil /* ERROR < not defined */ < nil
+       _ = nil /* ERROR <= not defined */ <= nil
+       _ = nil /* ERROR > not defined */ > nil
+       _ = nil /* ERROR >= not defined */ >= nil
+
+       // basics
+       var p, q *int
+       _ = p == q
+       _ = p != q
+
+       _ = p == nil
+       _ = p != nil
+       _ = nil == q
+       _ = nil != q
+
+       _ = p /* ERROR < not defined */ < q
+       _ = p /* ERROR <= not defined */ <= q
+       _ = p /* ERROR > not defined */ > q
+       _ = p /* ERROR >= not defined */ >= q
+
+       // various element types
+       type (
+               S1 struct{}
+               S2 struct{}
+               P1 *S1
+               P2 *S2
+       )
+       var (
+               ps1 *S1
+               ps2 *S2
+               p1 P1
+               p2 P2
+       )
+       _ = ps1 == ps1
+       _ = ps1 /* ERROR mismatched types */ == ps2
+       _ = ps2 /* ERROR mismatched types */ == ps1
+
+       _ = p1 == p1
+       _ = p1 /* ERROR mismatched types */ == p2
+
+       _ = p1 == ps1
+}
+
+func channels() {
+       // basics
+       var c, d chan int
+       _ = c == d
+       _ = c != d
+       _ = c == nil
+       _ = c /* ERROR < not defined */ < d
+
+       // various element types (named types)
+       type (
+               C1 chan int
+               C1r <-chan int
+               C1s chan<- int
+               C2 chan float32
+       )
+       var (
+               c1 C1
+               c1r C1r
+               c1s C1s
+               c1a chan int
+               c2 C2
+       )
+       _ = c1 == c1
+       _ = c1 /* ERROR mismatched types */ == c1r
+       _ = c1 /* ERROR mismatched types */ == c1s
+       _ = c1r /* ERROR mismatched types */ == c1s
+       _ = c1 == c1a
+       _ = c1a == c1
+       _ = c1 /* ERROR mismatched types */ == c2
+       _ = c1a /* ERROR mismatched types */ == c2
+
+       // various element types (unnamed types)
+       var (
+               d1 chan int
+               d1r <-chan int
+               d1s chan<- int
+               d1a chan<- int
+               d2 chan float32
+       )
+       _ = d1 == d1
+       _ = d1 == d1r
+       _ = d1 == d1s
+       _ = d1r /* ERROR mismatched types */ == d1s
+       _ = d1 == d1a
+       _ = d1a == d1
+       _ = d1 /* ERROR mismatched types */ == d2
+       _ = d1a /* ERROR mismatched types */ == d2
+}
+
+// for interfaces test
+type S1 struct{}
+type S11 struct{}
+type S2 struct{}
+func (*S1) m() int
+func (*S11) m() int
+func (*S11) n()
+func (*S2) m() float32
+
+func interfaces() {
+       // basics
+       var i, j interface{ m() int }
+       _ = i == j
+       _ = i != j
+       _ = i == nil
+       _ = i /* ERROR < not defined */ < j
+
+       // various interfaces
+       var ii interface { m() int; n() }
+       var k interface { m() float32 }
+       _ = i == ii
+       _ = i /* ERROR mismatched types */ == k
+
+       // interfaces vs values
+       var s1 S1
+       var s11 S11
+       var s2 S2
+
+       _ = i == 0 /* ERROR cannot convert */
+       _ = i /* ERROR mismatched types */ == s1
+       _ = i == &s1
+       _ = i == &s11
+
+       _ = i /* ERROR mismatched types */ == s2
+       _ = i /* ERROR mismatched types */ == &s2
+}
+
+func slices() {
+       // basics
+       var s []int
+       _ = s == nil
+       _ = s != nil
+       _ = s /* ERROR < not defined */ < nil
+
+       // slices are not otherwise comparable
+       _ = s /* ERROR == not defined */ == s
+       _ = s /* ERROR < not defined */ < s
+}
+
+func maps() {
+       // basics
+       var m map[string]int
+       _ = m == nil
+       _ = m != nil
+       _ = m /* ERROR < not defined */ < nil
+
+       // maps are not otherwise comparable
+       _ = m /* ERROR == not defined */ == m
+       _ = m /* ERROR < not defined */ < m
+}
+
+func funcs() {
+       // basics
+       var f func(int) float32
+       _ = f == nil
+       _ = f != nil
+       _ = f /* ERROR < not defined */ < nil
+
+       // funcs are not otherwise comparable
+       _ = f /* ERROR == not defined */ == f
+       _ = f /* ERROR < not defined */ < f
+}
diff --git a/libgo/go/go/types/testdata/expr3.src b/libgo/go/go/types/testdata/expr3.src
new file mode 100644 (file)
index 0000000..ab1a9f6
--- /dev/null
@@ -0,0 +1,558 @@
+// 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.
+
+package expr3
+
+import "time"
+
+func indexes() {
+       _ = 1 /* ERROR "cannot index" */ [0]
+       _ = indexes /* ERROR "cannot index" */ [0]
+       _ = ( /* ERROR "cannot slice" */ 12 + 3)[1:2]
+
+       var a [10]int
+       _ = a[true /* ERROR "cannot convert" */ ]
+       _ = a["foo" /* ERROR "cannot convert" */ ]
+       _ = a[1.1 /* ERROR "truncated" */ ]
+       _ = a[1.0]
+       _ = a[- /* ERROR "negative" */ 1]
+       _ = a[- /* ERROR "negative" */ 1 :]
+       _ = a[: - /* ERROR "negative" */ 1]
+       _ = a[: /* ERROR "2nd index required" */ : /* ERROR "3rd index required" */ ]
+       _ = a[0: /* ERROR "2nd index required" */ : /* ERROR "3rd index required" */ ]
+       _ = a[0: /* ERROR "2nd index required" */ :10]
+       _ = a[:10:10]
+
+       var a0 int
+       a0 = a[0]
+       _ = a0
+       var a1 int32
+       a1 = a /* ERROR "cannot use .* in assignment" */ [1]
+       _ = a1
+
+       _ = a[9]
+       _ = a[10 /* ERROR "index .* out of bounds" */ ]
+       _ = a[1 /* ERROR "overflows" */ <<100]
+       _ = a[10:]
+       _ = a[:10]
+       _ = a[10:10]
+       _ = a[11 /* ERROR "index .* out of bounds" */ :]
+       _ = a[: 11 /* ERROR "index .* out of bounds" */ ]
+       _ = a[: 1 /* ERROR "overflows" */ <<100]
+       _ = a[:10:10]
+       _ = a[:11 /* ERROR "index .* out of bounds" */ :10]
+       _ = a[:10:11 /* ERROR "index .* out of bounds" */ ]
+       _ = a[10:0:10] /* ERROR "invalid slice indices" */
+       _ = a[0:10:0] /* ERROR "invalid slice indices" */
+       _ = a[10:0:0] /* ERROR "invalid slice indices" */
+       _ = &a /* ERROR "cannot take address" */ [:10]
+
+       pa := &a
+       _ = pa[9]
+       _ = pa[10 /* ERROR "index .* out of bounds" */ ]
+       _ = pa[1 /* ERROR "overflows" */ <<100]
+       _ = pa[10:]
+       _ = pa[:10]
+       _ = pa[10:10]
+       _ = pa[11 /* ERROR "index .* out of bounds" */ :]
+       _ = pa[: 11 /* ERROR "index .* out of bounds" */ ]
+       _ = pa[: 1 /* ERROR "overflows" */ <<100]
+       _ = pa[:10:10]
+       _ = pa[:11 /* ERROR "index .* out of bounds" */ :10]
+       _ = pa[:10:11 /* ERROR "index .* out of bounds" */ ]
+       _ = pa[10:0:10] /* ERROR "invalid slice indices" */
+       _ = pa[0:10:0] /* ERROR "invalid slice indices" */
+       _ = pa[10:0:0] /* ERROR "invalid slice indices" */
+       _ = &pa /* ERROR "cannot take address" */ [:10]
+
+       var b [0]int
+       _ = b[0 /* ERROR "index .* out of bounds" */ ]
+       _ = b[:]
+       _ = b[0:]
+       _ = b[:0]
+       _ = b[0:0]
+       _ = b[0:0:0]
+       _ = b[1 /* ERROR "index .* out of bounds" */ :0:0]
+
+       var s []int
+       _ = s[- /* ERROR "negative" */ 1]
+       _ = s[- /* ERROR "negative" */ 1 :]
+       _ = s[: - /* ERROR "negative" */ 1]
+       _ = s[0]
+       _ = s[1:2]
+       _ = s[2:1] /* ERROR "invalid slice indices" */
+       _ = s[2:]
+       _ = s[: 1 /* ERROR "overflows" */ <<100]
+       _ = s[1 /* ERROR "overflows" */ <<100 :]
+       _ = s[1 /* ERROR "overflows" */ <<100 : 1 /* ERROR "overflows" */ <<100]
+       _ = s[: /* ERROR "2nd index required" */ :  /* ERROR "3rd index required" */ ]
+       _ = s[:10:10]
+       _ = s[10:0:10] /* ERROR "invalid slice indices" */
+       _ = s[0:10:0] /* ERROR "invalid slice indices" */
+       _ = s[10:0:0] /* ERROR "invalid slice indices" */
+       _ = &s /* ERROR "cannot take address" */ [:10]
+
+       var m map[string]int
+       _ = m[0 /* ERROR "cannot convert" */ ]
+       _ = m /* ERROR "cannot slice" */ ["foo" : "bar"]
+       _ = m["foo"]
+       // ok is of type bool
+       type mybool bool
+       var ok mybool
+       _, ok = m["bar"]
+       _ = ok
+
+       var t string
+       _ = t[- /* ERROR "negative" */ 1]
+       _ = t[- /* ERROR "negative" */ 1 :]
+       _ = t[: - /* ERROR "negative" */ 1]
+       _ = t /* ERROR "3-index slice of string" */ [1:2:3]
+       _ = "foo" /* ERROR "3-index slice of string" */ [1:2:3]
+       var t0 byte
+       t0 = t[0]
+       _ = t0
+       var t1 rune
+       t1 = t /* ERROR "cannot use .* in assignment" */ [2]
+       _ = t1
+       _ = ("foo" + "bar")[5]
+       _ = ("foo" + "bar")[6 /* ERROR "index .* out of bounds" */ ]
+
+       const c = "foo"
+       _ = c[- /* ERROR "negative" */ 1]
+       _ = c[- /* ERROR "negative" */ 1 :]
+       _ = c[: - /* ERROR "negative" */ 1]
+       var c0 byte
+       c0 = c[0]
+       _ = c0
+       var c2 float32
+       c2 = c /* ERROR "cannot use .* in assignment" */ [2]
+       _ = c[3 /* ERROR "index .* out of bounds" */ ]
+       _ = ""[0 /* ERROR "index .* out of bounds" */ ]
+       _ = c2
+
+       _ = s[1<<30] // no compile-time error here
+
+       // issue 4913
+       type mystring string
+       var ss string
+       var ms mystring
+       var i, j int
+       ss = "foo"[1:2]
+       ss = "foo"[i:j]
+       ms = "foo" /* ERROR "cannot use .* in assignment" */ [1:2]
+       ms = "foo" /* ERROR "cannot use .* in assignment" */ [i:j]
+       _, _ = ss, ms
+}
+
+type T struct {
+       x int
+       y func()
+}
+
+func (*T) m() {}
+
+func method_expressions() {
+       _ = T /* ERROR "no field or method" */ .a
+       _ = T /* ERROR "has no method" */ .x
+       _ = T /* ERROR "not in method set" */ .m
+       _ = (*T).m
+
+       var f func(*T) = T /* ERROR "not in method set" */ .m
+       var g func(*T) = (*T).m
+       _, _ = f, g
+
+       _ = T /* ERROR "has no method" */ .y
+       _ = ( /* ERROR "has no method" */ *T).y
+}
+
+func struct_literals() {
+       type T0 struct {
+               a, b, c int
+       }
+
+       type T1 struct {
+               T0
+               a, b int
+               u float64
+               s string
+       }
+
+       // keyed elements
+       _ = T1{}
+       _ = T1{a: 0, 1 /* ERROR "mixture of .* elements" */ }
+       _ = T1{aa /* ERROR "unknown field" */ : 0}
+       _ = T1{1 /* ERROR "invalid field name" */ : 0}
+       _ = T1{a: 0, s: "foo", u: 0, a /* ERROR "duplicate field" */: 10}
+       _ = T1{a: "foo" /* ERROR "cannot convert" */ }
+       _ = T1{c /* ERROR "unknown field" */ : 0}
+       _ = T1{T0: { /* ERROR "missing type" */ }} // struct literal element type may not be elided
+       _ = T1{T0: T0{}}
+       _ = T1{T0 /* ERROR "invalid field name" */ .a: 0}
+
+       // unkeyed elements
+       _ = T0{1, 2, 3}
+       _ = T0{1, b /* ERROR "mixture" */ : 2, 3}
+       _ = T0{1, 2} /* ERROR "too few values" */
+       _ = T0{1, 2, 3, 4  /* ERROR "too many values" */ }
+       _ = T0{1, "foo" /* ERROR "cannot convert" */, 3.4  /* ERROR "truncated" */}
+
+       // invalid type
+       type P *struct{
+               x int
+       }
+       _ = P /* ERROR "invalid composite literal type" */ {}
+
+       // unexported fields
+       _ = time.Time{}
+       _ = time.Time{sec /* ERROR "unknown field" */ : 0}
+       _ = time.Time{
+               0 /* ERROR implicit assignment to unexported field sec in time.Time literal */,
+               0 /* ERROR implicit assignment */ ,
+               nil /* ERROR implicit assignment */ ,
+       }
+}
+
+func array_literals() {
+       type A0 [0]int
+       _ = A0{}
+       _ = A0{0 /* ERROR "index .* out of bounds" */}
+       _ = A0{0 /* ERROR "index .* out of bounds" */ : 0}
+
+       type A1 [10]int
+       _ = A1{}
+       _ = A1{0, 1, 2}
+       _ = A1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
+       _ = A1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 /* ERROR "index .* out of bounds" */ }
+       _ = A1{- /* ERROR "negative" */ 1: 0}
+       _ = A1{8: 8, 9}
+       _ = A1{8: 8, 9, 10 /* ERROR "index .* out of bounds" */ }
+       _ = A1{0, 1, 2, 0 /* ERROR "duplicate index" */ : 0, 3: 3, 4}
+       _ = A1{5: 5, 6, 7, 3: 3, 4}
+       _ = A1{5: 5, 6, 7, 3: 3, 4, 5 /* ERROR "duplicate index" */ }
+       _ = A1{10 /* ERROR "index .* out of bounds" */ : 10, 10 /* ERROR "index .* out of bounds" */ : 10}
+       _ = A1{5: 5, 6, 7, 3: 3, 1 /* ERROR "overflows" */ <<100: 4, 5 /* ERROR "duplicate index" */ }
+       _ = A1{5: 5, 6, 7, 4: 4, 1 /* ERROR "overflows" */ <<100: 4}
+       _ = A1{2.0}
+       _ = A1{2.1 /* ERROR "truncated" */ }
+       _ = A1{"foo" /* ERROR "cannot convert" */ }
+
+       // indices must be integer constants
+       i := 1
+       const f = 2.1
+       const s = "foo"
+       _ = A1{i /* ERROR "index i must be integer constant" */ : 0}
+       _ = A1{f /* ERROR "truncated" */ : 0}
+       _ = A1{s /* ERROR "cannot convert" */ : 0}
+
+       a0 := [...]int{}
+       assert(len(a0) == 0)
+
+       a1 := [...]int{0, 1, 2}
+       assert(len(a1) == 3)
+       var a13 [3]int
+       var a14 [4]int
+       a13 = a1
+       a14 = a1 /* ERROR "cannot use .* in assignment" */
+       _, _ = a13, a14
+
+       a2 := [...]int{- /* ERROR "negative" */ 1: 0}
+       _ = a2
+
+       a3 := [...]int{0, 1, 2, 0 /* ERROR "duplicate index" */ : 0, 3: 3, 4}
+       assert(len(a3) == 5) // somewhat arbitrary
+
+       a4 := [...]complex128{0, 1, 2, 1<<10-2: -1i, 1i, 400: 10, 12, 14}
+       assert(len(a4) == 1024)
+
+       // composite literal element types may be elided
+       type T []int
+       _ = [10]T{T{}, {}, 5: T{1, 2, 3}, 7: {1, 2, 3}}
+       a6 := [...]T{T{}, {}, 5: T{1, 2, 3}, 7: {1, 2, 3}}
+       assert(len(a6) == 8)
+
+       // recursively so
+       _ = [10][10]T{{}, [10]T{{}}, {{1, 2, 3}}}
+
+       // from the spec
+       type Point struct { x, y float32 }
+       _ = [...]Point{Point{1.5, -3.5}, Point{0, 0}}
+       _ = [...]Point{{1.5, -3.5}, {0, 0}}
+       _ = [][]int{[]int{1, 2, 3}, []int{4, 5}}
+       _ = [][]int{{1, 2, 3}, {4, 5}}
+       _ = [...]*Point{&Point{1.5, -3.5}, &Point{0, 0}}
+       _ = [...]*Point{{1.5, -3.5}, {0, 0}}
+}
+
+func slice_literals() {
+       type S0 []int
+       _ = S0{}
+       _ = S0{0, 1, 2}
+       _ = S0{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
+       _ = S0{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
+       _ = S0{- /* ERROR "negative" */ 1: 0}
+       _ = S0{8: 8, 9}
+       _ = S0{8: 8, 9, 10}
+       _ = S0{0, 1, 2, 0 /* ERROR "duplicate index" */ : 0, 3: 3, 4}
+       _ = S0{5: 5, 6, 7, 3: 3, 4}
+       _ = S0{5: 5, 6, 7, 3: 3, 4, 5 /* ERROR "duplicate index" */ }
+       _ = S0{10: 10, 10 /* ERROR "duplicate index" */ : 10}
+       _ = S0{5: 5, 6, 7, 3: 3, 1 /* ERROR "overflows" */ <<100: 4, 5 /* ERROR "duplicate index" */ }
+       _ = S0{5: 5, 6, 7, 4: 4, 1 /* ERROR "overflows" */ <<100: 4}
+       _ = S0{2.0}
+       _ = S0{2.1 /* ERROR "truncated" */ }
+       _ = S0{"foo" /* ERROR "cannot convert" */ }
+
+       // indices must be resolved correctly
+       const index1 = 1
+       _ = S0{index1: 1}
+       _ = S0{index2: 2}
+       _ = S0{index3 /* ERROR "undeclared name" */ : 3}
+
+       // indices must be integer constants
+       i := 1
+       const f = 2.1
+       const s = "foo"
+       _ = S0{i /* ERROR "index i must be integer constant" */ : 0}
+       _ = S0{f /* ERROR "truncated" */ : 0}
+       _ = S0{s /* ERROR "cannot convert" */ : 0}
+
+       // composite literal element types may be elided
+       type T []int
+       _ = []T{T{}, {}, 5: T{1, 2, 3}, 7: {1, 2, 3}}
+       _ = [][]int{{1, 2, 3}, {4, 5}}
+
+       // recursively so
+       _ = [][]T{{}, []T{{}}, {{1, 2, 3}}}
+
+       // issue 17954
+       type T0 *struct { s string }
+       _ = []T0{{}}
+       _ = []T0{{"foo"}}
+
+       type T1 *struct{ int }
+       _ = []T1{}
+       _ = []T1{{0}, {1}, {2}}
+
+       type T2 T1
+       _ = []T2{}
+       _ = []T2{{0}, {1}, {2}}
+
+       _ = map[T0]T2{}
+       _ = map[T0]T2{{}: {}}
+}
+
+const index2 int = 2
+
+type N int
+func (N) f() {}
+
+func map_literals() {
+       type M0 map[string]int
+       type M1 map[bool]int
+       type M2 map[*int]int
+
+       _ = M0{}
+       _ = M0{1 /* ERROR "missing key" */ }
+       _ = M0{1 /* ERROR "cannot convert" */ : 2}
+       _ = M0{"foo": "bar" /* ERROR "cannot convert" */ }
+       _ = M0{"foo": 1, "bar": 2, "foo" /* ERROR "duplicate key" */ : 3 }
+
+       _ = map[interface{}]int{2: 1, 2 /* ERROR "duplicate key" */ : 1}
+       _ = map[interface{}]int{int(2): 1, int16(2): 1}
+       _ = map[interface{}]int{int16(2): 1, int16 /* ERROR "duplicate key" */ (2): 1}
+
+       type S string
+
+       _ = map[interface{}]int{"a": 1, "a" /* ERROR "duplicate key" */ : 1}
+       _ = map[interface{}]int{"a": 1, S("a"): 1}
+       _ = map[interface{}]int{S("a"): 1, S /* ERROR "duplicate key" */ ("a"): 1}
+
+       type I interface {
+               f()
+       }
+
+       _ = map[I]int{N(0): 1, N(2): 1}
+       _ = map[I]int{N(2): 1, N /* ERROR "duplicate key" */ (2): 1}
+
+       // map keys must be resolved correctly
+       key1 := "foo"
+       _ = M0{key1: 1}
+       _ = M0{key2: 2}
+       _ = M0{key3 /* ERROR "undeclared name" */ : 2}
+
+       var value int
+       _ = M1{true: 1, false: 0}
+       _ = M2{nil: 0, &value: 1}
+
+       // composite literal element types may be elided
+       type T [2]int
+       _ = map[int]T{0: T{3, 4}, 1: {5, 6}}
+
+       // recursively so
+       _ = map[int][]T{0: {}, 1: {{}, T{1, 2}}}
+
+       // composite literal key types may be elided
+       _ = map[T]int{T{3, 4}: 0, {5, 6}: 1}
+
+       // recursively so
+       _ = map[[2]T]int{{}: 0, {{}}: 1, [2]T{{}}: 2, {T{1, 2}}: 3}
+
+       // composite literal element and key types may be elided
+       _ = map[T]T{{}: {}, {1, 2}: T{3, 4}, T{4, 5}: {}}
+       _ = map[T]M0{{} : {}, T{1, 2}: M0{"foo": 0}, {1, 3}: {"foo": 1}}
+
+       // recursively so
+       _ = map[[2]T][]T{{}: {}, {{}}: {{}, T{1, 2}}, [2]T{{}}: nil, {T{1, 2}}: {{}, {}}}
+
+       // from the spec
+       type Point struct { x, y float32 }
+       _ = map[string]Point{"orig": {0, 0}}
+       _ = map[*Point]string{{0, 0}: "orig"}
+
+       // issue 17954
+       type T0 *struct{ s string }
+       type T1 *struct{ int }
+       type T2 T1
+
+       _ = map[T0]T2{}
+       _ = map[T0]T2{{}: {}}
+}
+
+var key2 string = "bar"
+
+type I interface {
+       m()
+}
+
+type I2 interface {
+       m(int)
+}
+
+type T1 struct{}
+type T2 struct{}
+
+func (T2) m(int) {}
+
+type mybool bool
+
+func type_asserts() {
+       var x int
+       _ = x /* ERROR "not an interface" */ .(int)
+
+       var e interface{}
+       var ok bool
+       x, ok = e.(int)
+       _ = ok
+
+       // ok value is of type bool
+       var myok mybool
+       _, myok = e.(int)
+       _ = myok
+
+       var t I
+       _ = t /* ERROR "use of .* outside type switch" */ .(type)
+       _ = t /* ERROR "missing method m" */ .(T)
+       _ = t.(*T)
+       _ = t /* ERROR "missing method m" */ .(T1)
+       _ = t /* ERROR "wrong type for method m" */ .(T2)
+       _ = t /* STRICT "wrong type for method m" */ .(I2) // only an error in strict mode (issue 8561)
+
+       // e doesn't statically have an m, but may have one dynamically.
+       _ = e.(I2)
+}
+
+func f0() {}
+func f1(x int) {}
+func f2(u float32, s string) {}
+func fs(s []byte) {}
+func fv(x ...int) {}
+func fi(x ... interface{}) {}
+func (T) fm(x ...int)
+
+func g0() {}
+func g1() int { return 0}
+func g2() (u float32, s string) { return }
+func gs() []byte { return nil }
+
+func _calls() {
+       var x int
+       var y float32
+       var s []int
+
+       f0()
+       _ = f0 /* ERROR "used as value" */ ()
+       f0(g0 /* ERROR "too many arguments" */ )
+
+       f1(0)
+       f1(x)
+       f1(10.0)
+       f1() /* ERROR "too few arguments" */
+       f1(x, y /* ERROR "too many arguments" */ )
+       f1(s /* ERROR "cannot use .* in argument" */ )
+       f1(x ... /* ERROR "cannot use ..." */ )
+       f1(g0 /* ERROR "used as value" */ ())
+       f1(g1())
+       // f1(g2()) // TODO(gri) missing position in error message
+
+       f2() /* ERROR "too few arguments" */
+       f2(3.14) /* ERROR "too few arguments" */
+       f2(3.14, "foo")
+       f2(x /* ERROR "cannot use .* in argument" */ , "foo")
+       f2(g0 /* ERROR "used as value" */ ())
+       f2(g1 /* ERROR "cannot use .* in argument" */ ()) /* ERROR "too few arguments" */
+       f2(g2())
+
+       fs() /* ERROR "too few arguments" */
+       fs(g0 /* ERROR "used as value" */ ())
+       fs(g1 /* ERROR "cannot use .* in argument" */ ())
+       fs(g2 /* ERROR "cannot use .* in argument" */ /* ERROR "too many arguments" */ ())
+       fs(gs())
+
+       fv()
+       fv(1, 2.0, x)
+       fv(s /* ERROR "cannot use .* in argument" */ )
+       fv(s...)
+       fv(x /* ERROR "cannot use" */ ...)
+       fv(1, s... /* ERROR "can only use ... with matching parameter" */ )
+       fv(gs /* ERROR "cannot use .* in argument" */ ())
+       fv(gs /* ERROR "cannot use .* in argument" */ ()...)
+
+       var t T
+       t.fm()
+       t.fm(1, 2.0, x)
+       t.fm(s /* ERROR "cannot use .* in argument" */ )
+       t.fm(g1())
+       t.fm(1, s... /* ERROR "can only use ... with matching parameter" */ )
+       t.fm(gs /* ERROR "cannot use .* in argument" */ ())
+       t.fm(gs /* ERROR "cannot use .* in argument" */ ()...)
+
+       T.fm(t, )
+       T.fm(t, 1, 2.0, x)
+       T.fm(t, s /* ERROR "cannot use .* in argument" */ )
+       T.fm(t, g1())
+       T.fm(t, 1, s... /* ERROR "can only use ... with matching parameter" */ )
+       T.fm(t, gs /* ERROR "cannot use .* in argument" */ ())
+       T.fm(t, gs /* ERROR "cannot use .* in argument" */ ()...)
+
+       var i interface{ fm(x ...int) } = t
+       i.fm()
+       i.fm(1, 2.0, x)
+       i.fm(s /* ERROR "cannot use .* in argument" */ )
+       i.fm(g1())
+       i.fm(1, s... /* ERROR "can only use ... with matching parameter" */ )
+       i.fm(gs /* ERROR "cannot use .* in argument" */ ())
+       i.fm(gs /* ERROR "cannot use .* in argument" */ ()...)
+
+       fi()
+       fi(1, 2.0, x, 3.14, "foo")
+       fi(g2())
+       fi(0, g2)
+       fi(0, g2 /* ERROR "2-valued g2" */ ())
+}
+
+func issue6344() {
+       type T []interface{}
+       var x T
+       fi(x...) // ... applies also to named slices
+}
diff --git a/libgo/go/go/types/testdata/gotos.src b/libgo/go/go/types/testdata/gotos.src
new file mode 100644 (file)
index 0000000..069a94b
--- /dev/null
@@ -0,0 +1,560 @@
+// Copyright 2011 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.
+
+// This file is a modified copy of $GOROOT/test/goto.go.
+
+package gotos
+
+var (
+       i, n int
+       x    []int
+       c    chan int
+       m    map[int]int
+       s    string
+)
+
+// goto after declaration okay
+func _() {
+       x := 1
+       goto L
+L:
+       _ = x
+}
+
+// goto before declaration okay
+func _() {
+       goto L
+L:
+       x := 1
+       _ = x
+}
+
+// goto across declaration not okay
+func _() {
+       goto L /* ERROR "goto L jumps over variable declaration at line 36" */
+       x := 1
+       _ = x
+L:
+}
+
+// goto across declaration in inner scope okay
+func _() {
+       goto L
+       {
+               x := 1
+               _ = x
+       }
+L:
+}
+
+// goto across declaration after inner scope not okay
+func _() {
+       goto L /* ERROR "goto L jumps over variable declaration at line 58" */
+       {
+               x := 1
+               _ = x
+       }
+       x := 1
+       _ = x
+L:
+}
+
+// goto across declaration in reverse okay
+func _() {
+L:
+       x := 1
+       _ = x
+       goto L
+}
+
+func _() {
+L: L1:
+       x := 1
+       _ = x
+       goto L
+       goto L1
+}
+
+// error shows first offending variable
+func _() {
+       goto L /* ERROR "goto L jumps over variable declaration at line 84" */
+       x := 1
+       _ = x
+       y := 1
+       _ = y
+L:
+}
+
+// goto not okay even if code path is dead
+func _() {
+       goto L /* ERROR "goto L jumps over variable declaration" */
+       x := 1
+       _ = x
+       y := 1
+       _ = y
+       return
+L:
+}
+
+// goto into outer block okay
+func _() {
+       {
+               goto L
+       }
+L:
+}
+
+func _() {
+       {
+               goto L
+               goto L1
+       }
+L: L1:
+}
+
+// goto backward into outer block okay
+func _() {
+L:
+       {
+               goto L
+       }
+}
+
+func _() {
+L: L1:
+       {
+               goto L
+               goto L1
+       }
+}
+
+// goto into inner block not okay
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       {
+       L:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       goto L1 /* ERROR "goto L1 jumps into block" */
+       {
+       L: L1:
+       }
+}
+
+// goto backward into inner block still not okay
+func _() {
+       {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       {
+       L: L1:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+       goto L1 /* ERROR "goto L1 jumps into block" */
+}
+
+// error shows first (outermost) offending block
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       {
+               {
+                       {
+                       L:
+                       }
+               }
+       }
+}
+
+// error prefers block diagnostic over declaration diagnostic
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       x := 1
+       _ = x
+       {
+       L:
+       }
+}
+
+// many kinds of blocks, all invalid to jump into or among,
+// but valid to jump out of
+
+// if
+
+func _() {
+L:
+       if true {
+               goto L
+       }
+}
+
+func _() {
+L:
+       if true {
+               goto L
+       } else {
+       }
+}
+
+func _() {
+L:
+       if false {
+       } else {
+               goto L
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       if true {
+       L:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       if true {
+       L:
+       } else {
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       if true {
+       } else {
+       L:
+       }
+}
+
+func _() {
+       if false {
+       L:
+       } else {
+               goto L /* ERROR "goto L jumps into block" */
+       }
+}
+
+func _() {
+       if true {
+               goto L /* ERROR "goto L jumps into block" */
+       } else {
+       L:
+       }
+}
+
+func _() {
+       if true {
+               goto L /* ERROR "goto L jumps into block" */
+       } else if false {
+       L:
+       }
+}
+
+func _() {
+       if true {
+               goto L /* ERROR "goto L jumps into block" */
+       } else if false {
+       L:
+       } else {
+       }
+}
+
+func _() {
+       if true {
+               goto L /* ERROR "goto L jumps into block" */
+       } else if false {
+       } else {
+       L:
+       }
+}
+
+func _() {
+       if true {
+               goto L /* ERROR "goto L jumps into block" */
+       } else {
+               L:
+       }
+}
+
+func _() {
+       if true {
+               L:
+       } else {
+               goto L /* ERROR "goto L jumps into block" */
+       }
+}
+
+// for
+
+func _() {
+       for {
+               goto L
+       }
+L:
+}
+
+func _() {
+       for {
+               goto L
+       L:
+       }
+}
+
+func _() {
+       for {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for {
+               goto L
+       L1:
+       }
+L:
+       goto L1 /* ERROR "goto L1 jumps into block" */
+}
+
+func _() {
+       for i < n {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for i = 0; i < n; i++ {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for i = range x {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for i = range c {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for i = range m {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+func _() {
+       for i = range s {
+       L:
+       }
+       goto L /* ERROR "goto L jumps into block" */
+}
+
+// switch
+
+func _() {
+L:
+       switch i {
+       case 0:
+               goto L
+       }
+}
+
+func _() {
+L:
+       switch i {
+       case 0:
+
+       default:
+               goto L
+       }
+}
+
+func _() {
+       switch i {
+       case 0:
+
+       default:
+       L:
+               goto L
+       }
+}
+
+func _() {
+       switch i {
+       case 0:
+
+       default:
+               goto L
+       L:
+       }
+}
+
+func _() {
+       switch i {
+       case 0:
+               goto L
+       L:
+               ;
+       default:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       switch i {
+       case 0:
+       L:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       switch i {
+       case 0:
+       L:
+               ;
+       default:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       switch i {
+       case 0:
+       default:
+       L:
+       }
+}
+
+func _() {
+       switch i {
+       default:
+               goto L /* ERROR "goto L jumps into block" */
+       case 0:
+       L:
+       }
+}
+
+func _() {
+       switch i {
+       case 0:
+       L:
+               ;
+       default:
+               goto L /* ERROR "goto L jumps into block" */
+       }
+}
+
+// select
+// different from switch.  the statement has no implicit block around it.
+
+func _() {
+L:
+       select {
+       case <-c:
+               goto L
+       }
+}
+
+func _() {
+L:
+       select {
+       case c <- 1:
+
+       default:
+               goto L
+       }
+}
+
+func _() {
+       select {
+       case <-c:
+
+       default:
+       L:
+               goto L
+       }
+}
+
+func _() {
+       select {
+       case c <- 1:
+
+       default:
+               goto L
+       L:
+       }
+}
+
+func _() {
+       select {
+       case <-c:
+               goto L
+       L:
+               ;
+       default:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       select {
+       case c <- 1:
+       L:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       select {
+       case c <- 1:
+       L:
+               ;
+       default:
+       }
+}
+
+func _() {
+       goto L /* ERROR "goto L jumps into block" */
+       select {
+       case <-c:
+       default:
+       L:
+       }
+}
+
+func _() {
+       select {
+       default:
+               goto L /* ERROR "goto L jumps into block" */
+       case <-c:
+       L:
+       }
+}
+
+func _() {
+       select {
+       case <-c:
+       L:
+               ;
+       default:
+               goto L /* ERROR "goto L jumps into block" */
+       }
+}
diff --git a/libgo/go/go/types/testdata/importC.src b/libgo/go/go/types/testdata/importC.src
new file mode 100644 (file)
index 0000000..31436be
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2015 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 importC
+
+import "C"
+import _ /* ERROR cannot rename import "C" */ "C"
+import foo /* ERROR cannot rename import "C" */ "C"
+import . /* ERROR cannot rename import "C" */ "C"
diff --git a/libgo/go/go/types/testdata/importdecl0a.src b/libgo/go/go/types/testdata/importdecl0a.src
new file mode 100644 (file)
index 0000000..463dcd0
--- /dev/null
@@ -0,0 +1,53 @@
+// 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 importdecl0
+
+import ()
+
+import (
+       // we can have multiple blank imports (was bug)
+       _ "math"
+       _ "net/rpc"
+       init /* ERROR "cannot declare init" */ "fmt"
+       // reflect defines a type "flag" which shows up in the gc export data
+       "reflect"
+       . /* ERROR "imported but not used" */ "reflect"
+)
+
+import "math" /* ERROR "imported but not used" */
+import m /* ERROR "imported but not used as m" */ "math"
+import _ "math"
+
+import (
+       "math/big" /* ERROR "imported but not used" */
+       b /* ERROR "imported but not used" */ "math/big"
+       _ "math/big"
+)
+
+import "fmt"
+import f1 "fmt"
+import f2 "fmt"
+
+// reflect.flag must not be visible in this package
+type flag int
+type _ reflect /* ERROR "not exported" */ .flag
+
+// imported package name may conflict with local objects
+type reflect /* ERROR "reflect already declared" */ int
+
+// dot-imported exported objects may conflict with local objects
+type Value /* ERROR "Value already declared through dot-import of package reflect" */ struct{}
+
+var _ = fmt.Println // use "fmt"
+
+func _() {
+       f1.Println() // use "fmt"
+}
+
+func _() {
+       _ = func() {
+               f2.Println() // use "fmt"
+       }
+}
diff --git a/libgo/go/go/types/testdata/importdecl0b.src b/libgo/go/go/types/testdata/importdecl0b.src
new file mode 100644 (file)
index 0000000..6844e70
--- /dev/null
@@ -0,0 +1,33 @@
+// 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 importdecl0
+
+import "math"
+import m "math"
+
+import . "testing" // declares T in file scope
+import . /* ERROR "imported but not used" */ "unsafe"
+import . "fmt"     // declares Println in file scope
+
+import (
+       // TODO(gri) At the moment, 2 errors are reported because both go/parser
+       // and the type checker report it. Eventually, this test should not be
+       // done by the parser anymore.
+       "" /* ERROR invalid import path */ /* ERROR invalid import path */
+       "a!b" /* ERROR invalid import path */ /* ERROR invalid import path */
+       "abc\xffdef" /* ERROR invalid import path */ /* ERROR invalid import path */
+)
+
+// using "math" in this file doesn't affect its use in other files
+const Pi0 = math.Pi
+const Pi1 = m.Pi
+
+type _ T // use "testing"
+
+func _() func() interface{} {
+       return func() interface{} {
+               return Println // use "fmt"
+       }
+}
diff --git a/libgo/go/go/types/testdata/importdecl1a.src b/libgo/go/go/types/testdata/importdecl1a.src
new file mode 100644 (file)
index 0000000..8301820
--- /dev/null
@@ -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.
+
+// Test case for issue 8969.
+
+package importdecl1
+
+import . "unsafe"
+
+var _ Pointer // use dot-imported package unsafe
diff --git a/libgo/go/go/types/testdata/importdecl1b.src b/libgo/go/go/types/testdata/importdecl1b.src
new file mode 100644 (file)
index 0000000..f24bb9a
--- /dev/null
@@ -0,0 +1,7 @@
+// 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 importdecl1
+
+import . /* ERROR "imported but not used" */ "unsafe"
diff --git a/libgo/go/go/types/testdata/init0.src b/libgo/go/go/types/testdata/init0.src
new file mode 100644 (file)
index 0000000..ef0349c
--- /dev/null
@@ -0,0 +1,106 @@
+// 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.
+
+// initialization cycles
+
+package init0
+
+// initialization cycles (we don't know the types)
+const (
+       s0 /* ERROR initialization cycle */ = s0
+
+       x0 /* ERROR initialization cycle */ = y0
+       y0 = x0
+
+       a0 = b0
+       b0 /* ERROR initialization cycle */ = c0
+       c0 = d0
+       d0 = b0
+)
+
+var (
+       s1 /* ERROR initialization cycle */ = s1
+
+       x1 /* ERROR initialization cycle */ = y1
+       y1 = x1
+
+       a1 = b1
+       b1 /* ERROR initialization cycle */ = c1
+       c1 = d1
+       d1 = b1
+)
+
+// initialization cycles (we know the types)
+const (
+       s2 /* ERROR initialization cycle */ int = s2
+
+       x2 /* ERROR initialization cycle */ int = y2
+       y2 = x2
+
+       a2 = b2
+       b2 /* ERROR initialization cycle */ int = c2
+       c2 = d2
+       d2 = b2
+)
+
+var (
+       s3 /* ERROR initialization cycle */ int = s3
+
+       x3 /* ERROR initialization cycle */ int = y3
+       y3 = x3
+
+       a3 = b3
+       b3 /* ERROR initialization cycle */ int = c3
+       c3 = d3
+       d3 = b3
+)
+
+// cycles via struct fields
+
+type S1 struct {
+       f int
+}
+const cx3 S1 /* ERROR invalid constant type */ = S1{cx3.f}
+var vx3 /* ERROR initialization cycle */ S1 = S1{vx3.f}
+
+// cycles via functions
+
+var x4 = x5
+var x5 /* ERROR initialization cycle */ = f1()
+func f1() int { return x5*10 }
+
+var x6, x7 /* ERROR initialization cycle */ = f2()
+var x8 = x7
+func f2() (int, int) { return f3() + f3(), 0 }
+func f3() int { return x8 }
+
+// cycles via closures
+
+var x9 /* ERROR initialization cycle */ = func() int { return x9 }()
+
+var x10 /* ERROR initialization cycle */ = f4()
+
+func f4() int {
+       _ = func() {
+               _ = x10
+       }
+       return 0
+}
+
+// cycles via method expressions
+
+type T1 struct{}
+
+func (T1) m() bool { _ = x11; return false }
+
+var x11 /* ERROR initialization cycle */ = T1.m(T1{})
+
+// cycles via method values
+
+type T2 struct{}
+
+func (T2) m() bool { _ = x12; return false }
+
+var t1 T2
+var x12 /* ERROR initialization cycle */ = t1.m
diff --git a/libgo/go/go/types/testdata/init1.src b/libgo/go/go/types/testdata/init1.src
new file mode 100644 (file)
index 0000000..39ca314
--- /dev/null
@@ -0,0 +1,97 @@
+// 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.
+
+// initialization cycles
+
+package init1
+
+// issue 6683 (marked as WorkingAsIntended)
+
+type T0 struct{}
+
+func (T0) m() int { return y0 }
+
+var x0 = T0{}
+
+var y0 /* ERROR initialization cycle */ = x0.m()
+
+type T1 struct{}
+
+func (T1) m() int { return y1 }
+
+var x1 interface {
+       m() int
+} = T1{}
+
+var y1 = x1.m() // no cycle reported, x1 is of interface type
+
+// issue 6703 (modified)
+
+var x2 /* ERROR initialization cycle */ = T2.m
+
+var y2 = x2
+
+type T2 struct{}
+
+func (T2) m() int {
+       _ = y2
+       return 0
+}
+
+var x3 /* ERROR initialization cycle */ = T3.m(T3{}) // <<<< added (T3{})
+
+var y3 = x3
+
+type T3 struct{}
+
+func (T3) m() int {
+       _ = y3
+       return 0
+}
+
+var x4 /* ERROR initialization cycle */ = T4{}.m // <<<< added {}
+
+var y4 = x4
+
+type T4 struct{}
+
+func (T4) m() int {
+       _ = y4
+       return 0
+}
+
+var x5 /* ERROR initialization cycle */ = T5{}.m() // <<<< added ()
+
+var y5 = x5
+
+type T5 struct{}
+
+func (T5) m() int {
+       _ = y5
+       return 0
+}
+
+// issue 4847
+// simplified test case
+
+var x6 = f6
+var y6 /* ERROR initialization cycle */ = f6
+func f6() { _ = y6 }
+
+// full test case
+
+type (
+      E int
+      S int
+)
+
+type matcher func(s *S) E
+
+func matchList(s *S) E { return matcher(matchAnyFn)(s) }
+
+var foo = matcher(matchList)
+
+var matchAny /* ERROR initialization cycle */ = matcher(matchList)
+
+func matchAnyFn(s *S) (err E) { return matchAny(s) }
\ No newline at end of file
diff --git a/libgo/go/go/types/testdata/init2.src b/libgo/go/go/types/testdata/init2.src
new file mode 100644 (file)
index 0000000..614db6c
--- /dev/null
@@ -0,0 +1,139 @@
+// 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.
+
+// initialization cycles
+
+package init2
+
+// cycles through functions
+
+func f1() int { _ = x1; return 0 }
+var x1 /* ERROR initialization cycle */ = f1
+
+func f2() int { _ = x2; return 0 }
+var x2 /* ERROR initialization cycle */ = f2()
+
+// cycles through method expressions
+
+type T3 int
+func (T3) m() int { _ = x3; return 0 }
+var x3 /* ERROR initialization cycle */ = T3.m
+
+type T4 int
+func (T4) m() int { _ = x4; return 0 }
+var x4 /* ERROR initialization cycle */ = T4.m(0)
+
+type T3p int
+func (*T3p) m() int { _ = x3p; return 0 }
+var x3p /* ERROR initialization cycle */ = (*T3p).m
+
+type T4p int
+func (*T4p) m() int { _ = x4p; return 0 }
+var x4p /* ERROR initialization cycle */ = (*T4p).m(nil)
+
+// cycles through method expressions of embedded methods
+
+type T5 struct { E5 }
+type E5 int
+func (E5) m() int { _ = x5; return 0 }
+var x5 /* ERROR initialization cycle */ = T5.m
+
+type T6 struct { E6 }
+type E6 int
+func (E6) m() int { _ = x6; return 0 }
+var x6 /* ERROR initialization cycle */ = T6.m(T6{0})
+
+type T5p struct { E5p }
+type E5p int
+func (*E5p) m() int { _ = x5p; return 0 }
+var x5p /* ERROR initialization cycle */ = (*T5p).m
+
+type T6p struct { E6p }
+type E6p int
+func (*E6p) m() int { _ = x6p; return 0 }
+var x6p /* ERROR initialization cycle */ = (*T6p).m(nil)
+
+// cycles through method values
+
+type T7 int
+func (T7) m() int { _ = x7; return 0 }
+var x7 /* ERROR initialization cycle */ = T7(0).m
+
+type T8 int
+func (T8) m() int { _ = x8; return 0 }
+var x8 /* ERROR initialization cycle */ = T8(0).m()
+
+type T7p int
+func (*T7p) m() int { _ = x7p; return 0 }
+var x7p /* ERROR initialization cycle */ = new(T7p).m
+
+type T8p int
+func (*T8p) m() int { _ = x8p; return 0 }
+var x8p /* ERROR initialization cycle */ = new(T8p).m()
+
+type T7v int
+func (T7v) m() int { _ = x7v; return 0 }
+var x7var T7v
+var x7v /* ERROR initialization cycle */ = x7var.m
+
+type T8v int
+func (T8v) m() int { _ = x8v; return 0 }
+var x8var T8v
+var x8v /* ERROR initialization cycle */ = x8var.m()
+
+type T7pv int
+func (*T7pv) m() int { _ = x7pv; return 0 }
+var x7pvar *T7pv
+var x7pv /* ERROR initialization cycle */ = x7pvar.m
+
+type T8pv int
+func (*T8pv) m() int { _ = x8pv; return 0 }
+var x8pvar *T8pv
+var x8pv /* ERROR initialization cycle */ = x8pvar.m()
+
+// cycles through method values of embedded methods
+
+type T9 struct { E9 }
+type E9 int
+func (E9) m() int { _ = x9; return 0 }
+var x9 /* ERROR initialization cycle */ = T9{0}.m
+
+type T10 struct { E10 }
+type E10 int
+func (E10) m() int { _ = x10; return 0 }
+var x10 /* ERROR initialization cycle */ = T10{0}.m()
+
+type T9p struct { E9p }
+type E9p int
+func (*E9p) m() int { _ = x9p; return 0 }
+var x9p /* ERROR initialization cycle */ = new(T9p).m
+
+type T10p struct { E10p }
+type E10p int
+func (*E10p) m() int { _ = x10p; return 0 }
+var x10p /* ERROR initialization cycle */ = new(T10p).m()
+
+type T9v struct { E9v }
+type E9v int
+func (E9v) m() int { _ = x9v; return 0 }
+var x9var T9v
+var x9v /* ERROR initialization cycle */ = x9var.m
+
+type T10v struct { E10v }
+type E10v int
+func (E10v) m() int { _ = x10v; return 0 }
+var x10var T10v
+var x10v /* ERROR initialization cycle */ = x10var.m()
+
+type T9pv struct { E9pv }
+type E9pv int
+func (*E9pv) m() int { _ = x9pv; return 0 }
+var x9pvar *T9pv
+var x9pv /* ERROR initialization cycle */ = x9pvar.m
+
+type T10pv struct { E10pv }
+type E10pv int
+func (*E10pv) m() int { _ = x10pv; return 0 }
+var x10pvar *T10pv
+var x10pv /* ERROR initialization cycle */ = x10pvar.m()
diff --git a/libgo/go/go/types/testdata/issues.src b/libgo/go/go/types/testdata/issues.src
new file mode 100644 (file)
index 0000000..6579aa3
--- /dev/null
@@ -0,0 +1,188 @@
+// 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 issues
+
+import "fmt"
+
+func issue7035() {
+       type T struct{ X int }
+       _ = func() {
+               fmt.Println() // must refer to imported fmt rather than the fmt below
+       }
+       fmt := new(T)
+       _ = fmt.X
+}
+
+func issue8066() {
+       const (
+               _ = float32(340282356779733661637539395458142568447)
+               _ = float32(340282356779733661637539395458142568448 /* ERROR cannot convert */ )
+       )
+}
+
+// Check that a missing identifier doesn't lead to a spurious error cascade.
+func issue8799a() {
+       x, ok := missing /* ERROR undeclared */ ()
+       _ = !ok
+       _ = x
+}
+
+func issue8799b(x int, ok bool) {
+       x, ok = missing /* ERROR undeclared */ ()
+       _ = !ok
+       _ = x
+}
+
+func issue9182() {
+       type Point C /* ERROR undeclared */ .Point
+       // no error for composite literal based on unknown type
+       _ = Point{x: 1, y: 2}
+}
+
+func f0() (a []int)         { return }
+func f1() (a []int, b int)  { return }
+func f2() (a, b []int)      { return }
+
+func append_([]int, ...int) {}
+
+func issue9473(a []int, b ...int) {
+       // variadic builtin function
+       _ = append(f0())
+       _ = append(f0(), f0()...)
+       _ = append(f1())
+       _ = append(f2 /* ERROR cannot use .* in argument */ ())
+       _ = append(f2()... /* ERROR cannot use ... */ )
+       _ = append(f0(), f1 /* ERROR 2-valued f1 */ ())
+       _ = append(f0(), f2 /* ERROR 2-valued f2 */ ())
+       _ = append(f0(), f1 /* ERROR 2-valued f1 */ ()...)
+       _ = append(f0(), f2 /* ERROR 2-valued f2 */ ()...)
+
+       // variadic user-defined function
+       append_(f0())
+       append_(f0(), f0()...)
+       append_(f1())
+       append_(f2 /* ERROR cannot use .* in argument */ ())
+       append_(f2()... /* ERROR cannot use ... */ )
+       append_(f0(), f1 /* ERROR 2-valued f1 */ ())
+       append_(f0(), f2 /* ERROR 2-valued f2 */ ())
+       append_(f0(), f1 /* ERROR 2-valued f1 */ ()...)
+       append_(f0(), f2 /* ERROR 2-valued f2 */ ()...)
+}
+
+// Check that embedding a non-interface type in an interface results in a good error message.
+func issue10979() {
+       type _ interface {
+               int /* ERROR int is not an interface */
+       }
+       type T struct{}
+       type _ interface {
+               T /* ERROR T is not an interface */
+       }
+       type _ interface {
+               nosuchtype /* ERROR undeclared name: nosuchtype */
+       }
+       type _ interface {
+               fmt /* ERROR Nosuchtype not declared by package fmt */ .Nosuchtype
+       }
+       type _ interface {
+               nosuchpkg /* ERROR undeclared name: nosuchpkg */ .Nosuchtype
+       }
+       type I interface {
+               I /* ERROR I\.m \(value of type func\(I\)\) is not a type */ .m
+               m()
+       }
+}
+
+// issue11347
+// These should not crash.
+var a1, b1 /* ERROR cycle */ , c1 /* ERROR cycle */ b1 = 0 > 0<<""[""[c1]]>c1
+var a2, b2 /* ERROR cycle */ = 0 /* ERROR mismatch */ /* ERROR mismatch */ > 0<<""[b2]
+var a3, b3 /* ERROR cycle */ = int /* ERROR mismatch */ /* ERROR mismatch */ (1<<""[b3])
+
+// issue10260
+// Check that error messages explain reason for interface assignment failures.
+type (
+       I0 interface{}
+       I1 interface{ foo() }
+       I2 interface{ foo(x int) }
+       T0 struct{}
+       T1 struct{}
+       T2 struct{}
+)
+
+func (*T1) foo() {}
+func (*T2) foo(x int) {}
+
+func issue10260() {
+       var (
+               i0 I0
+               i1 I1
+               i2 I2
+               t0 *T0
+               t1 *T1
+               t2 *T2
+       )
+       i1 = i0 /* ERROR cannot use .* missing method foo */
+       i1 = t0 /* ERROR cannot use .* missing method foo */
+       i1 = i2 /* ERROR cannot use .* wrong type for method foo */
+       i1 = t2 /* ERROR cannot use .* wrong type for method foo */
+       i2 = i1 /* ERROR cannot use .* wrong type for method foo */
+       i2 = t1 /* ERROR cannot use .* wrong type for method foo */
+
+       _ = func() I1 { return i0 /* ERROR cannot use .* missing method foo */ }
+       _ = func() I1 { return t0 /* ERROR cannot use .* missing method foo */ }
+       _ = func() I1 { return i2 /* ERROR cannot use .* wrong type for method foo */ }
+       _ = func() I1 { return t2 /* ERROR cannot use .* wrong type for method foo */ }
+       _ = func() I2 { return i1 /* ERROR cannot use .* wrong type for method foo */ }
+       _ = func() I2 { return t1 /* ERROR cannot use .* wrong type for method foo */ }
+
+       // a few more - less exhaustive now
+
+       f := func(I1, I2){}
+       f(i0 /* ERROR cannot use .* missing method foo */ , i1 /* ERROR cannot use .* wrong type for method foo */)
+
+       _ = [...]I1{i0 /* ERROR cannot use .* missing method foo */ }
+       _ = [...]I1{i2 /* ERROR cannot use .* wrong type for method foo */ }
+       _ = []I1{i0 /* ERROR cannot use .* missing method foo */ }
+       _ = []I1{i2 /* ERROR cannot use .* wrong type for method foo */ }
+       _ = map[int]I1{0: i0 /* ERROR cannot use .* missing method foo */ }
+       _ = map[int]I1{0: i2 /* ERROR cannot use .* wrong type for method foo */ }
+
+       make(chan I1) <- i0 /* ERROR cannot use .* in send: missing method foo */
+       make(chan I1) <- i2 /* ERROR cannot use .* in send: wrong type for method foo */
+}
+
+// Check that constants representable as integers are in integer form
+// before being used in operations that are only defined on integers.
+func issue14229() {
+       // from the issue
+       const _ = int64(-1<<63) % 1e6
+
+       // related
+       const (
+               a int = 3
+               b = 4.0
+               _ = a / b
+               _ = a % b
+               _ = b / a
+               _ = b % a
+       )
+}
+
+// Check that in a n:1 variable declaration with type and initialization
+// expression the type is distributed to all variables of the lhs before
+// the initialization expression assignment is checked.
+func issue15755() {
+       // from issue
+       var i interface{}
+       type b bool
+       var x, y b = i.(b)
+       _ = x == y
+
+       // related: we should see an error since the result of f1 is ([]int, int)
+       var u, v []int = f1 /* ERROR cannot use f1 */ ()
+       _ = u
+       _ = v
+}
diff --git a/libgo/go/go/types/testdata/labels.src b/libgo/go/go/types/testdata/labels.src
new file mode 100644 (file)
index 0000000..9f42406
--- /dev/null
@@ -0,0 +1,207 @@
+// Copyright 2011 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.
+
+// This file is a modified concatenation of the files
+// $GOROOT/test/label.go and $GOROOT/test/label1.go.
+
+package labels
+
+var x int
+
+func f0() {
+L1 /* ERROR "label L1 declared but not used" */ :
+       for {
+       }
+L2 /* ERROR "label L2 declared but not used" */ :
+       select {
+       }
+L3 /* ERROR "label L3 declared but not used" */ :
+       switch {
+       }
+L4 /* ERROR "label L4 declared but not used" */ :
+       if true {
+       }
+L5 /* ERROR "label L5 declared but not used" */ :
+       f0()
+L6:
+       f0()
+L6 /* ERROR "label L6 already declared" */ :
+       f0()
+       if x == 20 {
+               goto L6
+       }
+
+L7:
+       for {
+               break L7
+               break L8 /* ERROR "invalid break label L8" */
+       }
+
+// A label must be directly associated with a switch, select, or
+// for statement; it cannot be the label of a labeled statement.
+
+L7a /* ERROR "declared but not used" */ : L7b:
+       for {
+               break L7a /* ERROR "invalid break label L7a" */
+               continue L7a /* ERROR "invalid continue label L7a" */
+               continue L7b
+       }
+
+L8:
+       for {
+               if x == 21 {
+                       continue L8
+                       continue L7 /* ERROR "invalid continue label L7" */
+               }
+       }
+
+L9:
+       switch {
+       case true:
+               break L9
+       defalt /* ERROR "label defalt declared but not used" */ :
+       }
+
+L10:
+       select {
+       default:
+               break L10
+               break L9 /* ERROR "invalid break label L9" */
+       }
+
+       goto L10a
+L10a: L10b:
+       select {
+       default:
+               break L10a /* ERROR "invalid break label L10a" */
+               break L10b
+               continue L10b /* ERROR "invalid continue label L10b" */
+       }
+}
+
+func f1() {
+L1:
+       for {
+               if x == 0 {
+                       break L1
+               }
+               if x == 1 {
+                       continue L1
+               }
+               goto L1
+       }
+
+L2:
+       select {
+       default:
+               if x == 0 {
+                       break L2
+               }
+               if x == 1 {
+                       continue L2 /* ERROR "invalid continue label L2" */
+               }
+               goto L2
+       }
+
+L3:
+       switch {
+       case x > 10:
+               if x == 11 {
+                       break L3
+               }
+               if x == 12 {
+                       continue L3 /* ERROR "invalid continue label L3" */
+               }
+               goto L3
+       }
+
+L4:
+       if true {
+               if x == 13 {
+                       break L4 /* ERROR "invalid break label L4" */
+               }
+               if x == 14 {
+                       continue L4 /* ERROR "invalid continue label L4" */
+               }
+               if x == 15 {
+                       goto L4
+               }
+       }
+
+L5:
+       f1()
+       if x == 16 {
+               break L5 /* ERROR "invalid break label L5" */
+       }
+       if x == 17 {
+               continue L5 /* ERROR "invalid continue label L5" */
+       }
+       if x == 18 {
+               goto L5
+       }
+
+       for {
+               if x == 19 {
+                       break L1 /* ERROR "invalid break label L1" */
+               }
+               if x == 20 {
+                       continue L1 /* ERROR "invalid continue label L1" */
+               }
+               if x == 21 {
+                       goto L1
+               }
+       }
+}
+
+// Additional tests not in the original files.
+
+func f2() {
+L1 /* ERROR "label L1 declared but not used" */ :
+       if x == 0 {
+               for {
+                       continue L1 /* ERROR "invalid continue label L1" */
+               }
+       }
+}
+
+func f3() {
+L1:
+L2:
+L3:
+       for {
+               break L1 /* ERROR "invalid break label L1" */
+               break L2 /* ERROR "invalid break label L2" */
+               break L3
+               continue L1 /* ERROR "invalid continue label L1" */
+               continue L2 /* ERROR "invalid continue label L2" */
+               continue L3
+               goto L1
+               goto L2
+               goto L3
+       }
+}
+
+// Blank labels are never declared.
+
+func f4() {
+_:
+_: // multiple blank labels are ok
+       goto _ /* ERROR "label _ not declared" */
+}
+
+func f5() {
+_:
+       for {
+               break _ /* ERROR "invalid break label _" */
+               continue _ /* ERROR "invalid continue label _" */
+       }
+}
+
+func f6() {
+_:
+       switch {
+       default:
+               break _ /* ERROR "invalid break label _" */
+       }
+}
diff --git a/libgo/go/go/types/testdata/methodsets.src b/libgo/go/go/types/testdata/methodsets.src
new file mode 100644 (file)
index 0000000..8921146
--- /dev/null
@@ -0,0 +1,214 @@
+// 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 methodsets
+
+type T0 struct {}
+
+func (T0) v0() {}
+func (*T0) p0() {}
+
+type T1 struct {} // like T0 with different method names
+
+func (T1) v1() {}
+func (*T1) p1() {}
+
+type T2 interface {
+       v2()
+       p2()
+}
+
+type T3 struct {
+       T0
+       *T1
+       T2
+}
+
+// Method expressions
+func _() {
+       var (
+               _ func(T0) = T0.v0
+               _ = T0 /* ERROR "not in method set" */ .p0
+
+               _ func (*T0) = (*T0).v0
+               _ func (*T0) = (*T0).p0
+
+               // T1 is like T0
+
+               _ func(T2) = T2.v2
+               _ func(T2) = T2.p2
+
+               _ func(T3) = T3.v0
+               _ func(T3) = T3 /* ERROR "not in method set" */ .p0
+               _ func(T3) = T3.v1
+               _ func(T3) = T3.p1
+               _ func(T3) = T3.v2
+               _ func(T3) = T3.p2
+
+               _ func(*T3) = (*T3).v0
+               _ func(*T3) = (*T3).p0
+               _ func(*T3) = (*T3).v1
+               _ func(*T3) = (*T3).p1
+               _ func(*T3) = (*T3).v2
+               _ func(*T3) = (*T3).p2
+       )
+}
+
+// Method values with addressable receivers
+func _() {
+       var (
+               v0 T0
+               _ func() = v0.v0
+               _ func() = v0.p0
+       )
+
+       var (
+               p0 *T0
+               _ func() = p0.v0
+               _ func() = p0.p0
+       )
+
+       // T1 is like T0
+
+       var (
+               v2 T2
+               _ func() = v2.v2
+               _ func() = v2.p2
+       )
+
+       var (
+               v4 T3
+               _ func() = v4.v0
+               _ func() = v4.p0
+               _ func() = v4.v1
+               _ func() = v4.p1
+               _ func() = v4.v2
+               _ func() = v4.p2
+       )
+
+       var (
+               p4 *T3
+               _ func() = p4.v0
+               _ func() = p4.p0
+               _ func() = p4.v1
+               _ func() = p4.p1
+               _ func() = p4.v2
+               _ func() = p4.p2
+       )
+}
+
+// Method calls with addressable receivers
+func _() {
+       var v0 T0
+       v0.v0()
+       v0.p0()
+
+       var p0 *T0
+       p0.v0()
+       p0.p0()
+
+       // T1 is like T0
+
+       var v2 T2
+       v2.v2()
+       v2.p2()
+
+       var v4 T3
+       v4.v0()
+       v4.p0()
+       v4.v1()
+       v4.p1()
+       v4.v2()
+       v4.p2()
+
+       var p4 *T3
+       p4.v0()
+       p4.p0()
+       p4.v1()
+       p4.p1()
+       p4.v2()
+       p4.p2()
+}
+
+// Method values with value receivers
+func _() {
+       var (
+               _ func() = T0{}.v0
+               _ func() = T0 /* ERROR "not in method set" */ {}.p0
+
+               _ func() = (&T0{}).v0
+               _ func() = (&T0{}).p0
+
+               // T1 is like T0
+
+               // no values for T2
+
+               _ func() = T3{}.v0
+               _ func() = T3 /* ERROR "not in method set" */ {}.p0
+               _ func() = T3{}.v1
+               _ func() = T3{}.p1
+               _ func() = T3{}.v2
+               _ func() = T3{}.p2
+
+               _ func() = (&T3{}).v0
+               _ func() = (&T3{}).p0
+               _ func() = (&T3{}).v1
+               _ func() = (&T3{}).p1
+               _ func() = (&T3{}).v2
+               _ func() = (&T3{}).p2
+       )
+}
+
+// Method calls with value receivers
+func _() {
+       T0{}.v0()
+       T0 /* ERROR "not in method set" */ {}.p0()
+
+       (&T0{}).v0()
+       (&T0{}).p0()
+
+       // T1 is like T0
+
+       // no values for T2
+
+       T3{}.v0()
+       T3 /* ERROR "not in method set" */ {}.p0()
+       T3{}.v1()
+       T3{}.p1()
+       T3{}.v2()
+       T3{}.p2()
+
+       (&T3{}).v0()
+       (&T3{}).p0()
+       (&T3{}).v1()
+       (&T3{}).p1()
+       (&T3{}).v2()
+       (&T3{}).p2()
+}
+
+// *T has no methods if T is an interface type
+func issue5918() {
+       var (
+               err error
+               _ = err.Error()
+               _ func() string = err.Error
+               _ func(error) string = error.Error
+
+               perr = &err
+               _ = perr /* ERROR "no field or method" */ .Error()
+               _ func() string = perr /* ERROR "no field or method" */ .Error
+               _ func(*error) string = ( /* ERROR "no field or method" */ *error).Error
+       )
+
+       type T *interface{ m() int }
+       var (
+               x T
+               _ = (*x).m()
+               _ = (*x).m
+
+               _ = x /* ERROR "no field or method" */ .m()
+               _ = x /* ERROR "no field or method" */ .m
+               _ = T /* ERROR "no field or method" */ .m
+       )
+}
diff --git a/libgo/go/go/types/testdata/shifts.src b/libgo/go/go/types/testdata/shifts.src
new file mode 100644 (file)
index 0000000..099c9ec
--- /dev/null
@@ -0,0 +1,341 @@
+// 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 shifts
+
+func shifts0() {
+       // basic constant shifts
+       const (
+               s = 10
+               _ = 0<<0
+               _ = 1<<s
+               _ = 1<<- /* ERROR "invalid shift" */ 1
+               _ = 1<<1075 /* ERROR "invalid shift" */
+               _ = 2.0<<1
+
+               _ int = 2<<s
+               _ float32 = 2<<s
+               _ complex64 = 2<<s
+
+               _ int = 2.0<<s
+               _ float32 = 2.0<<s
+               _ complex64 = 2.0<<s
+
+               _ int = 'a'<<s
+               _ float32 = 'a'<<s
+               _ complex64 = 'a'<<s
+       )
+}
+
+func shifts1() {
+       // basic non-constant shifts
+       var (
+               i int
+               u uint
+
+               _ = 1<<0
+               _ = 1<<i /* ERROR "must be unsigned" */
+               _ = 1<<u
+               _ = 1<<"foo" /* ERROR "cannot convert" */
+               _ = i<<0
+               _ = i<<- /* ERROR "must not be negative" */ 1
+               _ = 1 /* ERROR "overflows" */ <<100
+
+               _ uint = 1 << 0
+               _ uint = 1 << u
+               _ float32 = 1 /* ERROR "must be integer" */ << u
+       )
+}
+
+func shifts2() {
+       // from the spec
+       var (
+               s uint = 33
+               i = 1<<s           // 1 has type int
+               j int32 = 1<<s     // 1 has type int32; j == 0
+               k = uint64(1<<s)   // 1 has type uint64; k == 1<<33
+               m int = 1.0<<s     // 1.0 has type int
+               n = 1.0<<s != i    // 1.0 has type int; n == false if ints are 32bits in size
+               o = 1<<s == 2<<s   // 1 and 2 have type int; o == true if ints are 32bits in size
+               p = 1<<s == 1<<33  // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int
+               u = 1.0 /* ERROR "must be integer" */ <<s         // illegal: 1.0 has type float64, cannot shift
+               u1 = 1.0 /* ERROR "must be integer" */ <<s != 0   // illegal: 1.0 has type float64, cannot shift
+               u2 = 1 /* ERROR "must be integer" */ <<s != 1.0   // illegal: 1 has type float64, cannot shift
+               v float32 = 1 /* ERROR "must be integer" */ <<s   // illegal: 1 has type float32, cannot shift
+               w int64 = 1.0<<33  // 1.0<<33 is a constant shift expression
+       )
+       _, _, _, _, _, _, _, _, _, _, _, _ = i, j, k, m, n, o, p, u, u1, u2, v, w
+}
+
+func shifts3(a int16, b float32) {
+       // random tests
+       var (
+               s uint = 11
+               u = 1 /* ERROR "must be integer" */ <<s + 1.0
+               v complex128 = 1 /* ERROR "must be integer" */ << s + 1.0 /* ERROR "must be integer" */ << s + 1
+       )
+       x := 1.0 /* ERROR "must be integer" */ <<s + 1
+       shifts3(1.0 << s, 1 /* ERROR "must be integer" */ >> s)
+       _, _, _ = u, v, x
+}
+
+func shifts4() {
+       // shifts in comparisons w/ untyped operands
+       var s uint
+
+       _ = 1<<s == 1
+       _ = 1 /* ERROR "integer" */ <<s == 1.
+       _ = 1. /* ERROR "integer" */ <<s == 1
+       _ = 1. /* ERROR "integer" */ <<s == 1.
+
+       _ = 1<<s + 1 == 1
+       _ = 1 /* ERROR "integer" */ <<s + 1 == 1.
+       _ = 1 /* ERROR "integer" */ <<s + 1. == 1
+       _ = 1 /* ERROR "integer" */ <<s + 1. == 1.
+       _ = 1. /* ERROR "integer" */ <<s + 1 == 1
+       _ = 1. /* ERROR "integer" */ <<s + 1 == 1.
+       _ = 1. /* ERROR "integer" */ <<s + 1. == 1
+       _ = 1. /* ERROR "integer" */ <<s + 1. == 1.
+
+       _ = 1<<s == 1<<s
+       _ = 1 /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s
+
+       _ = 1<<s + 1<<s == 1
+       _ = 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1.
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1.
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1.
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1.
+
+       _ = 1<<s + 1<<s == 1<<s + 1<<s
+       _ = 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1 /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1 /* ERROR "integer" */ <<s
+       _ = 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s == 1. /* ERROR "integer" */ <<s + 1. /* ERROR "integer" */ <<s
+}
+
+func shifts5() {
+       // shifts in comparisons w/ typed operands
+       var s uint
+       var x int
+
+       _ = 1<<s == x
+       _ = 1.<<s == x
+       _ = 1.1 /* ERROR "int" */ <<s == x
+
+       _ = 1<<s + x == 1
+       _ = 1<<s + x == 1.
+       _ = 1<<s + x == 1.1 /* ERROR "int" */
+       _ = 1.<<s + x == 1
+       _ = 1.<<s + x == 1.
+       _ = 1.<<s + x == 1.1 /* ERROR "int" */
+       _ = 1.1 /* ERROR "int" */ <<s + x == 1
+       _ = 1.1 /* ERROR "int" */ <<s + x == 1.
+       _ = 1.1 /* ERROR "int" */ <<s + x == 1.1
+
+       _ = 1<<s == x<<s
+       _ = 1.<<s == x<<s
+       _ = 1.1  /* ERROR "int" */ <<s == x<<s
+}
+
+func shifts6() {
+       // shifts as operands in non-arithmetic operations and as arguments
+       var a [10]int
+       var s uint
+
+       _ = a[1<<s]
+       _ = a[1.0]
+       _ = a[1.0<<s]
+
+       _ = make([]int, 1.0)
+       _ = make([]int, 1.0<<s)
+       _ = make([]int, 1.1 /* ERROR "must be integer" */ <<s)
+
+       _ = float32(1)
+       _ = float32(1 /* ERROR "must be integer" */ <<s)
+       _ = float32(1.0)
+       _ = float32(1.0 /* ERROR "must be integer" */ <<s)
+       _ = float32(1.1 /* ERROR "must be integer" */ <<s)
+
+       var b []int
+       _ = append(b, 1<<s)
+       _ = append(b, 1.0<<s)
+       _ = append(b, 1.1 /* ERROR "must be integer" */ <<s)
+
+       _ = append(b, 1<<s)
+       _ = append(b, 1.0<<s) // should fail - see TODO in append code
+       _ = append(b, 1.1 /* ERROR "must be integer" */ <<s)
+
+       _ = complex(1.0 /* ERROR "must be integer" */ <<s, 0)
+       _ = complex(1.1 /* ERROR "must be integer" */ <<s, 0)
+       _ = complex(0, 1.0 /* ERROR "must be integer" */ <<s)
+       _ = complex(0, 1.1 /* ERROR "must be integer" */ <<s)
+
+       // TODO(gri) The delete below is not type-checked correctly yet.
+       // var m1 map[int]string
+       // delete(m1, 1<<s)
+}
+
+func shifts7() {
+       // shifts of shifts
+       var s uint
+       var x int
+       _ = x
+
+       _ = 1<<(1<<s)
+       _ = 1<<(1.<<s)
+       _ = 1. /* ERROR "integer" */ <<(1<<s)
+       _ = 1. /* ERROR "integer" */ <<(1.<<s)
+
+       x = 1<<(1<<s)
+       x = 1<<(1.<<s)
+       x = 1.<<(1<<s)
+       x = 1.<<(1.<<s)
+
+       _ = (1<<s)<<(1<<s)
+       _ = (1<<s)<<(1.<<s)
+       _ = ( /* ERROR "integer" */ 1.<<s)<<(1<<s)
+       _ = ( /* ERROR "integer" */ 1.<<s)<<(1.<<s)
+
+       x = (1<<s)<<(1<<s)
+       x = (1<<s)<<(1.<<s)
+       x = ( /* ERROR "integer" */ 1.<<s)<<(1<<s)
+       x = ( /* ERROR "integer" */ 1.<<s)<<(1.<<s)
+}
+
+func shifts8() {
+       // shift examples from shift discussion: better error messages
+       var s uint
+       _ = 1.0 /* ERROR "shifted operand 1.0 \(type float64\) must be integer" */ <<s == 1
+       _ = 1.0 /* ERROR "shifted operand 1.0 \(type float64\) must be integer" */ <<s == 1.0
+       _ = 1 /* ERROR "shifted operand 1 \(type float64\) must be integer" */ <<s == 1.0
+       _ = 1 /* ERROR "shifted operand 1 \(type float64\) must be integer" */ <<s + 1.0 == 1
+       _ = 1 /* ERROR "shifted operand 1 \(type float64\) must be integer" */ <<s + 1.1 == 1
+       _ = 1 /* ERROR "shifted operand 1 \(type float64\) must be integer" */ <<s + 1 == 1.0
+
+       // additional cases
+       _ = complex(1.0 /* ERROR "shifted operand 1.0 \(type float64\) must be integer" */ <<s, 1)
+       _ = complex(1.0, 1 /* ERROR "shifted operand 1 \(type float64\) must be integer" */ <<s)
+
+       _ = int(1.<<s)
+       _ = int(1.1 /* ERROR "shifted operand .* must be integer" */ <<s)
+       _ = float32(1 /* ERROR "shifted operand .* must be integer" */ <<s)
+       _ = float32(1. /* ERROR "shifted operand .* must be integer" */ <<s)
+       _ = float32(1.1 /* ERROR "shifted operand .* must be integer" */ <<s)
+       // TODO(gri) the error messages for these two are incorrect - disabled for now
+       // _ = complex64(1<<s)
+       // _ = complex64(1.<<s)
+       _ = complex64(1.1 /* ERROR "shifted operand .* must be integer" */ <<s)
+}
+
+func shifts9() {
+       // various originally failing snippets of code from the std library
+       // from src/compress/lzw/reader.go:90
+       {
+               var d struct {
+                       bits     uint32
+                       width    uint
+               }
+               _ = uint16(d.bits & (1<<d.width - 1))
+       }
+
+       // from src/debug/dwarf/buf.go:116
+       {
+               var ux uint64
+               var bits uint
+               x := int64(ux)
+               if x&(1<<(bits-1)) != 0 {}
+       }
+
+       // from src/encoding/asn1/asn1.go:160
+       {
+               var bytes []byte
+               if bytes[len(bytes)-1]&((1<<bytes[0])-1) != 0 {}
+       }
+
+       // from src/math/big/rat.go:140
+       {
+               var exp int
+               var mantissa uint64
+               shift := uint64(-1022 - (exp - 1)) // [1..53)
+               _ = mantissa & (1<<shift - 1)
+       }
+
+       // from src/net/interface.go:51
+       {
+               type Flags uint
+               var f Flags
+               var i int
+               if f&(1<<uint(i)) != 0 {}
+       }
+
+       // from src/runtime/softfloat64.go:234
+       {
+               var gm uint64
+               var shift uint
+               _ = gm & (1<<shift - 1)
+       }
+
+       // from src/strconv/atof.go:326
+       {
+               var mant uint64
+               var mantbits uint
+               if mant == 2<<mantbits {}
+       }
+
+       // from src/route_bsd.go:82
+       {
+               var Addrs int32
+               const rtaRtMask = 1
+               var i uint
+               if Addrs&rtaRtMask&(1<<i) == 0 {}
+       }
+
+       // from src/text/scanner/scanner.go:540
+       {
+               var s struct { Whitespace uint64 }
+               var ch rune
+               for s.Whitespace&(1<<uint(ch)) != 0 {}
+       }
+}
+
+func issue5895() {
+       var x = 'a' << 1 // type of x must be rune
+       var _ rune = x
+}
+
+func issue11325() {
+       var _ = 0 >> 1.1 /* ERROR "must be unsigned integer" */ // example from issue 11325
+       _ = 0 >> 1.1 /* ERROR "must be unsigned integer" */
+       _ = 0 << 1.1 /* ERROR "must be unsigned integer" */
+       _ = 0 >> 1.
+       _ = 1 >> 1.1 /* ERROR "must be unsigned integer" */
+       _ = 1 >> 1.
+       _ = 1. >> 1
+       _ = 1. >> 1.
+       _ = 1.1 /* ERROR "must be integer" */ >> 1
+}
+
+func issue11594() {
+       var _ = complex64 /* ERROR "must be integer" */ (1) << 2 // example from issue 11594
+       _ = float32 /* ERROR "must be integer" */ (0) << 1
+       _ = float64 /* ERROR "must be integer" */ (0) >> 2
+       _ = complex64 /* ERROR "must be integer" */ (0) << 3
+       _ = complex64 /* ERROR "must be integer" */ (0) >> 4
+}
diff --git a/libgo/go/go/types/testdata/stmt0.src b/libgo/go/go/types/testdata/stmt0.src
new file mode 100644 (file)
index 0000000..87f08e4
--- /dev/null
@@ -0,0 +1,980 @@
+// 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.
+
+// statements
+
+package stmt0
+
+func assignments0() (int, int) {
+       var a, b, c int
+       var ch chan int
+       f0 := func() {}
+       f1 := func() int { return 1 }
+       f2 := func() (int, int) { return 1, 2 }
+       f3 := func() (int, int, int) { return 1, 2, 3 }
+
+       a, b, c = 1, 2, 3
+       a, b, c = 1 /* ERROR "assignment count mismatch" */ , 2
+       a, b, c = 1 /* ERROR "assignment count mismatch" */ , 2, 3, 4
+       _, _, _ = a, b, c
+
+       a = f0 /* ERROR "used as value" */ ()
+       a = f1()
+       a = f2 /* ERROR "assignment count mismatch" */ ()
+       a, b = f2()
+       a, b, c = f2 /* ERROR "assignment count mismatch" */ ()
+       a, b, c = f3()
+       a, b = f3 /* ERROR "assignment count mismatch" */ ()
+
+       a, b, c = <- /* ERROR "assignment count mismatch" */ ch
+
+       return /* ERROR "wrong number of return values" */
+       return /* ERROR "wrong number of return values" */ 1
+       return 1, 2
+       return /* ERROR "wrong number of return values" */ 1, 2, 3
+}
+
+func assignments1() {
+       b, i, f, c, s := false, 1, 1.0, 1i, "foo"
+       b = i /* ERROR "cannot use .* in assignment" */
+       i = f /* ERROR "cannot use .* in assignment" */
+       f = c /* ERROR "cannot use .* in assignment" */
+       c = s /* ERROR "cannot use .* in assignment" */
+       s = b /* ERROR "cannot use .* in assignment" */
+
+       v0, v1, v2 := 1 /* ERROR "mismatch" */ , 2, 3, 4
+       _, _, _ = v0, v1, v2
+
+       b = true
+
+       i += 1
+       i += "foo" /* ERROR "cannot convert.*int" */
+
+       f -= 1
+       f /= 0
+       f = float32(0)/0 /* ERROR "division by zero" */
+       f -= "foo" /* ERROR "cannot convert.*float64" */
+
+       c *= 1
+       c /= 0
+
+       s += "bar"
+       s += 1 /* ERROR "cannot convert.*string" */
+
+       var u64 uint64
+       u64 += 1<<u64
+
+       undeclared /* ERROR "undeclared" */ = 991
+
+       // test cases for issue 5800
+       var (
+               _ int = nil /* ERROR "untyped nil value" */
+               _ [10]int = nil /* ERROR "untyped nil value" */
+               _ []byte = nil
+               _ struct{} = nil /* ERROR "untyped nil value" */
+               _ func() = nil
+               _ map[int]string = nil
+               _ chan int = nil
+       )
+
+       // test cases for issue 5500
+       _ = func() (int, bool) {
+               var m map[int]int
+               return /* ERROR "wrong number of return values" */ m[0]
+       }
+
+       g := func(int, bool){}
+       var m map[int]int
+       g(m[0]) /* ERROR "too few arguments" */
+
+       // assignments to _
+       _ = nil /* ERROR "use of untyped nil" */
+       _ = 1 /* ERROR overflow */ <<1000
+       (_) = 0
+}
+
+func assignments2() {
+       type mybool bool
+       var m map[string][]bool
+       var s []bool
+       var b bool
+       var d mybool
+       _ = s
+       _ = b
+       _ = d
+
+       // assignments to map index expressions are ok
+       s, b = m["foo"]
+       _, d = m["bar"]
+       m["foo"] = nil
+       m["foo"] = nil /* ERROR assignment count mismatch */ , false
+       _ = append(m["foo"])
+       _ = append(m["foo"], true)
+
+       var c chan int
+       _, b = <-c
+       _, d = <-c
+       <- /* ERROR cannot assign */ c = 0
+       <-c = 0 /* ERROR assignment count mismatch */ , false
+
+       var x interface{}
+       _, b = x.(int)
+       x /* ERROR cannot assign */ .(int) = 0
+       x.(int) = 0 /* ERROR assignment count mismatch */ , false
+
+       assignments2 /* ERROR used as value */ () = nil
+       int /* ERROR not an expression */ = 0
+}
+
+func issue6487() {
+       type S struct{x int}
+       _ = &S /* ERROR "cannot take address" */ {}.x
+       _ = &( /* ERROR "cannot take address" */ S{}.x)
+       _ = (&S{}).x
+       S /* ERROR "cannot assign" */ {}.x = 0
+       (&S{}).x = 0
+
+       type M map[string]S
+       var m M
+       m /* ERROR "cannot assign to struct field" */ ["foo"].x = 0
+       _ = &( /* ERROR "cannot take address" */ m["foo"].x)
+       _ = &m /* ERROR "cannot take address" */ ["foo"].x
+}
+
+func issue6766a() {
+       a, a /* ERROR redeclared */ := 1, 2
+       _ = a
+       a, b, b /* ERROR redeclared */ := 1, 2, 3
+       _ = b
+       c, c /* ERROR redeclared */, b := 1, 2, 3
+       _ = c
+       a, b := /* ERROR no new variables */ 1, 2
+}
+
+func shortVarDecls1() {
+       const c = 0
+       type d int
+       a, b, c /* ERROR "cannot assign" */ , d /* ERROR "cannot assign" */  := 1, "zwei", 3.0, 4
+       var _ int = a // a is of type int
+       var _ string = b // b is of type string
+}
+
+func incdecs() {
+       const c = 3.14
+       c /* ERROR "cannot assign" */ ++
+       s := "foo"
+       s /* ERROR "invalid operation" */ --
+       3.14 /* ERROR "cannot assign" */ ++
+       var (
+               x int
+               y float32
+               z complex128
+       )
+       x++
+       y--
+       z++
+}
+
+func sends() {
+       var ch chan int
+       var rch <-chan int
+       var x int
+       x <- /* ERROR "cannot send" */ x
+       rch <- /* ERROR "cannot send" */ x
+       ch <- "foo" /* ERROR "cannot convert" */
+       ch <- x
+}
+
+func selects() {
+       select {}
+       var (
+               ch chan int
+               sc chan <- bool
+       )
+       select {
+       case <-ch:
+       case (<-ch):
+       case t := <-ch:
+               _ = t
+       case t := (<-ch):
+               _ = t
+       case t, ok := <-ch:
+               _, _ = t, ok
+       case t, ok := (<-ch):
+               _, _ = t, ok
+       case <-sc /* ERROR "cannot receive from send-only channel" */ :
+       }
+       select {
+       default:
+       default /* ERROR "multiple defaults" */ :
+       }
+       select {
+       case a, b := <-ch:
+               _, b = a, b
+       case x /* ERROR send or receive */ :
+       case a /* ERROR send or receive */ := ch:
+       }
+
+       // test for issue 9570: ch2 in second case falsely resolved to
+       // ch2 declared in body of first case
+       ch1 := make(chan int)
+       ch2 := make(chan int)
+       select {
+       case <-ch1:
+               var ch2 /* ERROR ch2 declared but not used */ chan bool
+       case i := <-ch2:
+               print(i + 1)
+       }
+}
+
+func gos() {
+       go 1 /* ERROR HERE "function must be invoked" */
+       go int /* ERROR "go requires function call, not conversion" */ (0)
+       go gos()
+       var c chan int
+       go close(c)
+       go len /* ERROR "go discards result" */ (c)
+}
+
+func defers() {
+       defer 1 /* ERROR HERE "function must be invoked" */
+       defer int /* ERROR "defer requires function call, not conversion" */ (0)
+       defer defers()
+       var c chan int
+       defer close(c)
+       defer len /* ERROR "defer discards result" */ (c)
+}
+
+func breaks() {
+       var x, y int
+
+       break /* ERROR "break" */
+       {
+               break /* ERROR "break" */
+       }
+       if x < y {
+               break /* ERROR "break" */
+       }
+
+       switch x {
+       case 0:
+               break
+       case 1:
+               if x == y {
+                       break
+               }
+       default:
+               break
+               break
+       }
+
+       var z interface{}
+       switch z.(type) {
+       case int:
+               break
+       }
+
+       for {
+               break
+       }
+
+       var a []int
+       for _ = range a {
+               break
+       }
+
+       for {
+               if x == y {
+                       break
+               }
+       }
+
+       var ch chan int
+       select {
+       case <-ch:
+               break
+       }
+
+       select {
+       case <-ch:
+               if x == y {
+                       break
+               }
+       default:
+               break
+       }
+}
+
+func continues() {
+       var x, y int
+
+       continue /* ERROR "continue" */
+       {
+               continue /* ERROR "continue" */
+       }
+
+       if x < y {
+               continue /* ERROR "continue" */
+       }
+
+       switch x {
+       case 0:
+               continue /* ERROR "continue" */
+       }
+
+       var z interface{}
+       switch z.(type) {
+       case int:
+               continue /* ERROR "continue" */
+       }
+
+       var ch chan int
+       select {
+       case <-ch:
+               continue /* ERROR "continue" */
+       }
+
+       for i := 0; i < 10; i++ {
+               continue
+               if x < y {
+                       continue
+                       break
+               }
+               switch x {
+               case y:
+                       continue
+               default:
+                       break
+               }
+               select {
+               case <-ch:
+                       continue
+               }
+       }
+
+       var a []int
+       for _ = range a {
+               continue
+               if x < y {
+                       continue
+                       break
+               }
+               switch x {
+               case y:
+                       continue
+               default:
+                       break
+               }
+               select {
+               case <-ch:
+                       continue
+               }
+       }
+}
+
+func returns0() {
+       return
+       return 0 /* ERROR no result values expected */
+}
+
+func returns1(x float64) (int, *float64) {
+       return 0, &x
+       return /* ERROR wrong number of return values */
+       return "foo" /* ERROR "cannot convert" */, x /* ERROR "cannot use .* in return statement" */
+       return /* ERROR wrong number of return values */ 0, &x, 1
+}
+
+func returns2() (a, b int) {
+       return
+       return 1, "foo" /* ERROR cannot convert */
+       return /* ERROR wrong number of return values */ 1, 2, 3
+       {
+               type a int
+               return 1, 2
+               return /* ERROR a not in scope at return */
+       }
+}
+
+func returns3() (_ int) {
+       return
+       {
+               var _ int // blank (_) identifiers never shadow since they are in no scope
+               return
+       }
+}
+
+func switches0() {
+       var x int
+
+       switch x {
+       }
+
+       switch x {
+       default:
+       default /* ERROR "multiple defaults" */ :
+       }
+
+       switch {
+       case 1  /* ERROR "cannot convert" */ :
+       }
+
+       true := "false"
+       _ = true
+       // A tagless switch is equivalent to the bool
+        // constant true, not the identifier 'true'.
+       switch {
+       case "false" /* ERROR "cannot convert" */:
+       }
+
+       switch int32(x) {
+       case 1, 2:
+       case x /* ERROR "cannot compare" */ :
+       }
+
+       switch x {
+       case 1 /* ERROR "overflows" */ << 100:
+       }
+
+       switch x {
+       case 1:
+       case 1 /* ERROR "duplicate case" */ :
+       case ( /* ERROR "duplicate case" */ 1):
+       case 2, 3, 4:
+       case 5, 1 /* ERROR "duplicate case" */ :
+       }
+
+       switch uint64(x) {
+       case 1<<64 - 1:
+       case 1 /* ERROR duplicate case */ <<64 - 1:
+       case 2, 3, 4:
+       case 5, 1 /* ERROR duplicate case */ <<64 - 1:
+       }
+
+       var y32 float32
+       switch y32 {
+       case 1.1:
+       case 11/10: // integer division!
+       case 11. /* ERROR duplicate case */ /10:
+       case 2, 3.0, 4.1:
+       case 5.2, 1.10 /* ERROR duplicate case */ :
+       }
+
+       var y64 float64
+       switch y64 {
+       case 1.1:
+       case 11/10: // integer division!
+       case 11. /* ERROR duplicate case */ /10:
+       case 2, 3.0, 4.1:
+       case 5.2, 1.10 /* ERROR duplicate case */ :
+       }
+
+       var s string
+       switch s {
+       case "foo":
+       case "foo" /* ERROR duplicate case */ :
+       case "f" /* ERROR duplicate case */ + "oo":
+       case "abc", "def", "ghi":
+       case "jkl", "foo" /* ERROR duplicate case */ :
+       }
+
+       type T int
+       type F float64
+       type S string
+       type B bool
+       var i interface{}
+       switch i {
+       case nil:
+       case nil: // no duplicate detection
+       case (*int)(nil):
+       case (*int)(nil): // do duplicate detection
+       case 1:
+       case byte(1):
+       case int /* ERROR duplicate case */ (1):
+       case T(1):
+       case 1.0:
+       case F(1.0):
+       case F /* ERROR duplicate case */ (1.0):
+       case "hello":
+       case S("hello"):
+       case S /* ERROR duplicate case */ ("hello"):
+       case 1==1, B(false):
+       case false, B(2==2):
+       }
+
+       // switch on array
+       var a [3]int
+       switch a {
+       case [3]int{1, 2, 3}:
+       case [3]int{1, 2, 3}: // no duplicate detection
+       case [ /* ERROR "mismatched types */ 4]int{4, 5, 6}:
+       }
+
+       // switch on channel
+       var c1, c2 chan int
+       switch c1 {
+       case nil:
+       case c1:
+       case c2:
+       case c1, c2: // no duplicate detection
+       }
+}
+
+func switches1() {
+       fallthrough /* ERROR "fallthrough statement out of place" */
+
+       var x int
+       switch x {
+       case 0:
+               fallthrough /* ERROR "fallthrough statement out of place" */
+               break
+       case 1:
+               fallthrough
+       case 2:
+               fallthrough; ; ; // trailing empty statements are ok
+       case 3:
+       default:
+               fallthrough; ;
+       case 4:
+               fallthrough /* ERROR "cannot fallthrough final case in switch" */
+       }
+
+       var y interface{}
+       switch y.(type) {
+       case int:
+               fallthrough /* ERROR "fallthrough statement out of place" */ ; ; ;
+       default:
+       }
+
+       switch x {
+       case 0:
+               if x == 0 {
+                       fallthrough /* ERROR "fallthrough statement out of place" */
+               }
+       }
+
+       switch x {
+       case 0:
+               goto L1
+               L1: fallthrough; ;
+       case 1:
+               goto L2
+               goto L3
+               goto L4
+               L2: L3: L4: fallthrough
+       default:
+       }
+
+       switch x {
+       case 0:
+               goto L5
+               L5: fallthrough
+       default:
+               goto L6
+               goto L7
+               goto L8
+               L6: L7: L8: fallthrough /* ERROR "cannot fallthrough final case in switch" */
+       }
+
+       switch x {
+       case 0:
+               fallthrough; ;
+       case 1:
+               {
+                       fallthrough /* ERROR "fallthrough statement out of place" */
+               }
+       case 2:
+               fallthrough
+       case 3:
+               fallthrough /* ERROR "fallthrough statement out of place" */
+               { /* empty block is not an empty statement */ }; ;
+       default:
+               fallthrough /* ERROR "cannot fallthrough final case in switch" */
+       }
+
+       switch x {
+       case 0:
+               {
+                       fallthrough /* ERROR "fallthrough statement out of place" */
+               }
+       }
+}
+
+func switches2() {
+       // untyped nil is not permitted as switch expression
+       switch nil /* ERROR "use of untyped nil" */ {
+       case 1, 2, "foo": // don't report additional errors here
+       }
+
+       // untyped constants are converted to default types
+       switch 1<<63-1 {
+       }
+       switch 1 /* ERROR "overflows int" */ << 63 {
+       }
+       var x int
+       switch 1.0 {
+       case 1.0, 2.0, x /* ERROR "mismatched types int and float64" */ :
+       }
+       switch x {
+       case 1.0:
+       }
+
+       // untyped bools become of type bool
+       type B bool
+       var b B = true
+       switch x == x {
+       case b /* ERROR "mismatched types B and bool" */ :
+       }
+       switch {
+       case b /* ERROR "mismatched types B and bool" */ :
+       }
+}
+
+func issue11667() {
+       switch 9223372036854775808 /* ERROR "overflows int" */ {
+       }
+       switch 9223372036854775808 /* ERROR "overflows int" */ {
+       case 9223372036854775808:
+       }
+       var x int
+       switch x {
+       case 9223372036854775808 /* ERROR "overflows int" */ :
+       }
+       var y float64
+       switch y {
+       case 9223372036854775808:
+       }
+}
+
+func issue11687() {
+       f := func() (_, _ int) { return }
+       switch f /* ERROR "2-valued f" */ () {
+       }
+       var x int
+       switch f /* ERROR "2-valued f" */ () {
+       case x:
+       }
+       switch x {
+       case f /* ERROR "2-valued f" */ ():
+       }
+}
+
+type I interface {
+       m()
+}
+
+type I2 interface {
+       m(int)
+}
+
+type T struct{}
+type T1 struct{}
+type T2 struct{}
+
+func (T) m() {}
+func (T2) m(int) {}
+
+func typeswitches() {
+       var i int
+       var x interface{}
+
+       switch x.(type) {}
+       switch (x /* ERROR "outside type switch" */ .(type)) {}
+
+       switch x.(type) {
+       default:
+       default /* ERROR "multiple defaults" */ :
+       }
+
+       switch x /* ERROR "declared but not used" */ := x.(type) {}
+       switch _ /* ERROR "no new variable on left side of :=" */ := x.(type) {}
+
+       switch x := x.(type) {
+       case int:
+               var y int = x
+               _ = y
+       }
+
+       switch x := i /* ERROR "not an interface" */ .(type) {}
+
+       switch t := x.(type) {
+       case nil:
+               var v bool = t /* ERROR "cannot use .* in variable declaration" */
+               _ = v
+       case int:
+               var v int = t
+               _ = v
+       case float32, complex64:
+               var v float32 = t /* ERROR "cannot use .* in variable declaration" */
+               _ = v
+       default:
+               var v float32 = t /* ERROR "cannot use .* in variable declaration" */
+               _ = v
+       }
+
+       var t I
+       switch t.(type) {
+       case T:
+       case T1 /* ERROR "missing method m" */ :
+       case T2 /* ERROR "wrong type for method m" */ :
+       case I2 /* STRICT "wrong type for method m" */ : // only an error in strict mode (issue 8561)
+       }
+}
+
+// Test that each case clause uses the correct type of the variable
+// declared by the type switch (issue 5504).
+func typeswitch0() {
+       switch y := interface{}(nil).(type) {
+       case int:
+               func() int { return y + 0 }()
+       case float32:
+               func() float32 { return y }()
+       }
+}
+
+// Test correct scope setup.
+// (no redeclaration errors expected in the type switch)
+func typeswitch1() {
+       var t I
+       switch t := t; t := t.(type) {
+       case nil:
+               var _ I = t
+       case T:
+               var _ T = t
+       default:
+               var _ I = t
+       }
+}
+
+// Test correct typeswitch against interface types.
+type A interface { a() }
+type B interface { b() }
+type C interface { a(int) }
+
+func typeswitch2() {
+       switch A(nil).(type) {
+       case A:
+       case B:
+       case C /* STRICT "cannot have dynamic type" */: // only an error in strict mode (issue 8561)
+       }
+}
+
+func typeswitch3(x interface{}) {
+       switch x.(type) {
+       case int:
+       case float64:
+       case int /* ERROR duplicate case */ :
+       }
+
+       switch x.(type) {
+       case nil:
+       case int:
+       case nil /* ERROR duplicate case */ , nil /* ERROR duplicate case */ :
+       }
+
+       type F func(int)
+       switch x.(type) {
+       case nil:
+       case int, func(int):
+       case float32, func /* ERROR duplicate case */ (x int):
+       case F:
+       }
+}
+
+func fors1() {
+       for {}
+       var i string
+       _ = i
+       for i := 0; i < 10; i++ {}
+       for i := 0; i < 10; j /* ERROR cannot declare */ := 0 {}
+}
+
+func rangeloops1() {
+       var (
+               x int
+               a [10]float32
+               b []string
+               p *[10]complex128
+               pp **[10]complex128
+               s string
+               m map[int]bool
+               c chan int
+               sc chan<- int
+               rc <-chan int
+       )
+
+       for range x /* ERROR "cannot range over" */ {}
+       for _ = range x /* ERROR "cannot range over" */ {}
+       for i := range x /* ERROR "cannot range over" */ {}
+
+       for range a {}
+       for i := range a {
+               var ii int
+               ii = i
+               _ = ii
+       }
+       for i, x := range a {
+               var ii int
+               ii = i
+               _ = ii
+               var xx float64
+               xx = x /* ERROR "cannot use .* in assignment" */
+               _ = xx
+       }
+       var ii int
+       var xx float32
+       for ii, xx = range a {}
+       _, _ = ii, xx
+
+       for range b {}
+       for i := range b {
+               var ii int
+               ii = i
+               _ = ii
+       }
+       for i, x := range b {
+               var ii int
+               ii = i
+               _ = ii
+               var xx string
+               xx = x
+               _ = xx
+       }
+
+       for range s {}
+       for i := range s {
+               var ii int
+               ii = i
+               _ = ii
+       }
+       for i, x := range s {
+               var ii int
+               ii = i
+               _ = ii
+               var xx rune
+               xx = x
+               _ = xx
+       }
+
+       for range p {}
+       for _, x := range p {
+               var xx complex128
+               xx = x
+               _ = xx
+       }
+
+       for range pp /* ERROR "cannot range over" */ {}
+       for _, x := range pp /* ERROR "cannot range over" */ {}
+
+       for range m {}
+       for k := range m {
+               var kk int32
+               kk = k /* ERROR "cannot use .* in assignment" */
+               _ = kk
+       }
+       for k, v := range m {
+               var kk int
+               kk = k
+               _ = kk
+               if v {}
+       }
+
+       for range c {}
+       for _, _ /* ERROR "only one iteration variable" */ = range c {}
+       for e := range c {
+               var ee int
+               ee = e
+               _ = ee
+       }
+       for _ = range sc /* ERROR "cannot range over send-only channel" */ {}
+       for _ = range rc {}
+
+       // constant strings
+       const cs = "foo"
+       for range cs {}
+       for range "" {}
+       for i, x := range cs { _, _ = i, x }
+       for i, x := range "" {
+               var ii int
+               ii = i
+               _ = ii
+               var xx rune
+               xx = x
+               _ = xx
+       }
+}
+
+func rangeloops2() {
+       type I int
+       type R rune
+
+       var a [10]int
+       var i I
+       _ = i
+       for i /* ERROR cannot use .* in assignment */ = range a {}
+       for i /* ERROR cannot use .* in assignment */ = range &a {}
+       for i /* ERROR cannot use .* in assignment */ = range a[:] {}
+
+       var s string
+       var r R
+       _ = r
+       for i /* ERROR cannot use .* in assignment */ = range s {}
+       for i /* ERROR cannot use .* in assignment */ = range "foo" {}
+       for _, r /* ERROR cannot use .* in assignment */ = range s {}
+       for _, r /* ERROR cannot use .* in assignment */ = range "foo" {}
+}
+
+func issue6766b() {
+       for _ := /* ERROR no new variables */ range "" {}
+       for a, a /* ERROR redeclared */ := range "" { _ = a }
+       var a int
+       _ = a
+       for a, a /* ERROR redeclared */ := range []int{1, 2, 3} { _ = a }
+}
+
+// Test that despite errors in the range clause,
+// the loop body is still type-checked (and thus
+// errors reported).
+func issue10148() {
+       for y /* ERROR declared but not used */ := range "" {
+               _ = "" /* ERROR cannot convert */ + 1
+       }
+       for range 1 /* ERROR cannot range over 1 */ {
+               _ = "" /* ERROR cannot convert */ + 1
+       }
+       for y := range 1 /* ERROR cannot range over 1 */ {
+               _ = "" /* ERROR cannot convert */ + 1
+       }
+}
+
+func labels0() {
+       goto L0
+       goto L1
+       L0:
+       L1:
+       L1 /* ERROR "already declared" */ :
+       if true {
+               goto L2
+               L2:
+               L0 /* ERROR "already declared" */ :
+       }
+       _ = func() {
+               goto L0
+               goto L1
+               goto L2
+               L0:
+               L1:
+               L2:
+       }
+}
+
+func expression_statements(ch chan int) {
+       expression_statements(ch)
+       <-ch
+       println()
+
+       0 /* ERROR "not used" */
+       1 /* ERROR "not used" */ +2
+       cap /* ERROR "not used" */ (ch)
+       println /* ERROR "must be called" */
+}
diff --git a/libgo/go/go/types/testdata/stmt1.src b/libgo/go/go/types/testdata/stmt1.src
new file mode 100644 (file)
index 0000000..24ad6eb
--- /dev/null
@@ -0,0 +1,241 @@
+// 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.
+
+// terminating statements
+
+package stmt1
+
+func _() {}
+
+func _() int {} /* ERROR "missing return" */
+
+func _() int { panic(0) }
+func _() int { (panic(0)) }
+
+// block statements
+func _(x, y int) (z int) {
+       {
+               return
+       }
+}
+
+func _(x, y int) (z int) {
+       {
+               return; ; ; // trailing empty statements are ok
+       }
+       ; ; ;
+}
+
+func _(x, y int) (z int) {
+       {
+       }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       {
+               ; ; ;
+       }
+       ; ; ;
+} /* ERROR "missing return" */
+
+// if statements
+func _(x, y int) (z int) {
+       if x < y { return }
+       return 1
+}
+
+func _(x, y int) (z int) {
+       if x < y { return; ; ; ; }
+       return 1
+}
+
+func _(x, y int) (z int) {
+       if x < y { return }
+       return 1; ;
+}
+
+func _(x, y int) (z int) {
+       if x < y { return }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       if x < y {
+       } else { return 1
+       }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       if x < y { return
+       } else { return
+       }
+}
+
+// for statements
+func _(x, y int) (z int) {
+       for x < y {
+               return
+       }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       for {
+               return
+       }
+}
+
+func _(x, y int) (z int) {
+       for {
+               return; ; ; ;
+       }
+}
+
+func _(x, y int) (z int) {
+       for {
+               return
+               break
+       }
+       ; ; ;
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       for {
+               for { break }
+               return
+       }
+}
+
+func _(x, y int) (z int) {
+       for {
+               for { break }
+               return ; ;
+       }
+       ;
+}
+
+func _(x, y int) (z int) {
+L:     for {
+               for { break L }
+               return
+       }
+} /* ERROR "missing return" */
+
+// switch statements
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return
+       default: return
+       }
+}
+
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return;
+       default: return; ; ;
+       }
+}
+
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return
+       }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return
+       case 1: break
+       }
+} /* ERROR "missing return" */
+
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return
+       default:
+               switch y {
+               case 0: break
+               }
+               panic(0)
+       }
+}
+
+func _(x, y int) (z int) {
+       switch x {
+       case 0: return
+       default:
+               switch y {
+               case 0: break
+               }
+               panic(0); ; ;
+       }
+       ;
+}
+
+func _(x, y int) (z int) {
+L:     switch x {
+       case 0: return
+       default:
+               switch y {
+               case 0: break L
+               }
+               panic(0)
+       }
+} /* ERROR "missing return" */
+
+// select statements
+func _(ch chan int) (z int) {
+       select {}
+} // nice!
+
+func _(ch chan int) (z int) {
+       select {}
+       ; ;
+}
+
+func _(ch chan int) (z int) {
+       select {
+       default: break
+       }
+} /* ERROR "missing return" */
+
+func _(ch chan int) (z int) {
+       select {
+       case <-ch: return
+       default: break
+       }
+} /* ERROR "missing return" */
+
+func _(ch chan int) (z int) {
+       select {
+       case <-ch: return
+       default:
+               for i := 0; i < 10; i++ {
+                       break
+               }
+               return
+       }
+}
+
+func _(ch chan int) (z int) {
+       select {
+       case <-ch: return; ; ;
+       default:
+               for i := 0; i < 10; i++ {
+                       break
+               }
+               return; ; ;
+       }
+       ; ; ;
+}
+
+func _(ch chan int) (z int) {
+L:     select {
+       case <-ch: return
+       default:
+               for i := 0; i < 10; i++ {
+                       break L
+               }
+               return
+       }
+       ; ; ;
+} /* ERROR "missing return" */
diff --git a/libgo/go/go/types/testdata/vardecl.src b/libgo/go/go/types/testdata/vardecl.src
new file mode 100644 (file)
index 0000000..0082537
--- /dev/null
@@ -0,0 +1,186 @@
+// 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 vardecl
+
+// Prerequisites.
+import "math"
+func f() {}
+func g() (x, y int) { return }
+var m map[string]int
+
+// Var decls must have a type or an initializer.
+var _ int
+var _, _ int
+
+// The first error message is produced by the parser.
+// In a real-world scenario, the type-checker would not be run
+// in this case and the 2nd error message would not appear.
+var _ /* ERROR "missing variable type" */ /* ERROR "missing type or init expr" */
+var _ /* ERROR "missing variable type" */ /* ERROR "missing type or init expr" */, _
+var _ /* ERROR "missing variable type" */ /* ERROR "missing type or init expr" */, _, _
+
+// The initializer must be an expression.
+var _ = int /* ERROR "not an expression" */
+var _ = f /* ERROR "used as value" */ ()
+
+// Identifier and expression arity must match.
+var _, _ = 1, 2
+var _ = 1, 2 /* ERROR "extra init expr 2" */
+var _, _ = 1 /* ERROR "assignment count mismatch" */
+var _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
+
+var _ = g /* ERROR "2-valued g" */ ()
+var _, _ = g()
+var _, _, _ = g /* ERROR "assignment count mismatch" */ ()
+
+var _ = m["foo"]
+var _, _ = m["foo"]
+var _, _, _ = m  /* ERROR "assignment count mismatch" */ ["foo"]
+
+var _, _ int = 1, 2
+var _ int = 1, 2 /* ERROR "extra init expr 2" */
+var _, _ int = 1 /* ERROR "assignment count mismatch" */
+var _, _, _ /* ERROR "missing init expr for _" */ int = 1, 2
+
+var (
+       _, _ = 1, 2
+       _ = 1, 2 /* ERROR "extra init expr 2" */
+       _, _ = 1 /* ERROR "assignment count mismatch" */
+       _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
+
+       _ = g /* ERROR "2-valued g" */ ()
+       _, _ = g()
+       _, _, _ = g /* ERROR "assignment count mismatch" */ ()
+
+       _ = m["foo"]
+       _, _ = m["foo"]
+       _, _, _ = m /* ERROR "assignment count mismatch" */ ["foo"]
+
+       _, _ int = 1, 2
+       _ int = 1, 2 /* ERROR "extra init expr 2" */
+       _, _ int = 1 /* ERROR "assignment count mismatch" */
+       _, _, _ /* ERROR "missing init expr for _" */ int = 1, 2
+)
+
+// Variables declared in function bodies must be 'used'.
+type T struct{}
+func (r T) _(a, b, c int) (u, v, w int) {
+       var x1 /* ERROR "declared but not used" */ int
+       var x2 /* ERROR "declared but not used" */ int
+       x1 = 1
+       (x2) = 2
+
+       y1 /* ERROR "declared but not used" */ := 1
+       y2 /* ERROR "declared but not used" */ := 2
+       y1 = 1
+       (y1) = 2
+
+       {
+               var x1 /* ERROR "declared but not used" */ int
+               var x2 /* ERROR "declared but not used" */ int
+               x1 = 1
+               (x2) = 2
+
+               y1 /* ERROR "declared but not used" */ := 1
+               y2 /* ERROR "declared but not used" */ := 2
+               y1 = 1
+               (y1) = 2
+       }
+
+       if x /* ERROR "declared but not used" */ := 0; a < b {}
+
+       switch x /* ERROR "declared but not used" */, y := 0, 1; a {
+       case 0:
+               _ = y
+       case 1:
+               x /* ERROR "declared but not used" */ := 0
+       }
+
+       var t interface{}
+       switch t /* ERROR "declared but not used" */ := t.(type) {}
+
+       switch t /* ERROR "declared but not used" */ := t.(type) {
+       case int:
+       }
+
+       switch t /* ERROR "declared but not used" */ := t.(type) {
+       case int:
+       case float32, complex64:
+               t = nil
+       }
+
+       switch t := t.(type) {
+       case int:
+       case float32, complex64:
+               _ = t
+       }
+
+       switch t := t.(type) {
+       case int:
+       case float32:
+       case string:
+               _ = func() string {
+                       return t
+               }
+       }
+
+       switch t := t; t /* ERROR "declared but not used" */ := t.(type) {}
+
+       var z1 /* ERROR "declared but not used" */ int
+       var z2 int
+       _ = func(a, b, c int) (u, v, w int) {
+               z1 = a
+               (z1) = b
+               a = z2
+               return
+       }
+
+       var s []int
+       var i /* ERROR "declared but not used" */ , j int
+       for i, j = range s {
+               _ = j
+       }
+
+       for i, j /* ERROR "declared but not used" */ := range s {
+               _ = func() int {
+                       return i
+               }
+       }
+       return
+}
+
+// Invalid (unused) expressions must not lead to spurious "declared but not used errors"
+func _() {
+       var a, b, c int
+       var x, y int
+       x, y = a /* ERROR assignment count mismatch */ , b, c
+       _ = x
+       _ = y
+}
+
+func _() {
+       var x int
+       return x /* ERROR no result values expected */
+       return math /* ERROR no result values expected */ .Sin(0)
+}
+
+func _() int {
+       var x, y int
+       return /* ERROR wrong number of return values */ x, y
+}
+
+// Short variable declarations must declare at least one new non-blank variable.
+func _() {
+       _ := /* ERROR no new variables */ 0
+       _, a := 0, 1
+       _, a := /* ERROR no new variables */ 0, 1
+       _, a, b := 0, 1, 2
+       _, _, _ := /* ERROR no new variables */ 0, 1, 2
+
+       _ = a
+       _ = b
+}
+
+// TODO(gri) consolidate other var decl checks in this file
\ No newline at end of file
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g01.png b/libgo/go/image/png/testdata/pngsuite/ftbbn0g01.png
new file mode 100644 (file)
index 0000000..ba746ff
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbbn0g01.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g01.sng b/libgo/go/image/png/testdata/pngsuite/ftbbn0g01.sng
new file mode 100644 (file)
index 0000000..c5347a4
--- /dev/null
@@ -0,0 +1,44 @@
+#SNG: from ftbbn0g01.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using grayscale;
+}
+bKGD {gray: 0;}
+tRNS {
+    gray: 0;
+}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+00ffffffffffffff000000000000000000000000000000000000000000000000
+00ffffffffffffffff0000000000000000000000000000000000000000000000
+00ffffffffffffffffff00000000000000000000000000000000000000000000
+00ffffff0000ffffffff00000000000000000000000000000000000000000000
+00ffffff000000ffffff00000000000000000000000000000000000000000000
+00ffffff000000ffffff00ffffff000000ffffff000000000000000000000000
+00ffffff00ffffffffff00ffffff000000ffffff000000000000000000000000
+00ffffffffffffffffff00ffffffff0000ffffff000000000000000000000000
+00ffffffffffffffff0000ffffffff0000ffffff000000000000000000000000
+00ffffffffff0000000000ffffffffff00ffffff000000000000000000000000
+00ffffff00000000000000ffffffffff00ffffff0000000000ffffffffff0000
+00ffffff00000000000000ffffffffffffffffff000000ffffffffffffffff00
+00ffffff00000000000000ffffffffffffffffff000000ffffffffffffffff00
+00ffffff00000000000000ffffffffffffffffff0000ffffffffff00ffffff00
+0000000000000000000000ffffff00ffffffffff0000ffffffff000000000000
+0000000000000000000000ffffff00ffffffffff0000ffffff00000000000000
+0000000000000000000000ffffff0000ffffffff0000ffffff0000ffffff0000
+0000000000000000000000ffffff000000ffffff0000ffffff00ffffffffff00
+0000000000000000000000ffffff000000ffffff0000ffffff0000ffffffff00
+00000000000000000000000000000000000000000000ffffff00000000ffff00
+00000000000000000000000000000000000000000000ffffffff0000ffffff00
+00000000000000000000000000000000000000000000ffffffffffffffffff00
+0000000000000000000000000000000000000000000000ffffffffffffffff00
+000000000000000000000000000000000000000000000000ffffffffffff0000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g02.png b/libgo/go/image/png/testdata/pngsuite/ftbbn0g02.png
new file mode 100644 (file)
index 0000000..3d83bd6
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbbn0g02.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g02.sng b/libgo/go/image/png/testdata/pngsuite/ftbbn0g02.sng
new file mode 100644 (file)
index 0000000..9686a6a
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbbn0g02.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using grayscale;
+}
+gAMA {0.45455}
+bKGD {gray: 0;}
+tRNS {
+    gray: 0;
+}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+00aaaaaaaaaaaaaa000000000000000000000000000000000000000000000000
+00aaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000
+00aaaaaaaaaaaaaaaaaa00000000000000000000000000000000000000000000
+00aaaaaa0000aaaaaaaa00000000000000000000000000000000000000000000
+00aaaaaa000000aaaaaa00000000000000000000000000000000000000000000
+00aaaaaa000000aaaaaa00aaaaaa000000aaaaaa000000000000000000000000
+00aaaaaa00aaaaaaaaaa00aaaaaa000000aaaaaa000000000000000000000000
+00aaaaaaaaaaaaaaaaaa00aaaaaaaa0000aaaaaa000000000000000000000000
+00aaaaaaaaaaaaaaaa0000aaaaaaaa0000aaaaaa000000000000000000000000
+00aaaaaaaaaa0000000000aaaaaaaaaa00aaaaaa000000000000000000000000
+00aaaaaa00000000000000aaaaaaaaaa00aaaaaa0000000000aaaaaaaaaa0000
+00aaaaaa00000000000000aaaaaaaaaaaaaaaaaa000000aaaaaaaaaaaaaaaa00
+00aaaaaa00000000000000aaaaaaaaaaaaaaaaaa000000aaaaaaaaaaaaaaaa00
+00aaaaaa00000000000000aaaaaaaaaaaaaaaaaa0000aaaaaaaaaa00aaaaaa00
+0000000000000000000000aaaaaa00aaaaaaaaaa0000aaaaaaaa000000000000
+0000000000000000000000aaaaaa00aaaaaaaaaa0000aaaaaa00000000000000
+0000000000000000000000aaaaaa0000aaaaaaaa0000aaaaaa0000aaaaaa0000
+0000000000000000000000aaaaaa000000aaaaaa0000aaaaaa00aaaaaaaaaa00
+0000000000000000000000aaaaaa000000aaaaaa0000aaaaaa0000aaaaaaaa00
+00000000000000000000000000000000000000000000aaaaaa00000000aaaa00
+00000000000000000000000000000000000000000000aaaaaaaa0000aaaaaa00
+00000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaa00
+0000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaa00
+000000000000000000000000000000000000000000000000aaaaaaaaaaaa0000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g04.png b/libgo/go/image/png/testdata/pngsuite/ftbbn0g04.png
new file mode 100644 (file)
index 0000000..39a7050
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbbn0g04.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn0g04.sng b/libgo/go/image/png/testdata/pngsuite/ftbbn0g04.sng
new file mode 100644 (file)
index 0000000..518ba6c
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbbn0g04.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using grayscale;
+}
+gAMA {1.0000}
+bKGD {gray: 0;}
+tRNS {
+    gray: 255;
+}
+IMAGE {
+    pixels hex
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffddcceeffffffffffffffffffffffffffffff
+ffffffffffffffffffffffeebb776655446699ddffffffffffffffffffffffff
+ffffffffffffffffeebb886666553322222222335599ccffffffffffffffffff
+ffffffffffeecc997766554433333322334422112222336699ccffffffffffff
+ffffffcc997777664433333333444433334444332233335566777799cceeffff
+ffffcc777777775533333344556655444444444444332266777777776699ffff
+ffffdd8888887766444466777777777766555555445566777777775555bbffff
+ffffee8888888888777777777777777777777777777777777766555544eeffff
+ffffff8866667788998888777777777777777777777777665555444455ffffff
+ffffff8866778888999999998877777777777777777755331111334488ffffff
+ffffff99667788889999999999998877777777776655221111111133aaffffff
+ffffff99666688888899997777999999887766555533221111001122ddffffff
+ffffffaa666677888899886666669999997755554422111122111144ffffffff
+ffffffbb666666888888777755669999997755552222113344223377ffffffff
+ffffffcc666655778877777755779999996655332211334422111199ffffffff
+ffffffdd6666446688557777557799999966552222113311111111ccffffffff
+ffffffee6666555588666677557799999966442211222211111122eeffffffff
+ffffffff6666555577775577557799999955332211332211111155ffffffffff
+ffffffff6666665566775577557799999955331111443311111188ffffffffff
+ffffffff88666655667755665577999988552211114433111111ccffffffffff
+ffffffffffaa66666666666655779999885522111133111122bbffffffffffff
+ffffffffffffcc6666666666557788998855221111111122ccffffffffffffff
+ffffffffffffffee886666665577888877553311111133ddffffffffffffffff
+ffffffffffffffffffaa666655778888775544221144eeffffffffffffffffff
+ffffffffffffffffffffcc77557788886655553377ffffffffffffffffffffff
+ffffffffffffffffffffffee9988888866555599ffffffffffffffffffffffff
+ffffffffffffffffffffffffffbb88886655bbffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffdd8866ccffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffeeddffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn2c16.png b/libgo/go/image/png/testdata/pngsuite/ftbbn2c16.png
new file mode 100644 (file)
index 0000000..dd3168e
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbbn2c16.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn2c16.sng b/libgo/go/image/png/testdata/pngsuite/ftbbn2c16.sng
new file mode 100644 (file)
index 0000000..76989fa
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbbn2c16.png
+IHDR {
+    width: 32; height: 32; bitdepth: 16;
+    using color;
+}
+gAMA {1.0000}
+bKGD {red: 0;  green: 0;  blue: 65535;}
+tRNS {
+    red: 65535; green: 65535; blue: 65535;
+}
+IMAGE {
+    pixels hex
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff e3e3e3e3e3e3 c9c9c9c9c9c9 f1f1f1f1f1f1 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff e8e8e8e8e8e8 b5b5b5b5b5b5 7e7e7e7e7e7e 656565656565 6e6e52525252 7e7e2e2e2e2e a6a643434343 c7c790909090 ebebdddddddd ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff eeeeeeeeeeee bfbfbfbfbfbf 898989898989 676767676767 6b6b5d5d5d5d 7a7a39393939 8a8a12121212 8d8d00010000 858500000000 777700000000 848400000000 9a9a01010101 a2a22d2d2d2d bfbf7d7d7d7d ddddd0d0d0d0 fcfcfcfcfcfc ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff f2f2f2f2f2f2 c4c4c4c4c4c4 959595959595 727272727272 6f6f6b6b6b6b 777744444444 87871e1e1e1e 959501010101 9f9f00010000 919100000000 808000010000 72720c0c0c0c 61612d2d2d2d 53530e0e0e0e 505000000000 595900010000 858500000000 929206060606 7a7a66666666 a0a0a0a0a0a0 cfcfcfcfcfcf f8f8f8f8f8f8 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff f7f7f7f7f7f7 cacacacacaca 9a9a9a9a9a9a 767676767676 737373737373 7c7c5d5d5d5d 87872e2e2e2e 939307070707 9e9e00010000 a9a900000000 b0b000000000 c9c900000000 cfcf00000000 b9b900010000 a2a201010101 8c8c19191919 85852a2a2a2a 7f7f13131313 818100010000 969600000000 8f8f00000000 6b6b53535353 6e6e6e6e6e6e 737373737373 767676767676 9b9b9b9b9b9b c4c4c4c4c4c4 eeeeeeeeeeee ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff cccccccccccc 7f7f7f7f7f7f 767676767676 757575757575 757575757575 96962f2f2f2f b8b800010000 b4b400000000 b6b600010000 adad0c0c0c0c 94943a3a3a3a 929250505050 b9b923232323 d6d602020202 e2e200010000 efef00000000 e7e700000000 dada00000000 cfcf00010000 baba00000000 7d7d01010101 6f6f6b6b6b6b 757575757575 757575757575 757575757575 757575757575 6a6a6a6a6a6a 9a9a9a9a9a9a ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff dcdcdcdcdcdc 858585858585 888888888888 848484848484 7b7b7b7b7b7b 858554545454 b7b713131313 a9a91d1d1d1d 8d8d4f4f4f4f 787875757575 777777777777 777777777777 777777777777 81816b6b6b6b aaaa41414141 d6d620202020 ecec10101010 e9e90c0c0c0c d0d012121212 a5a528282828 7b7b58585858 777777777777 777777777777 777777777777 707070707070 5c5c5c5c5c5c 525252525252 bdbdbdbdbdbd ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff eaeaeaeaeaea 848484848484 818181818181 858588888585 8e8e8e8e8e8e 898989898989 7f7f7f7f7f7f 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 767676767676 636363636363 545454545454 505050505050 4c4c4c4c4c4c e6e6e6e6e6e6 ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff f8f8f8f8f8f8 7f7f84847f7f 252597972525 0404a5a50404 3939a4a43939 8b8b94948b8b 939393939393 8f8f8f8f8f8f 838383838383 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7a7a7a7a7a7a 7a7a7a7a7a7a 797979797979 6a6a6a6a6a6a 575757575757 505050505050 4c4c4c4c4c4c 494949494949 595959595959 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 8a8a8a8a8a8a 0101b3b30101 0000c6c60001 0000f2f20000 5959b6b65959 929292929292 959595959595 979797979797 949494949494 878787878787 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 717171717171 5a5a5a5a6060 282828288585 040404049393 0c0c0c0c7878 282828285858 464646464a4a 828282828282 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 929292929292 0c0cabab0c0c 0000bdbd0001 0000f4f40000 2020dddd2020 919191919191 949494949494 979797979797 999999999999 9b9b9b9b9b9b 999999999999 8b8b8b8b8b8b 7f7f7f7f7f7f 7e7e7e7e7e7e 7e7e7e7e7e7e 7d7d7d7d7d7d 777777777777 626262626262 535353536060 12121212bebe 00010000cccc 000000009292 000000016969 000000006767 2a2a2a2a5555 acacacacacac ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 949494949494 1616a1a11616 0000b4b40001 0000e2e20000 0000f4f40000 7676a2a27676 939393939393 8d8d97978d8d 46469e9e4646 4646a7a74646 8e8e9e9e8e8e 9e9e9e9e9e9e 9c9c9c9c9c9c 8e8e8e8e8e8e 7e7e7e7e7e7e 6a6a6a6a6a6a 5a5a5a5a5a5a 575757575a5a 18181818cdcd 00010000f0f0 00000000a0a0 020202026060 010101013d3d 000100006161 1d1d1d1d5959 d6d6d6d6d6d6 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff a4a4a4a4a4a4 212198982121 0000aaaa0001 0000c8c80000 0000f4f40000 3b3bcaca3b3b 929292929292 4a4aacac4a4a 0001bcbc0000 0000a9a90000 2f2f9a9a2f2f 9d9d9d9d9d9d 9f9f9f9f9f9f a0a0a0a0a0a0 7a7a7a7a7a7a 5a5a5a5a5a5a 595959595959 31313131a1a1 00010000ffff 00000000c6c6 030303035b5b 191919192424 0c0c0c0c1515 0c0c0c0c5555 3b3b3b3b5353 fbfbfbfbfbfb ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff b6b6b6b6b6b6 2b2b8f8f2b2b 0000a2a20001 0000adad0000 0000ebeb0000 0707eded0707 898995958989 4343a7a74343 0001c9c90000 000099990000 383895953838 9c9c9c9c9c9c 9e9e9e9e9e9e 9f9f9f9f9f9f 747474747474 595959595959 505050506767 05050505f5f5 00010000f0f0 030303037070 383838384646 484848484848 161616163939 2b2b2b2b5555 727272727272 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff c7c7c7c7c7c7 343486863434 0000b1b10001 00008d8d0000 0000d2d20000 0000f3f30000 4c4c9b9b4c4c 3b3b9e9e3b3b 0001c7c70000 000098980000 3d3d94943d3d 9b9b9b9b9b9b 9d9d9d9d9d9d 9e9e9e9e9e9e 6e6e6e6e6e6e 595959595959 2b2b2b2badad 00000001ffff 00000000a6a6 252525255959 434343434f4f 161616167e7e 000000019f9f 010101018e8e 9c9c9c9ca1a1 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff d8d8d8d8d8d8 3e3e7d7d3e3e 0000b1b10001 00007b7b0000 0000b8b80000 0000f1f10000 17178b8b1717 3b3b9c9c3b3b 0001c6c60000 000097970000 3d3d93933d3d 9a9a9a9a9a9a 9b9b9b9b9b9b 9d9d9d9d9d9d 676767676767 575757575959 09090909eeee 00000001f0f0 040404046b6b 333333335a5a 070707079090 000000009e9e 000000017c7c 0d0d0d0d5d5d c7c7c7c7c7c7 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff eaeaeaeaeaea 474774744747 0000adad0001 000085850000 090998980909 0000dcdc0000 0000a7a70000 232398982323 0001c3c30000 000096960000 3f3f92923f3f 989898989898 9a9a9a9a9a9a 9c9c9c9c9c9c 616161616161 424242427f7f 00010000ffff 00000001b9b9 1a1a1a1a5d5d 161616164949 000000007b7b 000000006b6b 000000016b6b 1c1c1c1c5656 f4f4f4f4f4f4 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff fcfcfcfcfcfc 50506c6c5050 0000a9a90001 000095950000 2d2d77772d2d 0000c1c10000 0000c5c50000 010193930101 0001c1c10000 000090900000 4b4b91914b4b 979797979797 999999999999 9a9a9a9a9a9a 5a5a5a5a5a5a 2b2b2b2ba4a4 00010000f6f6 000000018686 2f2f2f2f5353 191919193030 020202026363 000000007373 000000019b9b 4d4d4d4d7070 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff 686873736868 0000a4a40001 0000a4a40000 3e3e65653e3e 1414a5a51414 0000d4d40000 00008b8b0001 0000bfbf0000 00008e8e0000 4a4a90904a4a 959595959595 979797979797 969696969696 575757575757 1a1a1a1ab5b5 00010000dede 000000016868 3f3f3f3f4b4b 2b2b2b2b2b2b 0c0c0c0c6d6d 00000000b3b3 000000016b6b 868686869292 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff 8c8c8c8c8c8c 05059e9e0505 0001b0b00000 343466663434 404085854040 0000caca0000 000097970001 0000bcbc0000 00008c8c0000 49498e8e4949 939393939393 959595959595 8f8f8f8f8f8f 565656565656 0f0f0f0fb7b7 00010000b9b9 030303036666 474747474747 2f2f2f2f6464 00010000a2a2 000000009d9d 090909095858 c5c5c5c5c5c5 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff fafafafafafa 9090b0b09090 343485853434 616164646161 63636a6a6363 0606afaf0606 0000aeae0001 0000b9b90000 00008b8b0000 53538d8d5353 919191919191 939393939393 898989898989 555555555555 0a0a0a0aa8a8 000100009d9d 070707076363 343434345c5c 040404049b9b 00010000b1b1 1a1a1a1a4d4d b5b5b5b5bbbb ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff d0d0d0d0d0d0 6d6d6d6d6d6d 656565656565 2d2d8f8f2d2d 0000b2b20001 0000b6b60000 000089890000 55558b8b5555 8f8f8f8f8f8f 919191919191 818181818181 555555555555 151515157e7e 000100008484 010101016565 010101018484 000100009191 1c1c1c1c6e6e cecececed0d0 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ecececececec 868686868686 585870705858 0000afaf0001 0000b3b30000 000088880000 535389895353 8d8d8d8d8d8d 8f8f8f8f8f8f 7a7a7a7a7a7a 545454545454 2c2c2c2c4949 020202026b6b 000000016464 000000006363 292929297474 dfdfdfdfe5e5 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff fcfcfcfcfcfc aaaaaaaaaaaa 212198982121 0001b0b00000 000086860000 575787875757 8b8b8b8b8b8b 8d8d8d8d8d8d 747474747474 535353535353 3d3d3d3d3d3d 1a1a1a1a2323 0d0d0d0d4343 474747477272 ededededefef ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff d1d1d6d6d1d1 38389b9b3838 2d2d77772d2d 7d7d81817d7d 888888888888 8b8b8b8b8b8b 6d6d6d6d6d6d 525252525252 4f4f4f4f4f4f 373737373737 777777777777 fafafafafafa ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff efefefefefef a0a0a0a0a0a0 838383838383 868686868686 888888888888 676767676767 515151515151 505050505050 a0a0a0a0a0a0 fdfdfdfdfdfd ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff fefefefefefe c0c0c0c0c0c0 858585858585 868686868686 616161616161 525252525252 b7b7b7b7b7b7 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff dededededede 909090909090 656565656565 cccccccccccc ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff f5f5f5f5f5f5 e3e3e3e3e3e3 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn3p08.png b/libgo/go/image/png/testdata/pngsuite/ftbbn3p08.png
new file mode 100644 (file)
index 0000000..0ede357
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbbn3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbbn3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftbbn3p08.sng
new file mode 100644 (file)
index 0000000..429d99b
--- /dev/null
@@ -0,0 +1,292 @@
+#SNG: from ftbbn3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+    (  0,  0,  0)     # rgb = (0x00,0x00,0x00) grey0
+}
+bKGD {index: 245}
+tRNS {
+ 0}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000e0ea66000000000000000000000000000000
+0000000000000000000000de02a336e43903f4f0000000000000000000000000
+000000000000000069ef1a358680062eb017b0ab7af459500000000000000000
+0000000000667c0ea9cc803979937917a03a878787b0e2ae8ae75c0000000000
+00005cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c690000
+00007823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e0000
+0000e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef0000
+00006c9f229d981a23282828282828282828282828282828a7b445c3c8de0000
+00005ca249d63d140f139f272727272727272727a5a528af44c3c8ce43000000
+0000009a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1000000
+000000965b58b53811940d0b090b1823a3a3252ab4d24c269957571088000000
+000000946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877000000
+00000088c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950000000
+00000002bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a900000000
+0000007b47636ec441b23d4edb3f09078bac4315f340ec855a82995f00000000
+00000059bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b00000000
+0000006cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086000000000
+00000050bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e60000000000
+00000000add6d6bf61c16f566eb20e0d924475bd578572c61e6d340000000000
+0000000016d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b0000000000
+00000000550c47b3365bd45d6f33110f1a4575cbf2c0521e0802000000000000
+000000000000e7ac36be625e7031131122455a0a2f0a99c6e700000000000000
+000000000000006a9e37d36270331613a545f181e53032e80000000000000000
+00000000000000005088c5d371311816a8464b7374ee89000000000000000000
+0000000000000000000077b654a29b18acc24a722a5500000000000000000000
+0000000000000000000000d78a9f9e9b3548c38ac90000000000000000000000
+00000000000000000000000000ef1f9e3cc20200000000000000000000000000
+0000000000000000000000000000e89736780000000000000000000000000000
+00000000000000000000000000000060e0000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbgn2c16.png b/libgo/go/image/png/testdata/pngsuite/ftbgn2c16.png
new file mode 100644 (file)
index 0000000..85cec39
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbgn2c16.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbgn2c16.sng b/libgo/go/image/png/testdata/pngsuite/ftbgn2c16.sng
new file mode 100644 (file)
index 0000000..0f5621d
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbgn2c16.png
+IHDR {
+    width: 32; height: 32; bitdepth: 16;
+    using color;
+}
+gAMA {1.0000}
+bKGD {red: 0;  green: 65535;  blue: 0;}
+tRNS {
+    red: 65535; green: 65535; blue: 65535;
+}
+IMAGE {
+    pixels hex
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff e3e3e3e3e3e3 c9c9c9c9c9c9 f1f1f1f1f1f1 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff e8e8e8e8e8e8 b5b5b5b5b5b5 7e7e7e7e7e7e 656565656565 6e6e52525252 7e7e2e2e2e2e a6a643434343 c7c790909090 ebebdddddddd ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff eeeeeeeeeeee bfbfbfbfbfbf 898989898989 676767676767 6b6b5d5d5d5d 7a7a39393939 8a8a12121212 8d8d00010000 858500000000 777700000000 848400000000 9a9a01010101 a2a22d2d2d2d bfbf7d7d7d7d ddddd0d0d0d0 fcfcfcfcfcfc ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff f2f2f2f2f2f2 c4c4c4c4c4c4 959595959595 727272727272 6f6f6b6b6b6b 777744444444 87871e1e1e1e 959501010101 9f9f00010000 919100000000 808000010000 72720c0c0c0c 61612d2d2d2d 53530e0e0e0e 505000000000 595900010000 858500000000 929206060606 7a7a66666666 a0a0a0a0a0a0 cfcfcfcfcfcf f8f8f8f8f8f8 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff f7f7f7f7f7f7 cacacacacaca 9a9a9a9a9a9a 767676767676 737373737373 7c7c5d5d5d5d 87872e2e2e2e 939307070707 9e9e00010000 a9a900000000 b0b000000000 c9c900000000 cfcf00000000 b9b900010000 a2a201010101 8c8c19191919 85852a2a2a2a 7f7f13131313 818100010000 969600000000 8f8f00000000 6b6b53535353 6e6e6e6e6e6e 737373737373 767676767676 9b9b9b9b9b9b c4c4c4c4c4c4 eeeeeeeeeeee ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff cccccccccccc 7f7f7f7f7f7f 767676767676 757575757575 757575757575 96962f2f2f2f b8b800010000 b4b400000000 b6b600010000 adad0c0c0c0c 94943a3a3a3a 929250505050 b9b923232323 d6d602020202 e2e200010000 efef00000000 e7e700000000 dada00000000 cfcf00010000 baba00000000 7d7d01010101 6f6f6b6b6b6b 757575757575 757575757575 757575757575 757575757575 6a6a6a6a6a6a 9a9a9a9a9a9a ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff dcdcdcdcdcdc 858585858585 888888888888 848484848484 7b7b7b7b7b7b 858554545454 b7b713131313 a9a91d1d1d1d 8d8d4f4f4f4f 787875757575 777777777777 777777777777 777777777777 81816b6b6b6b aaaa41414141 d6d620202020 ecec10101010 e9e90c0c0c0c d0d012121212 a5a528282828 7b7b58585858 777777777777 777777777777 777777777777 707070707070 5c5c5c5c5c5c 525252525252 bdbdbdbdbdbd ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff eaeaeaeaeaea 848484848484 818181818181 858588888585 8e8e8e8e8e8e 898989898989 7f7f7f7f7f7f 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 797979797979 767676767676 636363636363 545454545454 505050505050 4c4c4c4c4c4c e6e6e6e6e6e6 ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff f8f8f8f8f8f8 7f7f84847f7f 252597972525 0404a5a50404 3939a4a43939 8b8b94948b8b 939393939393 8f8f8f8f8f8f 838383838383 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7b7b7b7b7b7b 7a7a7a7a7a7a 7a7a7a7a7a7a 797979797979 6a6a6a6a6a6a 575757575757 505050505050 4c4c4c4c4c4c 494949494949 595959595959 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 8a8a8a8a8a8a 0101b3b30101 0000c6c60001 0000f2f20000 5959b6b65959 929292929292 959595959595 979797979797 949494949494 878787878787 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 7c7c7c7c7c7c 717171717171 5a5a5a5a6060 282828288585 040404049393 0c0c0c0c7878 282828285858 464646464a4a 828282828282 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 929292929292 0c0cabab0c0c 0000bdbd0001 0000f4f40000 2020dddd2020 919191919191 949494949494 979797979797 999999999999 9b9b9b9b9b9b 999999999999 8b8b8b8b8b8b 7f7f7f7f7f7f 7e7e7e7e7e7e 7e7e7e7e7e7e 7d7d7d7d7d7d 777777777777 626262626262 535353536060 12121212bebe 00010000cccc 000000009292 000000016969 000000006767 2a2a2a2a5555 acacacacacac ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff 949494949494 1616a1a11616 0000b4b40001 0000e2e20000 0000f4f40000 7676a2a27676 939393939393 8d8d97978d8d 46469e9e4646 4646a7a74646 8e8e9e9e8e8e 9e9e9e9e9e9e 9c9c9c9c9c9c 8e8e8e8e8e8e 7e7e7e7e7e7e 6a6a6a6a6a6a 5a5a5a5a5a5a 575757575a5a 18181818cdcd 00010000f0f0 00000000a0a0 020202026060 010101013d3d 000100006161 1d1d1d1d5959 d6d6d6d6d6d6 ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff a4a4a4a4a4a4 212198982121 0000aaaa0001 0000c8c80000 0000f4f40000 3b3bcaca3b3b 929292929292 4a4aacac4a4a 0001bcbc0000 0000a9a90000 2f2f9a9a2f2f 9d9d9d9d9d9d 9f9f9f9f9f9f a0a0a0a0a0a0 7a7a7a7a7a7a 5a5a5a5a5a5a 595959595959 31313131a1a1 00010000ffff 00000000c6c6 030303035b5b 191919192424 0c0c0c0c1515 0c0c0c0c5555 3b3b3b3b5353 fbfbfbfbfbfb ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff b6b6b6b6b6b6 2b2b8f8f2b2b 0000a2a20001 0000adad0000 0000ebeb0000 0707eded0707 898995958989 4343a7a74343 0001c9c90000 000099990000 383895953838 9c9c9c9c9c9c 9e9e9e9e9e9e 9f9f9f9f9f9f 747474747474 595959595959 505050506767 05050505f5f5 00010000f0f0 030303037070 383838384646 484848484848 161616163939 2b2b2b2b5555 727272727272 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff c7c7c7c7c7c7 343486863434 0000b1b10001 00008d8d0000 0000d2d20000 0000f3f30000 4c4c9b9b4c4c 3b3b9e9e3b3b 0001c7c70000 000098980000 3d3d94943d3d 9b9b9b9b9b9b 9d9d9d9d9d9d 9e9e9e9e9e9e 6e6e6e6e6e6e 595959595959 2b2b2b2badad 00000001ffff 00000000a6a6 252525255959 434343434f4f 161616167e7e 000000019f9f 010101018e8e 9c9c9c9ca1a1 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff d8d8d8d8d8d8 3e3e7d7d3e3e 0000b1b10001 00007b7b0000 0000b8b80000 0000f1f10000 17178b8b1717 3b3b9c9c3b3b 0001c6c60000 000097970000 3d3d93933d3d 9a9a9a9a9a9a 9b9b9b9b9b9b 9d9d9d9d9d9d 676767676767 575757575959 09090909eeee 00000001f0f0 040404046b6b 333333335a5a 070707079090 000000009e9e 000000017c7c 0d0d0d0d5d5d c7c7c7c7c7c7 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff eaeaeaeaeaea 474774744747 0000adad0001 000085850000 090998980909 0000dcdc0000 0000a7a70000 232398982323 0001c3c30000 000096960000 3f3f92923f3f 989898989898 9a9a9a9a9a9a 9c9c9c9c9c9c 616161616161 424242427f7f 00010000ffff 00000001b9b9 1a1a1a1a5d5d 161616164949 000000007b7b 000000006b6b 000000016b6b 1c1c1c1c5656 f4f4f4f4f4f4 ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff fcfcfcfcfcfc 50506c6c5050 0000a9a90001 000095950000 2d2d77772d2d 0000c1c10000 0000c5c50000 010193930101 0001c1c10000 000090900000 4b4b91914b4b 979797979797 999999999999 9a9a9a9a9a9a 5a5a5a5a5a5a 2b2b2b2ba4a4 00010000f6f6 000000018686 2f2f2f2f5353 191919193030 020202026363 000000007373 000000019b9b 4d4d4d4d7070 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff 686873736868 0000a4a40001 0000a4a40000 3e3e65653e3e 1414a5a51414 0000d4d40000 00008b8b0001 0000bfbf0000 00008e8e0000 4a4a90904a4a 959595959595 979797979797 969696969696 575757575757 1a1a1a1ab5b5 00010000dede 000000016868 3f3f3f3f4b4b 2b2b2b2b2b2b 0c0c0c0c6d6d 00000000b3b3 000000016b6b 868686869292 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff 8c8c8c8c8c8c 05059e9e0505 0001b0b00000 343466663434 404085854040 0000caca0000 000097970001 0000bcbc0000 00008c8c0000 49498e8e4949 939393939393 959595959595 8f8f8f8f8f8f 565656565656 0f0f0f0fb7b7 00010000b9b9 030303036666 474747474747 2f2f2f2f6464 00010000a2a2 000000009d9d 090909095858 c5c5c5c5c5c5 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff fafafafafafa 9090b0b09090 343485853434 616164646161 63636a6a6363 0606afaf0606 0000aeae0001 0000b9b90000 00008b8b0000 53538d8d5353 919191919191 939393939393 898989898989 555555555555 0a0a0a0aa8a8 000100009d9d 070707076363 343434345c5c 040404049b9b 00010000b1b1 1a1a1a1a4d4d b5b5b5b5bbbb ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff d0d0d0d0d0d0 6d6d6d6d6d6d 656565656565 2d2d8f8f2d2d 0000b2b20001 0000b6b60000 000089890000 55558b8b5555 8f8f8f8f8f8f 919191919191 818181818181 555555555555 151515157e7e 000100008484 010101016565 010101018484 000100009191 1c1c1c1c6e6e cecececed0d0 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ecececececec 868686868686 585870705858 0000afaf0001 0000b3b30000 000088880000 535389895353 8d8d8d8d8d8d 8f8f8f8f8f8f 7a7a7a7a7a7a 545454545454 2c2c2c2c4949 020202026b6b 000000016464 000000006363 292929297474 dfdfdfdfe5e5 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff fcfcfcfcfcfc aaaaaaaaaaaa 212198982121 0001b0b00000 000086860000 575787875757 8b8b8b8b8b8b 8d8d8d8d8d8d 747474747474 535353535353 3d3d3d3d3d3d 1a1a1a1a2323 0d0d0d0d4343 474747477272 ededededefef ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff d1d1d6d6d1d1 38389b9b3838 2d2d77772d2d 7d7d81817d7d 888888888888 8b8b8b8b8b8b 6d6d6d6d6d6d 525252525252 4f4f4f4f4f4f 373737373737 777777777777 fafafafafafa ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff efefefefefef a0a0a0a0a0a0 838383838383 868686868686 888888888888 676767676767 515151515151 505050505050 a0a0a0a0a0a0 fdfdfdfdfdfd ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff fefefefefefe c0c0c0c0c0c0 858585858585 868686868686 616161616161 525252525252 b7b7b7b7b7b7 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff dededededede 909090909090 656565656565 cccccccccccc ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff f5f5f5f5f5f5 e3e3e3e3e3e3 ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff ffffffffffff 
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbgn3p08.png b/libgo/go/image/png/testdata/pngsuite/ftbgn3p08.png
new file mode 100644 (file)
index 0000000..8cf2e6f
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbgn3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbgn3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftbgn3p08.sng
new file mode 100644 (file)
index 0000000..0e3b7bd
--- /dev/null
@@ -0,0 +1,292 @@
+#SNG: from ftbgn3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+    (170,170,170)     # rgb = (0xaa,0xaa,0xaa)
+}
+bKGD {index: 245}
+tRNS {
+ 0}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000e0ea66000000000000000000000000000000
+0000000000000000000000de02a336e43903f4f0000000000000000000000000
+000000000000000069ef1a358680062eb017b0ab7af459500000000000000000
+0000000000667c0ea9cc803979937917a03a878787b0e2ae8ae75c0000000000
+00005cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c690000
+00007823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e0000
+0000e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef0000
+00006c9f229d981a23282828282828282828282828282828a7b445c3c8de0000
+00005ca249d63d140f139f272727272727272727a5a528af44c3c8ce43000000
+0000009a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1000000
+000000965b58b53811940d0b090b1823a3a3252ab4d24c269957571088000000
+000000946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877000000
+00000088c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950000000
+00000002bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a900000000
+0000007b47636ec441b23d4edb3f09078bac4315f340ec855a82995f00000000
+00000059bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b00000000
+0000006cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086000000000
+00000050bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e60000000000
+00000000add6d6bf61c16f566eb20e0d924475bd578572c61e6d340000000000
+0000000016d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b0000000000
+00000000550c47b3365bd45d6f33110f1a4575cbf2c0521e0802000000000000
+000000000000e7ac36be625e7031131122455a0a2f0a99c6e700000000000000
+000000000000006a9e37d36270331613a545f181e53032e80000000000000000
+00000000000000005088c5d371311816a8464b7374ee89000000000000000000
+0000000000000000000077b654a29b18acc24a722a5500000000000000000000
+0000000000000000000000d78a9f9e9b3548c38ac90000000000000000000000
+00000000000000000000000000ef1f9e3cc20200000000000000000000000000
+0000000000000000000000000000e89736780000000000000000000000000000
+00000000000000000000000000000060e0000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbrn2c08.png b/libgo/go/image/png/testdata/pngsuite/ftbrn2c08.png
new file mode 100644 (file)
index 0000000..5cca0d6
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbrn2c08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbrn2c08.sng b/libgo/go/image/png/testdata/pngsuite/ftbrn2c08.sng
new file mode 100644 (file)
index 0000000..9569bda
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbrn2c08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color;
+}
+gAMA {1.0000}
+bKGD {red: 255;  green: 0;  blue: 0;}
+tRNS {
+    red: 255; green: 255; blue: 255;
+}
+IMAGE {
+    pixels hex
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff e3e3e3 c9c9c9 f1f1f1 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff e8e8e8 b5b5b5 7e7e7e 656565 6e5252 7e2e2e a64343 c79090 ebdddd ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff eeeeee bfbfbf 898989 676767 6b5d5d 7a3939 8a1212 8d0000 850000 770000 840000 9a0101 a22d2d bf7d7d ddd0d0 fcfcfc ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff f2f2f2 c4c4c4 959595 727272 6f6b6b 774444 871e1e 950101 9f0000 910000 800000 720c0c 612d2d 530e0e 500000 590000 850000 920606 7a6666 a0a0a0 cfcfcf f8f8f8 ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff f7f7f7 cacaca 9a9a9a 767676 737373 7c5d5d 872e2e 930707 9e0000 a90000 b00000 c90000 cf0000 b90000 a20101 8c1919 852a2a 7f1313 810000 960000 8f0000 6b5353 6e6e6e 737373 767676 9b9b9b c4c4c4 eeeeee ffffff ffffff 
+ffffff ffffff cccccc 7f7f7f 767676 757575 757575 962f2f b80000 b40000 b60000 ad0c0c 943a3a 925050 b92323 d60202 e20000 ef0000 e70000 da0000 cf0000 ba0000 7d0101 6f6b6b 757575 757575 757575 757575 6a6a6a 9a9a9a ffffff ffffff 
+ffffff ffffff dcdcdc 858585 888888 848484 7b7b7b 855454 b71313 a91d1d 8d4f4f 787575 777777 777777 777777 816b6b aa4141 d62020 ec1010 e90c0c d01212 a52828 7b5858 777777 777777 777777 707070 5c5c5c 525252 bdbdbd ffffff ffffff 
+ffffff ffffff eaeaea 848484 818181 858885 8e8e8e 898989 7f7f7f 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 767676 636363 545454 505050 4c4c4c e6e6e6 ffffff ffffff 
+ffffff ffffff f8f8f8 7f847f 259725 04a504 39a439 8b948b 939393 8f8f8f 838383 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7a7a7a 7a7a7a 797979 6a6a6a 575757 505050 4c4c4c 494949 595959 ffffff ffffff ffffff 
+ffffff ffffff ffffff 8a8a8a 01b301 00c600 00f200 59b659 929292 959595 979797 949494 878787 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 717171 5a5a60 282885 040493 0c0c78 282858 46464a 828282 ffffff ffffff ffffff 
+ffffff ffffff ffffff 929292 0cab0c 00bd00 00f400 20dd20 919191 949494 979797 999999 9b9b9b 999999 8b8b8b 7f7f7f 7e7e7e 7e7e7e 7d7d7d 777777 626262 535360 1212be 0000cc 000092 000069 000067 2a2a55 acacac ffffff ffffff ffffff 
+ffffff ffffff ffffff 949494 16a116 00b400 00e200 00f400 76a276 939393 8d978d 469e46 46a746 8e9e8e 9e9e9e 9c9c9c 8e8e8e 7e7e7e 6a6a6a 5a5a5a 57575a 1818cd 0000f0 0000a0 020260 01013d 000061 1d1d59 d6d6d6 ffffff ffffff ffffff 
+ffffff ffffff ffffff a4a4a4 219821 00aa00 00c800 00f400 3bca3b 929292 4aac4a 00bc00 00a900 2f9a2f 9d9d9d 9f9f9f a0a0a0 7a7a7a 5a5a5a 595959 3131a1 0000ff 0000c6 03035b 191924 0c0c15 0c0c55 3b3b53 fbfbfb ffffff ffffff ffffff 
+ffffff ffffff ffffff b6b6b6 2b8f2b 00a200 00ad00 00eb00 07ed07 899589 43a743 00c900 009900 389538 9c9c9c 9e9e9e 9f9f9f 747474 595959 505067 0505f5 0000f0 030370 383846 484848 161639 2b2b55 727272 ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff c7c7c7 348634 00b100 008d00 00d200 00f300 4c9b4c 3b9e3b 00c700 009800 3d943d 9b9b9b 9d9d9d 9e9e9e 6e6e6e 595959 2b2bad 0000ff 0000a6 252559 43434f 16167e 00009f 01018e 9c9ca1 ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff d8d8d8 3e7d3e 00b100 007b00 00b800 00f100 178b17 3b9c3b 00c600 009700 3d933d 9a9a9a 9b9b9b 9d9d9d 676767 575759 0909ee 0000f0 04046b 33335a 070790 00009e 00007c 0d0d5d c7c7c7 ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff eaeaea 477447 00ad00 008500 099809 00dc00 00a700 239823 00c300 009600 3f923f 989898 9a9a9a 9c9c9c 616161 42427f 0000ff 0000b9 1a1a5d 161649 00007b 00006b 00006b 1c1c56 f4f4f4 ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff fcfcfc 506c50 00a900 009500 2d772d 00c100 00c500 019301 00c100 009000 4b914b 979797 999999 9a9a9a 5a5a5a 2b2ba4 0000f6 000086 2f2f53 191930 020263 000073 00009b 4d4d70 ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff 687368 00a400 00a400 3e653e 14a514 00d400 008b00 00bf00 008e00 4a904a 959595 979797 969696 575757 1a1ab5 0000de 000068 3f3f4b 2b2b2b 0c0c6d 0000b3 00006b 868692 ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff 8c8c8c 059e05 00b000 346634 408540 00ca00 009700 00bc00 008c00 498e49 939393 959595 8f8f8f 565656 0f0fb7 0000b9 030366 474747 2f2f64 0000a2 00009d 090958 c5c5c5 ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff fafafa 90b090 348534 616461 636a63 06af06 00ae00 00b900 008b00 538d53 919191 939393 898989 555555 0a0aa8 00009d 070763 34345c 04049b 0000b1 1a1a4d b5b5bb ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff d0d0d0 6d6d6d 656565 2d8f2d 00b200 00b600 008900 558b55 8f8f8f 919191 818181 555555 15157e 000084 010165 010184 000091 1c1c6e ceced0 ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ececec 868686 587058 00af00 00b300 008800 538953 8d8d8d 8f8f8f 7a7a7a 545454 2c2c49 02026b 000064 000063 292974 dfdfe5 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff fcfcfc aaaaaa 219821 00b000 008600 578757 8b8b8b 8d8d8d 747474 535353 3d3d3d 1a1a23 0d0d43 474772 ededef ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff d1d6d1 389b38 2d772d 7d817d 888888 8b8b8b 6d6d6d 525252 4f4f4f 373737 777777 fafafa ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff efefef a0a0a0 838383 868686 888888 676767 515151 505050 a0a0a0 fdfdfd ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff fefefe c0c0c0 858585 868686 616161 525252 b7b7b7 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff dedede 909090 656565 cccccc ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff f5f5f5 e3e3e3 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff 
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbwn0g16.png b/libgo/go/image/png/testdata/pngsuite/ftbwn0g16.png
new file mode 100644 (file)
index 0000000..99bdeed
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbwn0g16.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbwn0g16.sng b/libgo/go/image/png/testdata/pngsuite/ftbwn0g16.sng
new file mode 100644 (file)
index 0000000..3fca307
--- /dev/null
@@ -0,0 +1,45 @@
+#SNG: from ftbwn0g16.png
+IHDR {
+    width: 32; height: 32; bitdepth: 16;
+    using grayscale;
+}
+gAMA {1.0000}
+bKGD {gray: 65535;}
+tRNS {
+    gray: 65535;
+}
+IMAGE {
+    pixels hex
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff e3e3 c9c9 f1f1 ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff e8e8 b5b5 7e7e 6565 5ab9 462f 60f8 a111 e210 ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff eeee bfbf 8989 6767 6190 4cba 3614 2a50 27e9 23b5 279c 2eea 5049 914b d4b7 fcfc ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff f2f2 c4c4 9595 7272 6c9e 5392 3da0 2d6a 2fb7 2b83 2669 2aa7 3cc7 22c2 1801 1ab5 27e9 3008 6c66 a0a0 cfcf f8f8 ffff ffff ffff ffff ffff 
+ffff ffff f7f7 caca 9a9a 7676 7373 66aa 48e3 3109 2f6a 32b6 34d0 3c50 3e1d 3784 3151 3b9b 4578 337b 26b6 2d03 2ae9 5a87 6e6e 7373 7676 9b9b c4c4 eeee ffff ffff 
+ffff ffff cccc 7f7f 7676 7575 7575 4e17 3737 3603 369d 3c5c 553c 641e 5026 419f 43d1 47b7 4551 416a 3e1e 37d0 2636 6c9e 7575 7575 7575 7575 6a6a 9a9a ffff ffff 
+ffff ffff dcdc 8585 8888 8484 7b7b 6308 4449 471f 61ea 765b 7777 7777 7777 7205 60c3 56bd 5214 4e5d 4b15 4daa 62d9 7777 7777 7777 7070 5c5c 5252 bdbd ffff ffff 
+ffff ffff eaea 8484 8181 8749 8e8e 8989 7f7f 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7979 7676 6363 5454 5050 4c4c e6e6 ffff ffff 
+ffff ffff f8f8 8271 6847 62d4 783c 90d8 9393 8f8f 8383 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7b7b 7a7a 7a7a 7979 6a6a 5757 5050 4c4c 4949 5959 ffff ffff ffff 
+ffff ffff ffff 8a8a 69d4 749a 8e83 901d 9292 9595 9797 9494 8787 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7c7c 7171 5b0b 32d9 1474 1876 2dac 46bc 8282 ffff ffff ffff 
+ffff ffff ffff 9292 69ae 6f4d 8fb1 8f6d 9191 9494 9797 9999 9b9b 9999 8b8b 7f7f 7e7e 7e7e 7d7d 7777 6262 54d2 25d7 1773 10c8 0c12 0bd7 2f1b acac ffff ffff ffff 
+ffff ffff ffff 9494 67f1 6a00 8517 8fb1 905f 9393 9371 7a19 7f65 97fa 9e9e 9c9c 8e8e 7e7e 6a6a 5a5a 57af 2ce6 1b97 1264 0cd0 07e7 0b27 2403 d6d6 ffff ffff ffff 
+ffff ffff ffff a4a4 6735 641d 75c7 8fb1 8f71 9292 8400 6eb6 6386 6e32 9d9d 9f9f a0a0 7a7a 5a5a 5959 3e11 1d50 16c2 0d21 1a5d 0d15 1470 3dfd fbfb ffff ffff ffff 
+ffff ffff ffff b6b6 660f 5f67 65e1 8a64 8e79 909a 7e27 765e 5a1a 6efc 9c9c 9e9e 9f9f 7474 5959 52f5 209b 1b97 0f8a 39d4 4848 1a1c 2fff 7272 ffff ffff ffff ffff 
+ffff ffff ffff c7c7 647e 683c 5309 7bab 8f1a 7ad2 7588 7531 5983 7079 9b9b 9d9d 9e9e 6e6e 5959 3a1c 1d50 1315 2b1f 44a4 220a 1247 1136 9d2f ffff ffff ffff ffff 
+ffff ffff ffff d8d8 6358 683c 486f 6c5b 8dec 5b67 745a 749a 58ec 6fe2 9a9a 9b9b 9d9d 6767 5792 235c 1b97 0fdb 37af 16c6 1229 0e41 163f c7c7 ffff ffff ffff ffff 
+ffff ffff ffff eaea 61c7 65e1 4e53 5d3f 818e 6258 6809 72d6 5855 7020 9898 9a9a 9c9c 6161 4945 1d50 1544 21ce 1bf3 0e23 0c4d 0c4d 22c7 f4f4 ffff ffff ffff ffff 
+ffff ffff ffff fcfc 60cd 6386 57bf 58c1 71a8 7403 56fb 71a8 54cd 7484 9797 9999 9a9a 5a5a 3914 1c47 0f68 3352 1bbe 0d28 0d38 11d2 5153 ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff 6ee2 6094 6094 5535 6978 7cd8 51db 707a 539f 7383 9595 9797 9696 5757 2beb 1985 0bf5 40a0 2b2b 1732 1493 0c4d 87e7 ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff 8c8c 5f1f 67a5 51a6 68e2 76f5 58ec 6eb6 5272 71eb 9393 9595 8f8f 5656 225f 1544 0e64 4747 3547 129f 120c 121e c5c5 ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff fafa a368 63e7 6325 6782 698c 6678 6cf2 51db 757b 9191 9393 8989 5555 1c33 120c 119a 38cd 155f 1459 1ff7 b666 ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff d0d0 6d6d 6565 66e3 68d3 6b2e 50ae 7522 8f8f 9191 8181 5555 2127 0f2d 0c80 1010 10ab 2589 cf09 ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ecec 8686 667a 670e 6969 5017 7320 8d8d 8f8f 7a7a 5454 2f81 0e14 0b7f 0b61 31c8 e090 ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff fcfc aaaa 6735 67a5 4ee9 739b 8b8b 8d8d 7474 5353 3d3d 1b23 1342 4c38 ee28 ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff d4c3 7285 58c1 7fd8 8888 8b8b 6d6d 5252 4f4f 3737 7777 fafa ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff efef a0a0 8383 8686 8888 6767 5151 5050 a0a0 fdfd ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff fefe c0c0 8585 8686 6161 5252 b7b7 ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff dede 9090 6565 cccc ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff f5f5 e3e3 ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff 
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbwn3p08.png b/libgo/go/image/png/testdata/pngsuite/ftbwn3p08.png
new file mode 100644 (file)
index 0000000..eacab7a
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbwn3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbwn3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftbwn3p08.sng
new file mode 100644 (file)
index 0000000..7b5aff6
--- /dev/null
@@ -0,0 +1,291 @@
+#SNG: from ftbwn3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+}
+bKGD {index: 0}
+tRNS {
+ 0}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000e0ea66000000000000000000000000000000
+0000000000000000000000de02a336e43903f4f0000000000000000000000000
+000000000000000069ef1a358680062eb017b0ab7af459500000000000000000
+0000000000667c0ea9cc803979937917a03a878787b0e2ae8ae75c0000000000
+00005cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c690000
+00007823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e0000
+0000e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef0000
+00006c9f229d981a23282828282828282828282828282828a7b445c3c8de0000
+00005ca249d63d140f139f272727272727272727a5a528af44c3c8ce43000000
+0000009a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1000000
+000000965b58b53811940d0b090b1823a3a3252ab4d24c269957571088000000
+000000946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877000000
+00000088c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950000000
+00000002bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a900000000
+0000007b47636ec441b23d4edb3f09078bac4315f340ec855a82995f00000000
+00000059bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b00000000
+0000006cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086000000000
+00000050bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e60000000000
+00000000add6d6bf61c16f566eb20e0d924475bd578572c61e6d340000000000
+0000000016d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b0000000000
+00000000550c47b3365bd45d6f33110f1a4575cbf2c0521e0802000000000000
+000000000000e7ac36be625e7031131122455a0a2f0a99c6e700000000000000
+000000000000006a9e37d36270331613a545f181e53032e80000000000000000
+00000000000000005088c5d371311816a8464b7374ee89000000000000000000
+0000000000000000000077b654a29b18acc24a722a5500000000000000000000
+0000000000000000000000d78a9f9e9b3548c38ac90000000000000000000000
+00000000000000000000000000ef1f9e3cc20200000000000000000000000000
+0000000000000000000000000000e89736780000000000000000000000000000
+00000000000000000000000000000060e0000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbyn3p08.png b/libgo/go/image/png/testdata/pngsuite/ftbyn3p08.png
new file mode 100644 (file)
index 0000000..656db09
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftbyn3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftbyn3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftbyn3p08.sng
new file mode 100644 (file)
index 0000000..5d61987
--- /dev/null
@@ -0,0 +1,292 @@
+#SNG: from ftbyn3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+    (255,255,  0)     # rgb = (0xff,0xff,0x00) yellow1
+}
+bKGD {index: 245}
+tRNS {
+ 0}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000e0ea66000000000000000000000000000000
+0000000000000000000000de02a336e43903f4f0000000000000000000000000
+000000000000000069ef1a358680062eb017b0ab7af459500000000000000000
+0000000000667c0ea9cc803979937917a03a878787b0e2ae8ae75c0000000000
+00005cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c690000
+00007823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e0000
+0000e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef0000
+00006c9f229d981a23282828282828282828282828282828a7b445c3c8de0000
+00005ca249d63d140f139f272727272727272727a5a528af44c3c8ce43000000
+0000009a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1000000
+000000965b58b53811940d0b090b1823a3a3252ab4d24c269957571088000000
+000000946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877000000
+00000088c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950000000
+00000002bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a900000000
+0000007b47636ec441b23d4edb3f09078bac4315f340ec855a82995f00000000
+00000059bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b00000000
+0000006cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086000000000
+00000050bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e60000000000
+00000000add6d6bf61c16f566eb20e0d924475bd578572c61e6d340000000000
+0000000016d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b0000000000
+00000000550c47b3365bd45d6f33110f1a4575cbf2c0521e0802000000000000
+000000000000e7ac36be625e7031131122455a0a2f0a99c6e700000000000000
+000000000000006a9e37d36270331613a545f181e53032e80000000000000000
+00000000000000005088c5d371311816a8464b7374ee89000000000000000000
+0000000000000000000077b654a29b18acc24a722a5500000000000000000000
+0000000000000000000000d78a9f9e9b3548c38ac90000000000000000000000
+00000000000000000000000000ef1f9e3cc20200000000000000000000000000
+0000000000000000000000000000e89736780000000000000000000000000000
+00000000000000000000000000000060e0000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n0g08.png b/libgo/go/image/png/testdata/pngsuite/ftp0n0g08.png
new file mode 100644 (file)
index 0000000..333465f
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftp0n0g08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n0g08.sng b/libgo/go/image/png/testdata/pngsuite/ftp0n0g08.sng
new file mode 100644 (file)
index 0000000..c8abd33
--- /dev/null
@@ -0,0 +1,41 @@
+#SNG: from ftp0n0g08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using grayscale;
+}
+gAMA {1.0000}
+IMAGE {
+    pixels hex
+7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7f7f7fe3c9f17f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7fe8b57e655a4661a1e17f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7feebf8967614d362a2824282f5091d4fc7f7f7f7f7f7f7f7f
+7f7f7f7f7ff2c495726c533e2e302c272b3d23181b28306ca0cff87f7f7f7f7f
+7f7ff7ca9a76736649313033353c3e38313c4533272d2b5a6e73769bc4ee7f7f
+7f7fcc7f7675754e3736373c55645042444845423e38266c757575756a9a7f7f
+7f7fdc8588847b6344476276777777726157524e4b4e63777777705c52bd7f7f
+7f7fea8481878e897f797979797979797979797979797979766354504ce67f7f
+7f7ff88268627890938f837b7b7b7b7b7b7b7b7b7a7a796a57504c49597f7f7f
+7f7f7f8a69748e8f92959794877c7c7c7c7c7c7c7c715b3314182d46827f7f7f
+7f7f7f92696f8f8f919497999b998b7f7e7e7d7762542517110c0c2fac7f7f7f
+7f7f7f946769848f9093937a7f979e9c8e7e6a5a572d1b120d080b24d67f7f7f
+7f7f7fa46764758f8f92836e636e9d9fa07a5a593e1d160d1a0d143efb7f7f7f
+7f7f7fb6665f658a8e907e765a6e9c9e9f745953201b0f3a481a30727f7f7f7f
+7f7f7fc76468537b8e7a757559709b9d9e6e593a1d132b442212119d7f7f7f7f
+7f7f7fd86368486c8d5b7474586f9a9b9d6757231b103717120e16c77f7f7f7f
+7f7f7fea61654e5d816268725870989a9c61491d15221c0e0c0c23f47f7f7f7f
+7f7f7ffc6063575871735771547497999a5a391c0f331c0d0d12517f7f7f7f7f
+7f7f7f7f6e606055697c51705373959796572c190c402b17140c877f7f7f7f7f
+7f7f7f7f8c5f67516876586e527193958f5622150e4735121212c57f7f7f7f7f
+7f7f7f7ffaa363636769666c5175919389551c121139151420b67f7f7f7f7f7f
+7f7f7f7f7f7fd06d6566686b50758f918155210f0c101025ce7f7f7f7f7f7f7f
+7f7f7f7f7f7f7fec8666676950738d8f7a542f0e0b0b31e07f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7ffcaa67674f738b8d74533d1b134ced7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7fd472587f888b6d524f3777fa7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7fefa0838688675150a0fd7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7ffec085866152b77f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7f7f7fde9065cc7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7f7f7f7ff5e37f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n2c08.png b/libgo/go/image/png/testdata/pngsuite/ftp0n2c08.png
new file mode 100644 (file)
index 0000000..fc6e42c
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftp0n2c08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n2c08.sng b/libgo/go/image/png/testdata/pngsuite/ftp0n2c08.sng
new file mode 100644 (file)
index 0000000..d41c7eb
--- /dev/null
@@ -0,0 +1,41 @@
+#SNG: from ftp0n2c08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color;
+}
+gAMA {1.0000}
+IMAGE {
+    pixels hex
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f e3e3e3 c9c9c9 f1f1f1 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f e8e8e8 b5b5b5 7e7e7e 656565 6e5252 7e2e2e a64343 c79090 ebdddd 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f eeeeee bfbfbf 898989 676767 6b5d5d 7a3939 8a1212 8d0000 850000 770000 840000 9a0101 a22d2d bf7d7d ddd0d0 fcfcfc 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f f2f2f2 c4c4c4 959595 727272 6f6b6b 774444 871e1e 950101 9f0000 910000 800000 720c0c 612d2d 530e0e 500000 590000 850000 920606 7a6666 a0a0a0 cfcfcf f8f8f8 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f f7f7f7 cacaca 9a9a9a 767676 737373 7c5d5d 872e2e 930707 9e0000 a90000 b00000 c90000 cf0000 b90000 a20101 8c1919 852a2a 7f1313 810000 960000 8f0000 6b5353 6e6e6e 737373 767676 9b9b9b c4c4c4 eeeeee 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f cccccc 7f7f7f 767676 757575 757575 962f2f b80000 b40000 b60000 ad0c0c 943a3a 925050 b92323 d60202 e20000 ef0000 e70000 da0000 cf0000 ba0000 7d0101 6f6b6b 757575 757575 757575 757575 6a6a6a 9a9a9a 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f dcdcdc 858585 888888 848484 7b7b7b 855454 b71313 a91d1d 8d4f4f 787575 777777 777777 777777 816b6b aa4141 d62020 ec1010 e90c0c d01212 a52828 7b5858 777777 777777 777777 707070 5c5c5c 525252 bdbdbd 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f eaeaea 848484 818181 858885 8e8e8e 898989 7f7f7f 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 797979 767676 636363 545454 505050 4c4c4c e6e6e6 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f f8f8f8 7f847f 259725 04a504 39a439 8b948b 939393 8f8f8f 838383 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7b7b7b 7a7a7a 7a7a7a 797979 6a6a6a 575757 505050 4c4c4c 494949 595959 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 8a8a8a 01b301 00c600 00f200 59b659 929292 959595 979797 949494 878787 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 7c7c7c 717171 5a5a60 282885 040493 0c0c78 282858 46464a 828282 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 929292 0cab0c 00bd00 00f400 20dd20 919191 949494 979797 999999 9b9b9b 999999 8b8b8b 7f7f7f 7e7e7e 7e7e7e 7d7d7d 777777 626262 535360 1212be 0000cc 000092 000069 000067 2a2a55 acacac 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 949494 16a116 00b400 00e200 00f400 76a276 939393 8d978d 469e46 46a746 8e9e8e 9e9e9e 9c9c9c 8e8e8e 7e7e7e 6a6a6a 5a5a5a 57575a 1818cd 0000f0 0000a0 020260 01013d 000061 1d1d59 d6d6d6 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f a4a4a4 219821 00aa00 00c800 00f400 3bca3b 929292 4aac4a 00bc00 00a900 2f9a2f 9d9d9d 9f9f9f a0a0a0 7a7a7a 5a5a5a 595959 3131a1 0000ff 0000c6 03035b 191924 0c0c15 0c0c55 3b3b53 fbfbfb 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f b6b6b6 2b8f2b 00a200 00ad00 00eb00 07ed07 899589 43a743 00c900 009900 389538 9c9c9c 9e9e9e 9f9f9f 747474 595959 505067 0505f5 0000f0 030370 383846 484848 161639 2b2b55 727272 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f c7c7c7 348634 00b100 008d00 00d200 00f300 4c9b4c 3b9e3b 00c700 009800 3d943d 9b9b9b 9d9d9d 9e9e9e 6e6e6e 595959 2b2bad 0000ff 0000a6 252559 43434f 16167e 00009f 01018e 9c9ca1 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f d8d8d8 3e7d3e 00b100 007b00 00b800 00f100 178b17 3b9c3b 00c600 009700 3d933d 9a9a9a 9b9b9b 9d9d9d 676767 575759 0909ee 0000f0 04046b 33335a 070790 00009e 00007c 0d0d5d c7c7c7 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f eaeaea 477447 00ad00 008500 099809 00dc00 00a700 239823 00c300 009600 3f923f 989898 9a9a9a 9c9c9c 616161 42427f 0000ff 0000b9 1a1a5d 161649 00007b 00006b 00006b 1c1c56 f4f4f4 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f fcfcfc 506c50 00a900 009500 2d772d 00c100 00c500 019301 00c100 009000 4b914b 979797 999999 9a9a9a 5a5a5a 2b2ba4 0000f6 000086 2f2f53 191930 020263 000073 00009b 4d4d70 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 687368 00a400 00a400 3e653e 14a514 00d400 008b00 00bf00 008e00 4a904a 959595 979797 969696 575757 1a1ab5 0000de 000068 3f3f4b 2b2b2b 0c0c6d 0000b3 00006b 868692 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 8c8c8c 059e05 00b000 346634 408540 00ca00 009700 00bc00 008c00 498e49 939393 959595 8f8f8f 565656 0f0fb7 0000b9 030366 474747 2f2f64 0000a2 00009d 090958 c5c5c5 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f fafafa 90b090 348534 616461 636a63 06af06 00ae00 00b900 008b00 538d53 919191 939393 898989 555555 0a0aa8 00009d 070763 34345c 04049b 0000b1 1a1a4d b5b5bb 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f d0d0d0 6d6d6d 656565 2d8f2d 00b200 00b600 008900 558b55 8f8f8f 919191 818181 555555 15157e 000084 010165 010184 000091 1c1c6e ceced0 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f ececec 868686 587058 00af00 00b300 008800 538953 8d8d8d 8f8f8f 7a7a7a 545454 2c2c49 02026b 000064 000063 292974 dfdfe5 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f fcfcfc aaaaaa 219821 00b000 008600 578757 8b8b8b 8d8d8d 747474 535353 3d3d3d 1a1a23 0d0d43 474772 ededef 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f d1d6d1 389b38 2d772d 7d817d 888888 8b8b8b 6d6d6d 525252 4f4f4f 373737 777777 fafafa 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f efefef a0a0a0 838383 868686 888888 676767 515151 505050 a0a0a0 fdfdfd 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f fefefe c0c0c0 858585 868686 616161 525252 b7b7b7 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f dedede 909090 656565 cccccc 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f f5f5f5 e3e3e3 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 7f7f7f 
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n3p08.png b/libgo/go/image/png/testdata/pngsuite/ftp0n3p08.png
new file mode 100644 (file)
index 0000000..69a69e5
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftp0n3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp0n3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftp0n3p08.sng
new file mode 100644 (file)
index 0000000..f1f8448
--- /dev/null
@@ -0,0 +1,288 @@
+#SNG: from ftp0n3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+}
+IMAGE {
+    pixels hex
+2323232323232323232323232323232323232323232323232323232323232323
+2323232323232323232323232323232323232323232323232323232323232323
+2323232323232323232323232323e0ea66232323232323232323232323232323
+2323232323232323232323de02a336e43903f4f0232323232323232323232323
+232323232323232369ef1a358680062eb017b0ab7af459502323232323232323
+2323232323667c0ea9cc803979937917a03a878787b0e2ae8ae75c2323232323
+23235cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c692323
+23237823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e2323
+2323e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef2323
+23236c9f229d981a23282828282828282828282828282828a7b445c3c8de2323
+23235ca249d63d140f139f272727272727272727a5a528af44c3c8ce43232323
+2323239a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1232323
+232323965b58b53811940d0b090b1823a3a3252ab4d24c269957571088232323
+232323946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877232323
+23232388c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950232323
+23232302bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a923232323
+2323237b47636ec441b23d4edb3f09078bac4315f340ec855a82995f23232323
+23232359bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b23232323
+2323236cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086023232323
+23232350bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e62323232323
+23232323add6d6bf61c16f566eb20e0d924475bd578572001e6d342323232323
+2323232316d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b2323232323
+23232323550c47b3365bd45d6f33110f1a4575cbf2c0521e0802232323232323
+232323232323e7ac36be625e7031131122455a0a2f0a9900e723232323232323
+232323232323236a9e37d36270331613a545f181e53032e82323232323232323
+23232323232323235088c5d371311816a8464b7374ee89232323232323232323
+2323232323232323232377b654a29b18acc24a722a5523232323232323232323
+2323232323232323232323d78a9f9e9b3548c38ac92323232323232323232323
+232323232323232323232323c6ef1f9e3cc20223232323232323232323232323
+2323232323232323232323232323e89736782323232323232323232323232323
+23232323232323232323232323232360e0232323232323232323232323232323
+2323232323232323232323232323232323232323232323232323232323232323
+}
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp1n3p08.png b/libgo/go/image/png/testdata/pngsuite/ftp1n3p08.png
new file mode 100644 (file)
index 0000000..a6c9f35
Binary files /dev/null and b/libgo/go/image/png/testdata/pngsuite/ftp1n3p08.png differ
diff --git a/libgo/go/image/png/testdata/pngsuite/ftp1n3p08.sng b/libgo/go/image/png/testdata/pngsuite/ftp1n3p08.sng
new file mode 100644 (file)
index 0000000..2d179e2
--- /dev/null
@@ -0,0 +1,290 @@
+#SNG: from ftp1n3p08.png
+IHDR {
+    width: 32; height: 32; bitdepth: 8;
+    using color palette;
+}
+gAMA {1.0000}
+PLTE {
+    (255,255,255)     # rgb = (0xff,0xff,0xff) grey100
+    (128, 86, 86)     # rgb = (0x80,0x56,0x56)
+    (181,181,184)     # rgb = (0xb5,0xb5,0xb8)
+    (168, 66, 66)     # rgb = (0xa8,0x42,0x42)
+    (159,159,159)     # rgb = (0x9f,0x9f,0x9f)
+    (177, 32, 32)     # rgb = (0xb1,0x20,0x20)
+    (139, 21, 21)     # rgb = (0x8b,0x15,0x15)
+    (157,157,157)     # rgb = (0x9d,0x9d,0x9d)
+    ( 27, 27, 89)     # rgb = (0x1b,0x1b,0x59)
+    (155,155,155)     # rgb = (0x9b,0x9b,0x9b)
+    (  0,  0,132)     # rgb = (0x00,0x00,0x84)
+    (153,153,153)     # rgb = (0x99,0x99,0x99) grey60
+    (143,167,143)     # rgb = (0x8f,0xa7,0x8f)
+    (151,151,151)     # rgb = (0x97,0x97,0x97)
+    (149,149,149)     # rgb = (0x95,0x95,0x95)
+    (147,147,147)     # rgb = (0x93,0x93,0x93)
+    ( 41, 41, 86)     # rgb = (0x29,0x29,0x56)
+    (145,145,145)     # rgb = (0x91,0x91,0x91) grey57
+    (  0,  0,155)     # rgb = (0x00,0x00,0x9b)
+    (143,143,143)     # rgb = (0x8f,0x8f,0x8f) grey56
+    (139,149,139)     # rgb = (0x8b,0x95,0x8b)
+    ( 46, 46,167)     # rgb = (0x2e,0x2e,0xa7)
+    (141,141,141)     # rgb = (0x8d,0x8d,0x8d)
+    (128,  0,  0)     # rgb = (0x80,0x00,0x00)
+    (139,139,139)     # rgb = (0x8b,0x8b,0x8b)
+    (185,  0,  0)     # rgb = (0xb9,0x00,0x00)
+    (137,137,137)     # rgb = (0x89,0x89,0x89)
+    ( 12, 12,213)     # rgb = (0x0c,0x0c,0xd5)
+    (120,117,117)     # rgb = (0x78,0x75,0x75)
+    (135,135,135)     # rgb = (0x87,0x87,0x87) grey53
+    (  0,  0,178)     # rgb = (0x00,0x00,0xb2)
+    (133,133,133)     # rgb = (0x85,0x85,0x85) grey52
+    (165,  0,  0)     # rgb = (0xa5,0x00,0x00)
+    (222,  0,  0)     # rgb = (0xde,0x00,0x00)
+    (129,129,129)     # rgb = (0x81,0x81,0x81)
+    (127,127,127)     # rgb = (0x7f,0x7f,0x7f) grey50
+    (  0,  0,158)     # rgb = (0x00,0x00,0x9e)
+    (125,125,125)     # rgb = (0x7d,0x7d,0x7d) grey49
+    (  0,  0,201)     # rgb = (0x00,0x00,0xc9)
+    (123,123,123)     # rgb = (0x7b,0x7b,0x7b)
+    (121,121,121)     # rgb = (0x79,0x79,0x79)
+    ( 55, 55, 86)     # rgb = (0x37,0x37,0x56)
+    (119,119,119)     # rgb = (0x77,0x77,0x77)
+    (117,117,117)     # rgb = (0x75,0x75,0x75) grey46
+    (115,115,115)     # rgb = (0x73,0x73,0x73) grey45
+    ( 72,169, 72)     # rgb = (0x48,0xa9,0x48)
+    (142,  0,  0)     # rgb = (0x8e,0x00,0x00)
+    (  2,  2,100)     # rgb = (0x02,0x02,0x64)
+    (  0,  0, 98)     # rgb = (0x00,0x00,0x62)
+    ( 86,137, 86)     # rgb = (0x56,0x89,0x56)
+    ( 40, 40,124)     # rgb = (0x28,0x28,0x7c)
+    ( 83,139, 83)     # rgb = (0x53,0x8b,0x53)
+    (137,137,143)     # rgb = (0x89,0x89,0x8f)
+    (103,103,103)     # rgb = (0x67,0x67,0x67)
+    (101,101,101)     # rgb = (0x65,0x65,0x65)
+    ( 93,109, 93)     # rgb = (0x5d,0x6d,0x5d)
+    ( 19,229, 19)     # rgb = (0x13,0xe5,0x13)
+    (134, 38, 38)     # rgb = (0x86,0x26,0x26)
+    (111, 45, 45)     # rgb = (0x6f,0x2d,0x2d)
+    ( 68,145, 68)     # rgb = (0x44,0x91,0x44)
+    ( 97, 97, 97)     # rgb = (0x61,0x61,0x61) grey38
+    ( 59,157, 59)     # rgb = (0x3b,0x9d,0x3b)
+    ( 68,137, 68)     # rgb = (0x44,0x89,0x44)
+    ( 61,147, 61)     # rgb = (0x3d,0x93,0x3d)
+    (  0,  0,164)     # rgb = (0x00,0x00,0xa4)
+    (  0,243,  0)     # rgb = (0x00,0xf3,0x00)
+    (  0,241,  0)     # rgb = (0x00,0xf1,0x00)
+    ( 89, 89, 89)     # rgb = (0x59,0x59,0x59) grey35
+    ( 87, 87, 87)     # rgb = (0x57,0x57,0x57) grey34
+    ( 85, 85, 85)     # rgb = (0x55,0x55,0x55)
+    ( 83, 83, 83)     # rgb = (0x53,0x53,0x53)
+    ( 52,133, 52)     # rgb = (0x34,0x85,0x34)
+    ( 81, 81, 81)     # rgb = (0x51,0x51,0x51)
+    ( 36,151, 36)     # rgb = (0x24,0x97,0x24)
+    ( 79, 79, 79)     # rgb = (0x4f,0x4f,0x4f) grey31
+    ( 58, 58, 65)     # rgb = (0x3a,0x3a,0x41)
+    ( 16, 16,186)     # rgb = (0x10,0x10,0xba)
+    (178, 15, 15)     # rgb = (0xb2,0x0f,0x0f)
+    (  0,199,  0)     # rgb = (0x00,0xc7,0x00)
+    (  0,197,  0)     # rgb = (0x00,0xc5,0x00)
+    (252,252,252)     # rgb = (0xfc,0xfc,0xfc) grey99
+    (  0,195,  0)     # rgb = (0x00,0xc3,0x00)
+    (  4,  4,151)     # rgb = (0x04,0x04,0x97)
+    (  0,193,  0)     # rgb = (0x00,0xc1,0x00)
+    ( 45,119, 45)     # rgb = (0x2d,0x77,0x2d)
+    (250,250,250)     # rgb = (0xfa,0xfa,0xfa) grey98
+    (  0,191,  0)     # rgb = (0x00,0xbf,0x00)
+    (  0,  0,104)     # rgb = (0x00,0x00,0x68)
+    (  0,189,  0)     # rgb = (0x00,0xbd,0x00)
+    (218,212,212)     # rgb = (0xda,0xd4,0xd4)
+    ( 16, 16,123)     # rgb = (0x10,0x10,0x7b)
+    (  9,173,  9)     # rgb = (0x09,0xad,0x09)
+    (248,248,248)     # rgb = (0xf8,0xf8,0xf8)
+    (  0,185,  0)     # rgb = (0x00,0xb9,0x00)
+    (  0,183,  0)     # rgb = (0x00,0xb7,0x00)
+    (156,156,161)     # rgb = (0x9c,0x9c,0xa1)
+    (246,246,246)     # rgb = (0xf6,0xf6,0xf6)
+    ( 12,161, 12)     # rgb = (0x0c,0xa1,0x0c)
+    (  0,179,  0)     # rgb = (0x00,0xb3,0x00)
+    (  0,177,  0)     # rgb = (0x00,0xb1,0x00)
+    ( 16,145, 16)     # rgb = (0x10,0x91,0x10)
+    (  0,171,  0)     # rgb = (0x00,0xab,0x00)
+    (242,242,242)     # rgb = (0xf2,0xf2,0xf2) grey95
+    (  0,169,  0)     # rgb = (0x00,0xa9,0x00)
+    (  0,167,  0)     # rgb = (0x00,0xa7,0x00)
+    (238,238,238)     # rgb = (0xee,0xee,0xee)
+    (236,236,236)     # rgb = (0xec,0xec,0xec)
+    (  0,151,  0)     # rgb = (0x00,0x97,0x00)
+    (234,234,234)     # rgb = (0xea,0xea,0xea)
+    (  0,  0,107)     # rgb = (0x00,0x00,0x6b)
+    (  0,141,  0)     # rgb = (0x00,0x8d,0x00)
+    (  0,139,  0)     # rgb = (0x00,0x8b,0x00) green4
+    (  0,137,  0)     # rgb = (0x00,0x89,0x00)
+    (  0,135,  0)     # rgb = (0x00,0x87,0x00)
+    ( 49, 49, 49)     # rgb = (0x31,0x31,0x31)
+    ( 25, 25, 42)     # rgb = (0x19,0x19,0x2a)
+    (  7,  7, 64)     # rgb = (0x07,0x07,0x40)
+    ( 18, 18,174)     # rgb = (0x12,0x12,0xae)
+    (  9,  9,238)     # rgb = (0x09,0x09,0xee)
+    (211,214,211)     # rgb = (0xd3,0xd6,0xd3)
+    (204,204,204)     # rgb = (0xcc,0xcc,0xcc) grey80
+    (147,  0,  0)     # rgb = (0x93,0x00,0x00)
+    (163, 42, 42)     # rgb = (0xa3,0x2a,0x2a)
+    (198,198,198)     # rgb = (0xc6,0xc6,0xc6)
+    (196,196,196)     # rgb = (0xc4,0xc4,0xc4) grey77
+    (204,  0,  0)     # rgb = (0xcc,0x00,0x00)
+    (211, 10, 10)     # rgb = (0xd3,0x0a,0x0a)
+    (129,107,107)     # rgb = (0x81,0x6b,0x6b)
+    (120, 62, 62)     # rgb = (0x78,0x3e,0x3e)
+    (  3,  3,109)     # rgb = (0x03,0x03,0x6d)
+    (  0,  0,159)     # rgb = (0x00,0x00,0x9f)
+    ( 10, 10, 86)     # rgb = (0x0a,0x0a,0x56)
+    ( 70, 70, 72)     # rgb = (0x46,0x46,0x48)
+    ( 65, 65, 77)     # rgb = (0x41,0x41,0x4d)
+    (115, 93, 93)     # rgb = (0x73,0x5d,0x5d)
+    ( 81,  7,  7)     # rgb = (0x51,0x07,0x07)
+    (168,168,168)     # rgb = (0xa8,0xa8,0xa8) grey66
+    (237,237,239)     # rgb = (0xed,0xed,0xef)
+    (160,160,160)     # rgb = (0xa0,0xa0,0xa0)
+    (158,158,158)     # rgb = (0x9e,0x9e,0x9e) grey62
+    (156,156,156)     # rgb = (0x9c,0x9c,0x9c) grey61
+    (  0,  0,185)     # rgb = (0x00,0x00,0xb9)
+    (154,154,154)     # rgb = (0x9a,0x9a,0x9a)
+    (178,  0,  0)     # rgb = (0xb2,0x00,0x00)
+    (152,152,152)     # rgb = (0x98,0x98,0x98)
+    (235,  0,  0)     # rgb = (0xeb,0x00,0x00)
+    (150,150,150)     # rgb = (0x96,0x96,0x96) grey59
+    (158,  0,  0)     # rgb = (0x9e,0x00,0x00)
+    (148,148,148)     # rgb = (0x94,0x94,0x94) grey58
+    ( 19, 19, 28)     # rgb = (0x13,0x13,0x1c)
+    (146,146,146)     # rgb = (0x92,0x92,0x92)
+    (144,144,144)     # rgb = (0x90,0x90,0x90)
+    (142,142,142)     # rgb = (0x8e,0x8e,0x8e)
+    (  0,  0,145)     # rgb = (0x00,0x00,0x91)
+    (138,138,138)     # rgb = (0x8a,0x8a,0x8a) grey54
+    (136,136,136)     # rgb = (0x88,0x88,0x88)
+    (118,162,118)     # rgb = (0x76,0xa2,0x76)
+    (133,136,133)     # rgb = (0x85,0x88,0x85)
+    (134,134,134)     # rgb = (0x86,0x86,0x86)
+    (132,132,132)     # rgb = (0x84,0x84,0x84)
+    (120, 15, 15)     # rgb = (0x78,0x0f,0x0f)
+    (130,130,130)     # rgb = (0x82,0x82,0x82) grey51
+    (126,130,126)     # rgb = (0x7e,0x82,0x7e)
+    (126,126,126)     # rgb = (0x7e,0x7e,0x7e)
+    (124,124,124)     # rgb = (0x7c,0x7c,0x7c)
+    (122,122,122)     # rgb = (0x7a,0x7a,0x7a) grey48
+    ( 74,192, 74)     # rgb = (0x4a,0xc0,0x4a)
+    (118,118,118)     # rgb = (0x76,0x76,0x76)
+    (116,116,116)     # rgb = (0x74,0x74,0x74)
+    (114,114,114)     # rgb = (0x72,0x72,0x72)
+    (112,112,112)     # rgb = (0x70,0x70,0x70) grey44
+    (152,  0,  0)     # rgb = (0x98,0x00,0x00)
+    (110,110,110)     # rgb = (0x6e,0x6e,0x6e) grey43
+    (106,112,106)     # rgb = (0x6a,0x70,0x6a)
+    (122,102,102)     # rgb = (0x7a,0x66,0x66)
+    (106,106,106)     # rgb = (0x6a,0x6a,0x6a)
+    (132,  0,  0)     # rgb = (0x84,0x00,0x00)
+    ( 68,162, 68)     # rgb = (0x44,0xa2,0x44)
+    ( 75,150, 75)     # rgb = (0x4b,0x96,0x4b)
+    ( 97,100, 97)     # rgb = (0x61,0x64,0x61)
+    ( 98, 98, 98)     # rgb = (0x62,0x62,0x62)
+    (  0,244,  0)     # rgb = (0x00,0xf4,0x00)
+    ( 56,152, 56)     # rgb = (0x38,0x98,0x38)
+    ( 92, 92, 92)     # rgb = (0x5c,0x5c,0x5c) grey36
+    ( 90, 90, 90)     # rgb = (0x5a,0x5a,0x5a)
+    (  0,230,  0)     # rgb = (0x00,0xe6,0x00)
+    (  2,  2, 93)     # rgb = (0x02,0x02,0x5d)
+    ( 66,120, 66)     # rgb = (0x42,0x78,0x42)
+    ( 86, 86, 86)     # rgb = (0x56,0x56,0x56)
+    (  0,  0,240)     # rgb = (0x00,0x00,0xf0)
+    ( 46,148, 46)     # rgb = (0x2e,0x94,0x2e)
+    ( 71,104, 71)     # rgb = (0x47,0x68,0x47)
+    ( 49, 49, 96)     # rgb = (0x31,0x31,0x60)
+    (  0,216,  0)     # rgb = (0x00,0xd8,0x00)
+    ( 82, 82, 82)     # rgb = (0x52,0x52,0x52) grey32
+    ( 80, 80, 80)     # rgb = (0x50,0x50,0x50)
+    (  0,206,  0)     # rgb = (0x00,0xce,0x00)
+    ( 33,152, 33)     # rgb = (0x21,0x98,0x21)
+    ( 20, 20,109)     # rgb = (0x14,0x14,0x6d)
+    (  0,200,  0)     # rgb = (0x00,0xc8,0x00)
+    ( 76, 76, 76)     # rgb = (0x4c,0x4c,0x4c)
+    (253,253,253)     # rgb = (0xfd,0xfd,0xfd)
+    (  0,198,  0)     # rgb = (0x00,0xc6,0x00)
+    (  0,  0,157)     # rgb = (0x00,0x00,0x9d)
+    (111,107,107)     # rgb = (0x6f,0x6b,0x6b)
+    (234, 14, 14)     # rgb = (0xea,0x0e,0x0e)
+    ( 72, 72, 72)     # rgb = (0x48,0x48,0x48)
+    (  0,188,  0)     # rgb = (0x00,0xbc,0x00)
+    ( 52,102, 52)     # rgb = (0x34,0x66,0x34)
+    (  2,  2,245)     # rgb = (0x02,0x02,0xf5)
+    ( 83, 83, 96)     # rgb = (0x53,0x53,0x60)
+    (  0,176,  0)     # rgb = (0x00,0xb0,0x00)
+    (  0,174,  0)     # rgb = (0x00,0xae,0x00)
+    (183,  0,  0)     # rgb = (0xb7,0x00,0x00)
+    (  0,164,  0)     # rgb = (0x00,0xa4,0x00)
+    (239,239,239)     # rgb = (0xef,0xef,0xef)
+    (  0,162,  0)     # rgb = (0x00,0xa2,0x00)
+    (143, 79, 79)     # rgb = (0x8f,0x4f,0x4f)
+    (149, 52, 52)     # rgb = (0x95,0x34,0x34)
+    (  0,152,  0)     # rgb = (0x00,0x98,0x00)
+    (  0,150,  0)     # rgb = (0x00,0x96,0x00)
+    (  0,146,  0)     # rgb = (0x00,0x92,0x00)
+    (231,231,231)     # rgb = (0xe7,0xe7,0xe7)
+    (  0,140,  0)     # rgb = (0x00,0x8c,0x00)
+    (227,227,227)     # rgb = (0xe3,0xe3,0xe3) grey89
+    (  0,128,  0)     # rgb = (0x00,0x80,0x00)
+    (146,  6,  6)     # rgb = (0x92,0x06,0x06)
+    (  1,  1,111)     # rgb = (0x01,0x01,0x6f)
+    (100, 86, 89)     # rgb = (0x64,0x56,0x59)
+    (  0,  0,100)     # rgb = (0x00,0x00,0x64)
+    ( 78, 78,107)     # rgb = (0x4e,0x4e,0x6b)
+    (207,207,207)     # rgb = (0xcf,0xcf,0xcf) grey81
+    (221,221,224)     # rgb = (0xdd,0xdd,0xe0)
+    (  0,  0,123)     # rgb = (0x00,0x00,0x7b)
+    (201,201,201)     # rgb = (0xc9,0xc9,0xc9) grey79
+    ( 22, 22, 65)     # rgb = (0x16,0x16,0x41)
+    ( 33, 33, 89)     # rgb = (0x21,0x21,0x59)
+    ( 87, 87, 89)     # rgb = (0x57,0x57,0x59)
+    ( 68, 68,120)     # rgb = (0x44,0x44,0x78)
+    (191,191,191)     # rgb = (0xbf,0xbf,0xbf) grey75
+    (235,221,221)     # rgb = (0xeb,0xdd,0xdd)
+    ( 45, 45, 84)     # rgb = (0x2d,0x2d,0x54)
+    ( 10, 10, 96)     # rgb = (0x0a,0x0a,0x60)
+    (  0,  0,255)     # rgb = (0x00,0x00,0xff) blue1
+    (191,125,125)     # rgb = (0xbf,0x7d,0x7d)
+}
+tRNS {
+ 0}
+IMAGE {
+    pixels hex
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000e0ea66000000000000000000000000000000
+0000000000000000000000de02a336e43903f4f0000000000000000000000000
+000000000000000069ef1a358680062eb017b0ab7af459500000000000000000
+0000000000667c0ea9cc803979937917a03a878787b0e2ae8ae75c0000000000
+00005cea8ea72c8639e293208f7d7d19200639a017ab2ee4ac2ca7097c690000
+00007823a72b2bda198fd54ddad90521219191217d1917cc2b2b2b2baf8e0000
+0000e81f9b9f27014d05d91c2a2a2a7f037ecdcd7e7a012a2a2aaab7c2ef0000
+00006c9f229d981a23282828282828282828282828282828a7b445c3c8de0000
+00005ca249d63d140f139f272727272727272727a5a528af44c3c8ce43000000
+0000009a62ca41a6960e0d941da4a4a4a4a4a4a4a4a9b732525a1084a1000000
+000000965b58b53811940d0b090b1823a3a3252ab4d24c269957571088000000
+000000946162b9b59c0f14b12d0c8b8c98a3afb8ed1bbd82ba74300877000000
+00000088c565c7b5a6962dcf67be07048aa5b84315f326ba7395832950000000
+00000002bed8d4b94214b1c7dbb68c8b04a843e6d1bd814bceeb10a900000000
+0000007b47636ec441b23d4edb3f09078bac4315f340ec855a82995f00000000
+00000059bb63e15d42643dca6b3f8e090735ed76bd81c05224e9f27b00000000
+0000006cbbd47161c1684951dc3f908e8c3ceef38d08ebe96d6d086000000000
+00000050bf67dc54534fdd53ddb20d0b8eb815d10af1732fe312e60000000000
+00000000add6d6bf61c16f566eb20e0d924475bd578572c61e6d340000000000
+0000000016d8d3d03ec76bcfdf3b0f0e13bc4c8d2f84c040cb837b0000000000
+00000000550c47b3365bd45d6f33110f1a4575cbf2c0521e0802000000000000
+000000000000e7ac36be625e7031131122455a0a2f0a99c6e700000000000000
+000000000000006a9e37d36270331613a545f181e53032e80000000000000000
+00000000000000005088c5d371311816a8464b7374ee89000000000000000000
+0000000000000000000077b654a29b18acc24a722a5500000000000000000000
+0000000000000000000000d78a9f9e9b3548c38ac90000000000000000000000
+00000000000000000000000000ef1f9e3cc20200000000000000000000000000
+0000000000000000000000000000e89736780000000000000000000000000000
+00000000000000000000000000000060e0000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+}
diff --git a/libgo/go/mime/testdata/test.types.plan9 b/libgo/go/mime/testdata/test.types.plan9
new file mode 100644 (file)
index 0000000..19dbf41
--- /dev/null
@@ -0,0 +1,8 @@
+# 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.
+
+
+ # mime package test
+.t1            application     test            -               y # Simple test 
+.t2            text            test            -               y # Text test   
index 072da2552bc5d06d8e109657d0ddfd9c19ad1fec..681dff193aa1dd6ef5d0f31c88ed3c9d0ceb85c7 100644 (file)
@@ -5173,3 +5173,142 @@ func TestServerDuplicateBackgroundRead(t *testing.T) {
        }
        wg.Wait()
 }
+
+// Test that the bufio.Reader returned by Hijack includes any buffered
+// byte (from the Server's backgroundRead) in its buffer. We want the
+// Handler code to be able to tell that a byte is available via
+// bufio.Reader.Buffered(), without resorting to Reading it
+// (potentially blocking) to get at it.
+func TestServerHijackGetsBackgroundByte(t *testing.T) {
+       if runtime.GOOS == "plan9" {
+               t.Skip("skipping test; see https://golang.org/issue/18657")
+       }
+       setParallel(t)
+       defer afterTest(t)
+       done := make(chan struct{})
+       inHandler := make(chan bool, 1)
+       ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+               defer close(done)
+
+               // Tell the client to send more data after the GET request.
+               inHandler <- true
+
+               // Wait until the HTTP server sees the extra data
+               // after the GET request. The HTTP server fires the
+               // close notifier here, assuming it's a pipelined
+               // request, as documented.
+               select {
+               case <-w.(CloseNotifier).CloseNotify():
+               case <-time.After(5 * time.Second):
+                       t.Error("timeout")
+                       return
+               }
+
+               conn, buf, err := w.(Hijacker).Hijack()
+               if err != nil {
+                       t.Error(err)
+                       return
+               }
+               defer conn.Close()
+               n := buf.Reader.Buffered()
+               if n != 1 {
+                       t.Errorf("buffered data = %d; want 1", n)
+               }
+               peek, err := buf.Reader.Peek(3)
+               if string(peek) != "foo" || err != nil {
+                       t.Errorf("Peek = %q, %v; want foo, nil", peek, err)
+               }
+       }))
+       defer ts.Close()
+
+       cn, err := net.Dial("tcp", ts.Listener.Addr().String())
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer cn.Close()
+       if _, err := cn.Write([]byte("GET / HTTP/1.1\r\nHost: e.com\r\n\r\n")); err != nil {
+               t.Fatal(err)
+       }
+       <-inHandler
+       if _, err := cn.Write([]byte("foo")); err != nil {
+               t.Fatal(err)
+       }
+
+       if err := cn.(*net.TCPConn).CloseWrite(); err != nil {
+               t.Fatal(err)
+       }
+       select {
+       case <-done:
+       case <-time.After(2 * time.Second):
+               t.Error("timeout")
+       }
+}
+
+// Like TestServerHijackGetsBackgroundByte above but sending a
+// immediate 1MB of data to the server to fill up the server's 4KB
+// buffer.
+func TestServerHijackGetsBackgroundByte_big(t *testing.T) {
+       if runtime.GOOS == "plan9" {
+               t.Skip("skipping test; see https://golang.org/issue/18657")
+       }
+       setParallel(t)
+       defer afterTest(t)
+       done := make(chan struct{})
+       const size = 8 << 10
+       ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+               defer close(done)
+
+               // Wait until the HTTP server sees the extra data
+               // after the GET request. The HTTP server fires the
+               // close notifier here, assuming it's a pipelined
+               // request, as documented.
+               select {
+               case <-w.(CloseNotifier).CloseNotify():
+               case <-time.After(5 * time.Second):
+                       t.Error("timeout")
+                       return
+               }
+
+               conn, buf, err := w.(Hijacker).Hijack()
+               if err != nil {
+                       t.Error(err)
+                       return
+               }
+               defer conn.Close()
+               slurp, err := ioutil.ReadAll(buf.Reader)
+               if err != nil {
+                       t.Error("Copy: %v", err)
+               }
+               allX := true
+               for _, v := range slurp {
+                       if v != 'x' {
+                               allX = false
+                       }
+               }
+               if len(slurp) != size {
+                       t.Errorf("read %d; want %d", len(slurp), size)
+               } else if !allX {
+                       t.Errorf("read %q; want %d 'x'", slurp, size)
+               }
+       }))
+       defer ts.Close()
+
+       cn, err := net.Dial("tcp", ts.Listener.Addr().String())
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer cn.Close()
+       if _, err := fmt.Fprintf(cn, "GET / HTTP/1.1\r\nHost: e.com\r\n\r\n%s",
+               strings.Repeat("x", size)); err != nil {
+               t.Fatal(err)
+       }
+       if err := cn.(*net.TCPConn).CloseWrite(); err != nil {
+               t.Fatal(err)
+       }
+
+       select {
+       case <-done:
+       case <-time.After(2 * time.Second):
+               t.Error("timeout")
+       }
+}
index 96236489bd9faf0e404a01aed92bafcab19ee33f..df70a15193bc6adb0127f250d4c2e3edb033e6e2 100644 (file)
@@ -164,7 +164,7 @@ type Flusher interface {
 // should always test for this ability at runtime.
 type Hijacker interface {
        // Hijack lets the caller take over the connection.
-       // After a call to Hijack(), the HTTP server library
+       // After a call to Hijack the HTTP server library
        // will not do anything else with the connection.
        //
        // It becomes the caller's responsibility to manage
@@ -174,6 +174,9 @@ type Hijacker interface {
        // already set, depending on the configuration of the
        // Server. It is the caller's responsibility to set
        // or clear those deadlines as needed.
+       //
+       // The returned bufio.Reader may contain unprocessed buffered
+       // data from the client.
        Hijack() (net.Conn, *bufio.ReadWriter, error)
 }
 
@@ -293,6 +296,11 @@ func (c *conn) hijackLocked() (rwc net.Conn, buf *bufio.ReadWriter, err error) {
        rwc.SetDeadline(time.Time{})
 
        buf = bufio.NewReadWriter(c.bufr, bufio.NewWriter(rwc))
+       if c.r.hasByte {
+               if _, err := c.bufr.Peek(c.bufr.Buffered() + 1); err != nil {
+                       return nil, nil, fmt.Errorf("unexpected Peek failure reading buffered byte: %v", err)
+               }
+       }
        c.setState(rwc, StateHijacked)
        return
 }
index d5ddf6a1232a019e97d1d48f9f423d58d8af7dc0..a58b1839cc6e09e30d5f1a975a6f8394008dae98 100644 (file)
@@ -36,6 +36,7 @@ import (
        "strconv"
        "strings"
        "sync"
+       "sync/atomic"
        "testing"
        "time"
 )
@@ -2545,6 +2546,13 @@ type closerFunc func() error
 
 func (f closerFunc) Close() error { return f() }
 
+type writerFuncConn struct {
+       net.Conn
+       write func(p []byte) (n int, err error)
+}
+
+func (c writerFuncConn) Write(p []byte) (n int, err error) { return c.write(p) }
+
 // Issue 4677. If we try to reuse a connection that the server is in the
 // process of closing, we may end up successfully writing out our request (or a
 // portion of our request) only to find a connection error when we try to read
@@ -2557,66 +2565,78 @@ func (f closerFunc) Close() error { return f() }
 func TestRetryIdempotentRequestsOnError(t *testing.T) {
        defer afterTest(t)
 
+       var (
+               mu     sync.Mutex
+               logbuf bytes.Buffer
+       )
+       logf := func(format string, args ...interface{}) {
+               mu.Lock()
+               defer mu.Unlock()
+               fmt.Fprintf(&logbuf, format, args...)
+               logbuf.WriteByte('\n')
+       }
+
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+               logf("Handler")
+               w.Header().Set("X-Status", "ok")
        }))
        defer ts.Close()
 
-       tr := &Transport{}
+       var writeNumAtomic int32
+       tr := &Transport{
+               Dial: func(network, addr string) (net.Conn, error) {
+                       logf("Dial")
+                       c, err := net.Dial(network, ts.Listener.Addr().String())
+                       if err != nil {
+                               logf("Dial error: %v", err)
+                               return nil, err
+                       }
+                       return &writerFuncConn{
+                               Conn: c,
+                               write: func(p []byte) (n int, err error) {
+                                       if atomic.AddInt32(&writeNumAtomic, 1) == 2 {
+                                               logf("intentional write failure")
+                                               return 0, errors.New("second write fails")
+                                       }
+                                       logf("Write(%q)", p)
+                                       return c.Write(p)
+                               },
+                       }, nil
+               },
+       }
+       defer tr.CloseIdleConnections()
        c := &Client{Transport: tr}
 
-       const N = 2
-       retryc := make(chan struct{}, N)
        SetRoundTripRetried(func() {
-               retryc <- struct{}{}
+               logf("Retried.")
        })
        defer SetRoundTripRetried(nil)
 
-       for n := 0; n < 100; n++ {
-               // open 2 conns
-               errc := make(chan error, N)
-               for i := 0; i < N; i++ {
-                       // start goroutines, send on errc
-                       go func() {
-                               res, err := c.Get(ts.URL)
-                               if err == nil {
-                                       res.Body.Close()
-                               }
-                               errc <- err
-                       }()
-               }
-               for i := 0; i < N; i++ {
-                       if err := <-errc; err != nil {
-                               t.Fatal(err)
-                       }
-               }
-
-               ts.CloseClientConnections()
-               for i := 0; i < N; i++ {
-                       go func() {
-                               res, err := c.Get(ts.URL)
-                               if err == nil {
-                                       res.Body.Close()
-                               }
-                               errc <- err
-                       }()
+       for i := 0; i < 3; i++ {
+               res, err := c.Get("http://fake.golang/")
+               if err != nil {
+                       t.Fatalf("i=%d: Get = %v", i, err)
                }
+               res.Body.Close()
+       }
 
-               for i := 0; i < N; i++ {
-                       if err := <-errc; err != nil {
-                               t.Fatal(err)
-                       }
-               }
-               for i := 0; i < N; i++ {
-                       select {
-                       case <-retryc:
-                               // we triggered a retry, test was successful
-                               t.Logf("finished after %d runs\n", n)
-                               return
-                       default:
-                       }
-               }
+       mu.Lock()
+       got := logbuf.String()
+       mu.Unlock()
+       const want = `Dial
+Write("GET / HTTP/1.1\r\nHost: fake.golang\r\nUser-Agent: Go-http-client/1.1\r\nAccept-Encoding: gzip\r\n\r\n")
+Handler
+intentional write failure
+Retried.
+Dial
+Write("GET / HTTP/1.1\r\nHost: fake.golang\r\nUser-Agent: Go-http-client/1.1\r\nAccept-Encoding: gzip\r\n\r\n")
+Handler
+Write("GET / HTTP/1.1\r\nHost: fake.golang\r\nUser-Agent: Go-http-client/1.1\r\nAccept-Encoding: gzip\r\n\r\n")
+Handler
+`
+       if got != want {
+               t.Errorf("Log of events differs. Got:\n%s\nWant:\n%s", got, want)
        }
-       t.Fatal("did not trigger any retries")
 }
 
 // Issue 6981
index 10a74c2062a636c2f0c91110db6dd74c0914174b..dcc8d762bf810f1e6372dd081f6d6a4f320565a8 100644 (file)
@@ -52,12 +52,15 @@ var sysdir = func() *sysDir {
        case "darwin":
                switch runtime.GOARCH {
                case "arm", "arm64":
+                       /// At this point the test harness has not had a chance
+                       // to move us into the ./src/os directory, so the
+                       // current working directory is the root of the app.
                        wd, err := syscall.Getwd()
                        if err != nil {
                                wd = err.Error()
                        }
                        return &sysDir{
-                               filepath.Join(wd, "..", ".."),
+                               wd,
                                []string{
                                        "ResourceRules.plist",
                                        "Info.plist",
index f51e95fd734082aea20b0d9fd46af1821b3c96e9..6b143df00e11604a07d7ef723196cffeb3c17cef 100644 (file)
@@ -26,6 +26,8 @@ import (
        "unsafe"
 )
 
+var sink interface{}
+
 func TestBool(t *testing.T) {
        v := ValueOf(true)
        if v.Bool() != true {
@@ -5348,6 +5350,72 @@ func TestCallGC(t *testing.T) {
        f2("four", "five5", "six666", "seven77", "eight888")
 }
 
+// Issue 18635 (function version).
+func TestKeepFuncLive(t *testing.T) {
+       // Test that we keep makeFuncImpl live as long as it is
+       // referenced on the stack.
+       typ := TypeOf(func(i int) {})
+       var f, g func(in []Value) []Value
+       f = func(in []Value) []Value {
+               clobber()
+               i := int(in[0].Int())
+               if i > 0 {
+                       // We can't use Value.Call here because
+                       // runtime.call* will keep the makeFuncImpl
+                       // alive. However, by converting it to an
+                       // interface value and calling that,
+                       // reflect.callReflect is the only thing that
+                       // can keep the makeFuncImpl live.
+                       //
+                       // Alternate between f and g so that if we do
+                       // reuse the memory prematurely it's more
+                       // likely to get obviously corrupted.
+                       MakeFunc(typ, g).Interface().(func(i int))(i - 1)
+               }
+               return nil
+       }
+       g = func(in []Value) []Value {
+               clobber()
+               i := int(in[0].Int())
+               MakeFunc(typ, f).Interface().(func(i int))(i)
+               return nil
+       }
+       MakeFunc(typ, f).Call([]Value{ValueOf(10)})
+}
+
+// Issue 18635 (method version).
+type KeepMethodLive struct{}
+
+func (k KeepMethodLive) Method1(i int) {
+       clobber()
+       if i > 0 {
+               ValueOf(k).MethodByName("Method2").Interface().(func(i int))(i - 1)
+       }
+}
+
+func (k KeepMethodLive) Method2(i int) {
+       clobber()
+       ValueOf(k).MethodByName("Method1").Interface().(func(i int))(i)
+}
+
+func TestKeepMethodLive(t *testing.T) {
+       // Test that we keep methodValue live as long as it is
+       // referenced on the stack.
+       KeepMethodLive{}.Method1(10)
+}
+
+// clobber tries to clobber unreachable memory.
+func clobber() {
+       runtime.GC()
+       for i := 1; i < 32; i++ {
+               for j := 0; j < 10; j++ {
+                       obj := make([]*byte, i)
+                       sink = obj
+               }
+       }
+       runtime.GC()
+}
+
 type funcLayoutTest struct {
        rcvr, t                  Type
        size, argsize, retOffset uintptr
index 07a355d5e41f3ce4ca1e656030082d33231b68fb..29d89f7176d6501e45d9a002dcd75ba945905127 100644 (file)
@@ -1677,7 +1677,7 @@ func FuncOf(in, out []Type, variadic bool) Type {
        *ft = *prototype
 
        // Build a hash and minimally populate ft.
-       var hash uint32 = 8
+       var hash uint32
        var fin, fout []*rtype
        shift := uint(1)
        for _, in := range in {
@@ -1697,6 +1697,7 @@ func FuncOf(in, out []Type, variadic bool) Type {
                hash++
        }
        hash <<= 4
+       hash += 8
        ft.hash = hash
        ft.in = fin
        ft.out = fout
diff --git a/libgo/go/runtime/testdata/testprogcgo/threadpanic_unix.c b/libgo/go/runtime/testdata/testprogcgo/threadpanic_unix.c
new file mode 100644 (file)
index 0000000..c426452
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2015 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.
+
+// +build !plan9,!windows
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+
+void gopanic(void);
+
+static void*
+die(void* x)
+{
+       gopanic();
+       return 0;
+}
+
+void
+start(void)
+{
+       pthread_t t;
+       if(pthread_create(&t, 0, die, 0) != 0)
+               printf("pthread_create failed\n");
+}
diff --git a/libgo/go/runtime/testdata/testprogcgo/threadpanic_windows.c b/libgo/go/runtime/testdata/testprogcgo/threadpanic_windows.c
new file mode 100644 (file)
index 0000000..ba66d0f
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2015 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.
+
+#include <process.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+void gopanic(void);
+
+static unsigned int __attribute__((__stdcall__))
+die(void* x)
+{
+       gopanic();
+       return 0;
+}
+
+void
+start(void)
+{
+       if(_beginthreadex(0, 0, die, 0, 0, 0) != 0)
+               printf("_beginthreadex failed\n");
+}
diff --git a/libgo/go/runtime/testdata/testprogcgo/tracebackctxt_c.c b/libgo/go/runtime/testdata/testprogcgo/tracebackctxt_c.c
new file mode 100644 (file)
index 0000000..900cada
--- /dev/null
@@ -0,0 +1,91 @@
+// Copyright 2016 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.
+
+// The C definitions for tracebackctxt.go. That file uses //export so
+// it can't put function definitions in the "C" import comment.
+
+#include <stdlib.h>
+#include <stdint.h>
+
+// Functions exported from Go.
+extern void G1(void);
+extern void G2(void);
+
+void C1() {
+       G1();
+}
+
+void C2() {
+       G2();
+}
+
+struct cgoContextArg {
+       uintptr_t context;
+};
+
+struct cgoTracebackArg {
+       uintptr_t  context;
+       uintptr_t  sigContext;
+       uintptr_t* buf;
+       uintptr_t  max;
+};
+
+struct cgoSymbolizerArg {
+       uintptr_t   pc;
+       const char* file;
+       uintptr_t   lineno;
+       const char* func;
+       uintptr_t   entry;
+       uintptr_t   more;
+       uintptr_t   data;
+};
+
+// Uses atomic adds and subtracts to catch the possibility of
+// erroneous calls from multiple threads; that should be impossible in
+// this test case, but we check just in case.
+static int contextCount;
+
+int getContextCount() {
+       return __sync_add_and_fetch(&contextCount, 0);
+}
+
+void tcContext(void* parg) {
+       struct cgoContextArg* arg = (struct cgoContextArg*)(parg);
+       if (arg->context == 0) {
+               arg->context = __sync_add_and_fetch(&contextCount, 1);
+       } else {
+               if (arg->context != __sync_add_and_fetch(&contextCount, 0)) {
+                       abort();
+               }
+               __sync_sub_and_fetch(&contextCount, 1);
+       }
+}
+
+void tcTraceback(void* parg) {
+       int base, i;
+       struct cgoTracebackArg* arg = (struct cgoTracebackArg*)(parg);
+       if (arg->context == 0) {
+               // This shouldn't happen in this program.
+               abort();
+       }
+       // Return a variable number of PC values.
+       base = arg->context << 8;
+       for (i = 0; i < arg->context; i++) {
+               if (i < arg->max) {
+                       arg->buf[i] = base + i;
+               }
+       }
+}
+
+void tcSymbolizer(void *parg) {
+       struct cgoSymbolizerArg* arg = (struct cgoSymbolizerArg*)(parg);
+       if (arg->pc == 0) {
+               return;
+       }
+       // Report two lines per PC returned by traceback, to test more handling.
+       arg->more = arg->file == NULL;
+       arg->file = "tracebackctxt.go";
+       arg->func = "cFunction";
+       arg->lineno = arg->pc + (arg->more << 16);
+}
index c033ce5fecb1286965089adde2a4919ff2a4da84..bcebb418c42572e1c26aa3427926667c596adf5b 100644 (file)
@@ -219,7 +219,7 @@ func (b *B) run1() bool {
        }
        // Only print the output if we know we are not going to proceed.
        // Otherwise it is printed in processBench.
-       if b.hasSub || b.finished {
+       if atomic.LoadInt32(&b.hasSub) != 0 || b.finished {
                tag := "BENCH"
                if b.skipped {
                        tag = "SKIP"
@@ -460,10 +460,13 @@ func (ctx *benchContext) processBench(b *B) {
 //
 // A subbenchmark is like any other benchmark. A benchmark that calls Run at
 // least once will not be measured itself and will be called once with N=1.
+//
+// Run may be called simultaneously from multiple goroutines, but all such
+// calls must happen before the outer benchmark function for b returns.
 func (b *B) Run(name string, f func(b *B)) bool {
        // Since b has subbenchmarks, we will no longer run it as a benchmark itself.
        // Release the lock and acquire it on exit to ensure locks stay paired.
-       b.hasSub = true
+       atomic.StoreInt32(&b.hasSub, 1)
        benchmarkLock.Unlock()
        defer benchmarkLock.Lock()
 
index 8d5d9206f03563633e457afceb37b035d861f2cc..bb7b3e09255ea167de3001248b55c83e20b21109 100644 (file)
@@ -6,6 +6,7 @@ package testing
 
 import (
        "bytes"
+       "fmt"
        "regexp"
        "strings"
        "sync/atomic"
@@ -515,3 +516,19 @@ func TestBenchmarkOutput(t *T) {
        Benchmark(func(b *B) { b.Error("do not print this output") })
        Benchmark(func(b *B) {})
 }
+
+func TestParallelSub(t *T) {
+       c := make(chan int)
+       block := make(chan int)
+       for i := 0; i < 10; i++ {
+               go func(i int) {
+                       <-block
+                       t.Run(fmt.Sprint(i), func(t *T) {})
+                       c <- 1
+               }(i)
+       }
+       close(block)
+       for i := 0; i < 10; i++ {
+               <-c
+       }
+}
index 8364c8e414405a437cb7cc24ebc4950b1d7848c9..bbeb95692a1dd3d81bd331710a56cd39f0a21139 100644 (file)
@@ -216,6 +216,7 @@ import (
        "strconv"
        "strings"
        "sync"
+       "sync/atomic"
        "time"
 )
 
@@ -267,8 +268,8 @@ type common struct {
        skipped    bool         // Test of benchmark has been skipped.
        finished   bool         // Test function has completed.
        done       bool         // Test is finished and all subtests have completed.
-       hasSub     bool
-       raceErrors int // number of races detected during test
+       hasSub     int32        // written atomically
+       raceErrors int          // number of races detected during test
 
        parent   *common
        level    int       // Nesting depth of test or benchmark.
@@ -645,7 +646,7 @@ func tRunner(t *T, fn func(t *T)) {
                // Do not lock t.done to allow race detector to detect race in case
                // the user does not appropriately synchronizes a goroutine.
                t.done = true
-               if t.parent != nil && !t.hasSub {
+               if t.parent != nil && atomic.LoadInt32(&t.hasSub) == 0 {
                        t.setRan()
                }
                t.signal <- true
@@ -659,8 +660,11 @@ func tRunner(t *T, fn func(t *T)) {
 
 // Run runs f as a subtest of t called name. It reports whether f succeeded.
 // Run will block until all its parallel subtests have completed.
+//
+// Run may be called simultaneously from multiple goroutines, but all such
+// calls must happen before the outer test function for t returns.
 func (t *T) Run(name string, f func(t *T)) bool {
-       t.hasSub = true
+       atomic.StoreInt32(&t.hasSub, 1)
        testName, ok := t.context.match.fullName(&t.common, name)
        if !ok {
                return true
index 8a92a2ecd4d0dd6b323fedc37d4f0b7f08304f07..c750a5d808b3b2fcf50654f1f38162a324f79757 100755 (executable)
@@ -147,7 +147,7 @@ done
 
 (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
   skip=false
-  case "$f" in
+  case "$d" in
   ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/internal/browser/*)
     ;;
   ./cmd/*)