From: Ian Lance Taylor Date: Thu, 3 Dec 2020 18:04:19 +0000 (-0800) Subject: testsuite: update existing Go tests to source repo X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a3b9f48c3743c6737acdc93074d058c1603be2a;p=gcc.git testsuite: update existing Go tests to source repo This updates a bunch of existing Go tests to the contents of the source repo. This does not add any of the newer tests. --- diff --git a/gcc/testsuite/go.test/test/alias.go b/gcc/testsuite/go.test/test/alias.go index ec93a2d101f..aabaef8f20e 100644 --- a/gcc/testsuite/go.test/test/alias.go +++ b/gcc/testsuite/go.test/test/alias.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/alias1.go b/gcc/testsuite/go.test/test/alias1.go index 42cf6934096..5707917d201 100644 --- a/gcc/testsuite/go.test/test/alias1.go +++ b/gcc/testsuite/go.test/test/alias1.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/append.go b/gcc/testsuite/go.test/test/append.go index 3f6251ee507..3d160634060 100644 --- a/gcc/testsuite/go.test/test/append.go +++ b/gcc/testsuite/go.test/test/append.go @@ -13,14 +13,12 @@ import ( "reflect" ) - func verify(name string, result, expected interface{}) { if !reflect.DeepEqual(result, expected) { panic(name) } } - func main() { for _, t := range tests { verify(t.name, t.result, t.expected) @@ -30,6 +28,10 @@ func main() { verifyType() } +var ( + zero int = 0 + one int = 1 +) var tests = []struct { name string @@ -49,7 +51,6 @@ var tests = []struct { {"bool i", append([]bool{true, false, true}, []bool{true}...), []bool{true, false, true, true}}, {"bool j", append([]bool{true, false, true}, []bool{true, true, true}...), []bool{true, false, true, true, true, true}}, - {"byte a", append([]byte{}), []byte{}}, {"byte b", append([]byte{}, 0), []byte{0}}, {"byte c", append([]byte{}, 0, 1, 2, 3), []byte{0, 1, 2, 3}}, @@ -84,7 +85,6 @@ var tests = []struct { {"int16 i", append([]int16{0, 1, 2}, []int16{3}...), []int16{0, 1, 2, 3}}, {"int16 j", append([]int16{0, 1, 2}, []int16{3, 4, 5}...), []int16{0, 1, 2, 3, 4, 5}}, - {"uint32 a", append([]uint32{}), []uint32{}}, {"uint32 b", append([]uint32{}, 0), []uint32{0}}, {"uint32 c", append([]uint32{}, 0, 1, 2, 3), []uint32{0, 1, 2, 3}}, @@ -99,7 +99,6 @@ var tests = []struct { {"uint32 i", append([]uint32{0, 1, 2}, []uint32{3}...), []uint32{0, 1, 2, 3}}, {"uint32 j", append([]uint32{0, 1, 2}, []uint32{3, 4, 5}...), []uint32{0, 1, 2, 3, 4, 5}}, - {"float64 a", append([]float64{}), []float64{}}, {"float64 b", append([]float64{}, 0), []float64{0}}, {"float64 c", append([]float64{}, 0, 1, 2, 3), []float64{0, 1, 2, 3}}, @@ -114,7 +113,6 @@ var tests = []struct { {"float64 i", append([]float64{0, 1, 2}, []float64{3}...), []float64{0, 1, 2, 3}}, {"float64 j", append([]float64{0, 1, 2}, []float64{3, 4, 5}...), []float64{0, 1, 2, 3, 4, 5}}, - {"complex128 a", append([]complex128{}), []complex128{}}, {"complex128 b", append([]complex128{}, 0), []complex128{0}}, {"complex128 c", append([]complex128{}, 0, 1, 2, 3), []complex128{0, 1, 2, 3}}, @@ -129,7 +127,6 @@ var tests = []struct { {"complex128 i", append([]complex128{0, 1, 2}, []complex128{3}...), []complex128{0, 1, 2, 3}}, {"complex128 j", append([]complex128{0, 1, 2}, []complex128{3, 4, 5}...), []complex128{0, 1, 2, 3, 4, 5}}, - {"string a", append([]string{}), []string{}}, {"string b", append([]string{}, "0"), []string{"0"}}, {"string c", append([]string{}, "0", "1", "2", "3"), []string{"0", "1", "2", "3"}}, @@ -143,8 +140,19 @@ var tests = []struct { {"string i", append([]string{"0", "1", "2"}, []string{"3"}...), []string{"0", "1", "2", "3"}}, {"string j", append([]string{"0", "1", "2"}, []string{"3", "4", "5"}...), []string{"0", "1", "2", "3", "4", "5"}}, -} + {"make a", append([]string{}, make([]string, 0)...), []string{}}, + {"make b", append([]string(nil), make([]string, 0)...), []string(nil)}, + + {"make c", append([]struct{}{}, make([]struct{}, 0)...), []struct{}{}}, + {"make d", append([]struct{}{}, make([]struct{}, 2)...), make([]struct{}, 2)}, + + {"make e", append([]int{0, 1}, make([]int, 0)...), []int{0, 1}}, + {"make f", append([]int{0, 1}, make([]int, 2)...), []int{0, 1, 0, 0}}, + + {"make g", append([]*int{&zero, &one}, make([]*int, 0)...), []*int{&zero, &one}}, + {"make h", append([]*int{&zero, &one}, make([]*int, 2)...), []*int{&zero, &one, nil, nil}}, +} func verifyStruct() { type T struct { @@ -185,7 +193,6 @@ func verifyStruct() { verify("struct m", append(s, e...), r) } - func verifyInterface() { type T interface{} type S []T diff --git a/gcc/testsuite/go.test/test/assign.go b/gcc/testsuite/go.test/test/assign.go index da0192f838d..62fd3b5be3c 100644 --- a/gcc/testsuite/go.test/test/assign.go +++ b/gcc/testsuite/go.test/test/assign.go @@ -53,4 +53,16 @@ func main() { _ = x _ = y } + { + var x = 1 + { + x, x := 2, 3 // ERROR ".*x.* repeated on left side of :=" + _ = x + } + _ = x + } + { + a, a := 1, 2 // ERROR ".*a.* repeated on left side of :=" + _ = a + } } diff --git a/gcc/testsuite/go.test/test/bench/garbage/Makefile b/gcc/testsuite/go.test/test/bench/garbage/Makefile index 98838453aa6..c10ef0a0f8c 100644 --- a/gcc/testsuite/go.test/test/bench/garbage/Makefile +++ b/gcc/testsuite/go.test/test/bench/garbage/Makefile @@ -1,4 +1,4 @@ -# Copyright 2010 The Go Authors. All rights reserved. +# Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/bench/garbage/parser.go b/gcc/testsuite/go.test/test/bench/garbage/parser.go index d85110b63d4..817afa91b08 100644 --- a/gcc/testsuite/go.test/test/bench/garbage/parser.go +++ b/gcc/testsuite/go.test/test/bench/garbage/parser.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -85,7 +85,7 @@ func main() { var t0 time.Time var numGC uint32 var pauseTotalNs uint64 - pkgroot := runtime.GOROOT() + "/src/pkg/" + pkgroot := runtime.GOROOT() + "/src/" for pass := 0; pass < 2; pass++ { // Once the heap is grown to full size, reset counters. // This hides the start-up pauses, which are much smaller diff --git a/gcc/testsuite/go.test/test/bench/garbage/stats.go b/gcc/testsuite/go.test/test/bench/garbage/stats.go index 6dc0aeb2331..937e00fa517 100644 --- a/gcc/testsuite/go.test/test/bench/garbage/stats.go +++ b/gcc/testsuite/go.test/test/bench/garbage/stats.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/bench/garbage/tree.go b/gcc/testsuite/go.test/test/bench/garbage/tree.go index 0a3ec234db8..524cfebc73f 100644 --- a/gcc/testsuite/go.test/test/bench/garbage/tree.go +++ b/gcc/testsuite/go.test/test/bench/garbage/tree.go @@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE. */ /* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ + * https://benchmarksgame-team.pages.debian.net/benchmarksgame/ * * contributed by The Go Authors. * based on C program by Kevin Carson diff --git a/gcc/testsuite/go.test/test/bench/garbage/tree2.go b/gcc/testsuite/go.test/test/bench/garbage/tree2.go index a171c696bbc..a70a1062390 100644 --- a/gcc/testsuite/go.test/test/bench/garbage/tree2.go +++ b/gcc/testsuite/go.test/test/bench/garbage/tree2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/binarytree_test.go b/gcc/testsuite/go.test/test/bench/go1/binarytree_test.go index c64c4b88166..e5e49d502cf 100644 --- a/gcc/testsuite/go.test/test/bench/go1/binarytree_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/binarytree_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/fannkuch_test.go b/gcc/testsuite/go.test/test/bench/go1/fannkuch_test.go index ae45bfd8813..0cf61158059 100644 --- a/gcc/testsuite/go.test/test/bench/go1/fannkuch_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/fannkuch_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/fasta_test.go b/gcc/testsuite/go.test/test/bench/go1/fasta_test.go index bff056fa90c..af4fbac274c 100644 --- a/gcc/testsuite/go.test/test/bench/go1/fasta_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/fasta_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -12,11 +12,11 @@ var fastabytes = makefasta() func makefasta() []byte { var n int = 25e6 - if runtime.GOARCH == "arm" { + if runtime.GOARCH == "arm" || runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" { // TODO(dfc) remove this limitation after precise gc. - // A value of 25e6 consumes 465mb of heap on 32bit - // platforms, which is too much for most ARM systems. - // A value of 25e5 produces a memory layout that + // A value of 25e6 consumes 465mb of heap on 32bit + // platforms, which is too much for some systems. + // A value of 25e5 produces a memory layout that // confuses the gc on 32bit platforms. So 25e4 it is. n = 25e4 } diff --git a/gcc/testsuite/go.test/test/bench/go1/gob_test.go b/gcc/testsuite/go.test/test/bench/go1/gob_test.go index b172b805ad2..224beff6801 100644 --- a/gcc/testsuite/go.test/test/bench/go1/gob_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/gob_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/gzip_test.go b/gcc/testsuite/go.test/test/bench/go1/gzip_test.go index fe4c480eb84..648eec5d457 100644 --- a/gcc/testsuite/go.test/test/bench/go1/gzip_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/gzip_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/http_test.go b/gcc/testsuite/go.test/test/bench/go1/http_test.go index 34e789f6658..7ece9b2ac54 100644 --- a/gcc/testsuite/go.test/test/bench/go1/http_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/http_test.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/json_test.go b/gcc/testsuite/go.test/test/bench/go1/json_test.go index 1d42619bdeb..5ff1f8b6506 100644 --- a/gcc/testsuite/go.test/test/bench/go1/json_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/json_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/jsondata_test.go b/gcc/testsuite/go.test/test/bench/go1/jsondata_test.go index cf0fac14806..281b6ca3562 100644 --- a/gcc/testsuite/go.test/test/bench/go1/jsondata_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/jsondata_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -1816,4 +1816,4 @@ zJE6zEudHD27ZzbOeSgpk/HnkQbT7twqaaJXNvUzMuUt1hyhU7ceZcph42+VTlXU cZ9UZZJyYojLjaeJHfJU1UZUEmBfLumu8yW5skuyE9uh2BmVxJZi6KxaXBNwSolw BqBcQLj3ucNZIYZLYtirLu3brW6UYgZgZJiDIGiwpsgg7g1AITkgM6FHITxDDnGt 4SDHzZbL5s8fec5PCq5DOzDRdWS+0h5Y2INZak1D29cpVyb2aVrV3Wlt7rQhLa3e -m3ZwPNcXywE2Qesk1XN24HvZ2Xa6nlm8Pf/xdyRThQkO1NjuAA== `) +m3ZwPNcXywE2Qesk1XN24HvZ2Xa6nlm8Pf/xdyRThQkO1NjuAA==`) diff --git a/gcc/testsuite/go.test/test/bench/go1/mandel_test.go b/gcc/testsuite/go.test/test/bench/go1/mandel_test.go index 888c5e4ea82..dd543b2bc86 100644 --- a/gcc/testsuite/go.test/test/bench/go1/mandel_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/mandel_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/parserdata_test.go b/gcc/testsuite/go.test/test/bench/go1/parserdata_test.go index 113e5e3e38e..8255d182cba 100644 --- a/gcc/testsuite/go.test/test/bench/go1/parserdata_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/parserdata_test.go @@ -1,10 +1,10 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Input for parser benchmark. -// This was generated by starting with a the contents of -// src/pkg/go/parser/parser.go at rev 9b455eb64690, then +// This was generated by starting with the contents of +// src/pkg/go/parser/parser.go at rev 9b455eb64690, then // compressing with bzip2 -9, then encoding to base64. // We compile the data into the binary so that the benchmark is // a stand-alone binary that can be copied easily from machine to diff --git a/gcc/testsuite/go.test/test/bench/go1/revcomp_test.go b/gcc/testsuite/go.test/test/bench/go1/revcomp_test.go index 6b6c1e5772b..7d57bd607b6 100644 --- a/gcc/testsuite/go.test/test/bench/go1/revcomp_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/revcomp_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/go1/template_test.go b/gcc/testsuite/go.test/test/bench/go1/template_test.go index db4839a488a..10dacaa35f6 100644 --- a/gcc/testsuite/go.test/test/bench/go1/template_test.go +++ b/gcc/testsuite/go.test/test/bench/go1/template_test.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.go b/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.go deleted file mode 100644 index 071a4e06e7b..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.go +++ /dev/null @@ -1,129 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * based on C program by Kevin Carson - */ - -package main - -import ( - "flag" - "fmt" -) - -var n = flag.Int("n", 15, "depth") - -type Node struct { - item int - left, right *Node -} - -type Arena struct { - head *Node -} - -var arena Arena - -func (n *Node) free() { - if n.left != nil { - n.left.free() - } - if n.right != nil { - n.right.free() - } - n.left = arena.head - arena.head = n -} - -func (a *Arena) New(item int, left, right *Node) *Node { - if a.head == nil { - nodes := make([]Node, 3< *n { - maxDepth = minDepth + 2 - } - stretchDepth := maxDepth + 1 - - check := bottomUpTree(0, stretchDepth).itemCheck() - fmt.Printf("stretch tree of depth %d\t check: %d\n", stretchDepth, check) - - longLivedTree := bottomUpTree(0, maxDepth) - - for depth := minDepth; depth <= maxDepth; depth += 2 { - iterations := 1 << uint(maxDepth-depth+minDepth) - check = 0 - - for i := 1; i <= iterations; i++ { - t := bottomUpTree(i, depth) - check += t.itemCheck() - t.free() - t = bottomUpTree(-i, depth) - check += t.itemCheck() - t.free() - } - fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations*2, depth, check) - } - fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck()) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.txt b/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.txt deleted file mode 100644 index f8286dd88bd..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/binary-tree-freelist.txt +++ /dev/null @@ -1,8 +0,0 @@ -stretch tree of depth 16 check: -1 -65536 trees of depth 4 check: -65536 -16384 trees of depth 6 check: -16384 -4096 trees of depth 8 check: -4096 -1024 trees of depth 10 check: -1024 -256 trees of depth 12 check: -256 -64 trees of depth 14 check: -64 -long lived tree of depth 15 check: -1 diff --git a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.c b/gcc/testsuite/go.test/test/bench/shootout/binary-tree.c deleted file mode 100644 index 9c35ac52a96..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.c +++ /dev/null @@ -1,164 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Shootout Benchmarks - http://shootout.alioth.debian.org/ - - contributed by Kevin Carson - compilation: - gcc -O3 -fomit-frame-pointer -funroll-loops -static binary-trees.c -lm - icc -O3 -ip -unroll -static binary-trees.c -lm -*/ - -#include -#include -#include - - -typedef struct tn { - struct tn* left; - struct tn* right; - long item; -} treeNode; - - -treeNode* NewTreeNode(treeNode* left, treeNode* right, long item) -{ - treeNode* new; - - new = (treeNode*)malloc(sizeof(treeNode)); - - new->left = left; - new->right = right; - new->item = item; - - return new; -} /* NewTreeNode() */ - - -long ItemCheck(treeNode* tree) -{ - if (tree->left == NULL) - return tree->item; - else - return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right); -} /* ItemCheck() */ - - -treeNode* BottomUpTree(long item, unsigned depth) -{ - if (depth > 0) - return NewTreeNode - ( - BottomUpTree(2 * item - 1, depth - 1), - BottomUpTree(2 * item, depth - 1), - item - ); - else - return NewTreeNode(NULL, NULL, item); -} /* BottomUpTree() */ - - -void DeleteTree(treeNode* tree) -{ - if (tree->left != NULL) - { - DeleteTree(tree->left); - DeleteTree(tree->right); - } - - free(tree); -} /* DeleteTree() */ - - -int main(int argc, char* argv[]) -{ - unsigned N, depth, minDepth, maxDepth, stretchDepth; - treeNode *stretchTree, *longLivedTree, *tempTree; - - N = atol(argv[1]); - - minDepth = 4; - - if ((minDepth + 2) > N) - maxDepth = minDepth + 2; - else - maxDepth = N; - - stretchDepth = maxDepth + 1; - - stretchTree = BottomUpTree(0, stretchDepth); - printf - ( - "stretch tree of depth %u\t check: %li\n", - stretchDepth, - ItemCheck(stretchTree) - ); - - DeleteTree(stretchTree); - - longLivedTree = BottomUpTree(0, maxDepth); - - for (depth = minDepth; depth <= maxDepth; depth += 2) - { - long i, iterations, check; - - iterations = pow(2, maxDepth - depth + minDepth); - - check = 0; - - for (i = 1; i <= iterations; i++) - { - tempTree = BottomUpTree(i, depth); - check += ItemCheck(tempTree); - DeleteTree(tempTree); - - tempTree = BottomUpTree(-i, depth); - check += ItemCheck(tempTree); - DeleteTree(tempTree); - } /* for(i = 1...) */ - - printf - ( - "%li\t trees of depth %u\t check: %li\n", - iterations * 2, - depth, - check - ); - } /* for(depth = minDepth...) */ - - printf - ( - "long lived tree of depth %u\t check: %li\n", - maxDepth, - ItemCheck(longLivedTree) - ); - - return 0; -} /* main() */ diff --git a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.go b/gcc/testsuite/go.test/test/bench/shootout/binary-tree.go deleted file mode 100644 index 9f867d11a70..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * based on C program by Kevin Carson - */ - -package main - -import ( - "flag" - "fmt" -) - -var n = flag.Int("n", 15, "depth") - -type Node struct { - item int - left, right *Node -} - -func bottomUpTree(item, depth int) *Node { - if depth <= 0 { - return &Node{item: item} - } - return &Node{item, bottomUpTree(2*item-1, depth-1), bottomUpTree(2*item, depth-1)} -} - -func (n *Node) itemCheck() int { - if n.left == nil { - return n.item - } - return n.item + n.left.itemCheck() - n.right.itemCheck() -} - -const minDepth = 4 - -func main() { - flag.Parse() - - maxDepth := *n - if minDepth+2 > *n { - maxDepth = minDepth + 2 - } - stretchDepth := maxDepth + 1 - - check := bottomUpTree(0, stretchDepth).itemCheck() - fmt.Printf("stretch tree of depth %d\t check: %d\n", stretchDepth, check) - - longLivedTree := bottomUpTree(0, maxDepth) - - for depth := minDepth; depth <= maxDepth; depth += 2 { - iterations := 1 << uint(maxDepth-depth+minDepth) - check = 0 - - for i := 1; i <= iterations; i++ { - check += bottomUpTree(i, depth).itemCheck() - check += bottomUpTree(-i, depth).itemCheck() - } - fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations*2, depth, check) - } - fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck()) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.txt b/gcc/testsuite/go.test/test/bench/shootout/binary-tree.txt deleted file mode 100644 index f8286dd88bd..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/binary-tree.txt +++ /dev/null @@ -1,8 +0,0 @@ -stretch tree of depth 16 check: -1 -65536 trees of depth 4 check: -65536 -16384 trees of depth 6 check: -16384 -4096 trees of depth 8 check: -4096 -1024 trees of depth 10 check: -1024 -256 trees of depth 12 check: -256 -64 trees of depth 14 check: -64 -long lived tree of depth 15 check: -1 diff --git a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.c b/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.c deleted file mode 100644 index ed78c31d7ba..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.c +++ /dev/null @@ -1,330 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - http://shootout.alioth.debian.org/ - - contributed by Michael Barker - based on a Java contribution by Luzius Meisser - - convert to C by dualamd -*/ - -#include -#include -#include - - -enum Colour -{ - blue = 0, - red = 1, - yellow = 2, - Invalid = 3 -}; - -const char* ColourName[] = {"blue", "red", "yellow"}; -const int STACK_SIZE = 32*1024; - -typedef unsigned int BOOL; -const BOOL TRUE = 1; -const BOOL FALSE = 0; - -int CreatureID = 0; - - -enum Colour doCompliment(enum Colour c1, enum Colour c2) -{ - switch (c1) - { - case blue: - switch (c2) - { - case blue: - return blue; - case red: - return yellow; - case yellow: - return red; - default: - goto errlb; - } - case red: - switch (c2) - { - case blue: - return yellow; - case red: - return red; - case yellow: - return blue; - default: - goto errlb; - } - case yellow: - switch (c2) - { - case blue: - return red; - case red: - return blue; - case yellow: - return yellow; - default: - goto errlb; - } - default: - break; - } - -errlb: - printf("Invalid colour\n"); - exit( 1 ); -} - -/* convert integer to number string: 1234 -> "one two three four" */ -char* formatNumber(int n, char* outbuf) -{ - int ochar = 0, ichar = 0; - int i; - char tmp[64]; - - const char* NUMBERS[] = - { - "zero", "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine" - }; - - ichar = sprintf(tmp, "%d", n); - - for (i = 0; i < ichar; i++) - ochar += sprintf( outbuf + ochar, " %s", NUMBERS[ tmp[i] - '0' ] ); - - return outbuf; -} - - -struct MeetingPlace -{ - pthread_mutex_t mutex; - int meetingsLeft; - struct Creature* firstCreature; -}; - -struct Creature -{ - pthread_t ht; - pthread_attr_t stack_att; - - struct MeetingPlace* place; - int count; - int sameCount; - - enum Colour colour; - int id; - - BOOL two_met; - BOOL sameid; -}; - - -void MeetingPlace_Init(struct MeetingPlace* m, int meetings ) -{ - pthread_mutex_init( &m->mutex, 0 ); - m->meetingsLeft = meetings; - m->firstCreature = 0; -} - - -BOOL Meet( struct Creature* cr) -{ - BOOL retval = TRUE; - - struct MeetingPlace* mp = cr->place; - pthread_mutex_lock( &(mp->mutex) ); - - if ( mp->meetingsLeft > 0 ) - { - if ( mp->firstCreature == 0 ) - { - cr->two_met = FALSE; - mp->firstCreature = cr; - } - else - { - struct Creature* first; - enum Colour newColour; - - first = mp->firstCreature; - newColour = doCompliment( cr->colour, first->colour ); - - cr->sameid = cr->id == first->id; - cr->colour = newColour; - cr->two_met = TRUE; - - first->sameid = cr->sameid; - first->colour = newColour; - first->two_met = TRUE; - - mp->firstCreature = 0; - mp->meetingsLeft--; - } - } - else - retval = FALSE; - - pthread_mutex_unlock( &(mp->mutex) ); - return retval; -} - - -void* CreatureThreadRun(void* param) -{ - struct Creature* cr = (struct Creature*)param; - - while (TRUE) - { - if ( Meet(cr) ) - { - while (cr->two_met == FALSE) - sched_yield(); - - if (cr->sameid) - cr->sameCount++; - cr->count++; - } - else - break; - } - - return 0; -} - -void Creature_Init( struct Creature *cr, struct MeetingPlace* place, enum Colour colour ) -{ - cr->place = place; - cr->count = cr->sameCount = 0; - - cr->id = ++CreatureID; - cr->colour = colour; - cr->two_met = FALSE; - - pthread_attr_init( &cr->stack_att ); - pthread_attr_setstacksize( &cr->stack_att, STACK_SIZE ); - pthread_create( &cr->ht, &cr->stack_att, &CreatureThreadRun, (void*)(cr) ); -} - -/* format meeting times of each creature to string */ -char* Creature_getResult(struct Creature* cr, char* str) -{ - char numstr[256]; - formatNumber(cr->sameCount, numstr); - - sprintf( str, "%u%s", cr->count, numstr ); - return str; -} - - -void runGame( int n_meeting, int ncolor, const enum Colour* colours ) -{ - int i; - int total = 0; - char str[256]; - - struct MeetingPlace place; - struct Creature *creatures = (struct Creature*) calloc( ncolor, sizeof(struct Creature) ); - - MeetingPlace_Init( &place, n_meeting ); - - /* print initial color of each creature */ - for (i = 0; i < ncolor; i++) - { - printf( "%s ", ColourName[ colours[i] ] ); - Creature_Init( &(creatures[i]), &place, colours[i] ); - } - printf("\n"); - - /* wait for them to meet */ - for (i = 0; i < ncolor; i++) - pthread_join( creatures[i].ht, 0 ); - - /* print meeting times of each creature */ - for (i = 0; i < ncolor; i++) - { - printf( "%s\n", Creature_getResult(&(creatures[i]), str) ); - total += creatures[i].count; - } - - /* print total meeting times, should equal n_meeting */ - printf( "%s\n\n", formatNumber(total, str) ); - - /* cleaup & quit */ - pthread_mutex_destroy( &place.mutex ); - free( creatures ); -} - - -void printColours( enum Colour c1, enum Colour c2 ) -{ - printf( "%s + %s -> %s\n", - ColourName[c1], - ColourName[c2], - ColourName[doCompliment(c1, c2)] ); -} - -void printColoursTable(void) -{ - printColours(blue, blue); - printColours(blue, red); - printColours(blue, yellow); - printColours(red, blue); - printColours(red, red); - printColours(red, yellow); - printColours(yellow, blue); - printColours(yellow, red); - printColours(yellow, yellow); -} - -int main(int argc, char** argv) -{ - int n = (argc == 2) ? atoi(argv[1]) : 600; - - printColoursTable(); - printf("\n"); - - const enum Colour r1[] = { blue, red, yellow }; - const enum Colour r2[] = { blue, red, yellow, - red, yellow, blue, - red, yellow, red, blue }; - - runGame( n, sizeof(r1) / sizeof(r1[0]), r1 ); - runGame( n, sizeof(r2) / sizeof(r2[0]), r2 ); - - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.go b/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.go deleted file mode 100644 index 3395798620f..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "flag" - "fmt" - "strconv" -) - -const ( - blue = iota - red - yellow - ncol -) - -var complement = [...]int{ - red | red<<2: red, - red | yellow<<2: blue, - red | blue<<2: yellow, - yellow | red<<2: blue, - yellow | yellow<<2: yellow, - yellow | blue<<2: red, - blue | red<<2: yellow, - blue | yellow<<2: red, - blue | blue<<2: blue, -} - -var colname = [...]string{ - blue: "blue", - red: "red", - yellow: "yellow", -} - -// information about the current state of a creature. -type info struct { - colour int // creature's current colour. - name int // creature's name. -} - -// exclusive access data-structure kept inside meetingplace. -// if mate is nil, it indicates there's no creature currently waiting; -// otherwise the creature's info is stored in info, and -// it is waiting to receive its mate's information on the mate channel. -type rendez struct { - n int // current number of encounters. - mate chan<- info // creature waiting when non-nil. - info info // info about creature waiting. -} - -// result sent by each creature at the end of processing. -type result struct { - met int - same int -} - -var n = 600 - -func main() { - flag.Parse() - if flag.NArg() > 0 { - n, _ = strconv.Atoi(flag.Arg(0)) - } - - for c0 := 0; c0 < ncol; c0++ { - for c1 := 0; c1 < ncol; c1++ { - fmt.Printf("%s + %s -> %s\n", colname[c0], colname[c1], colname[complement[c0|c1<<2]]) - } - } - fmt.Print("\n") - - pallmall([]int{blue, red, yellow}) - pallmall([]int{blue, red, yellow, red, yellow, blue, red, yellow, red, blue}) -} - -func pallmall(cols []int) { - - // invariant: meetingplace always contains a value unless a creature - // is currently dealing with it (whereupon it must put it back). - meetingplace := make(chan rendez, 1) - meetingplace <- rendez{n: 0} - - ended := make(chan result) - msg := "" - for i, col := range cols { - go creature(info{col, i}, meetingplace, ended) - msg += " " + colname[col] - } - fmt.Println(msg) - tot := 0 - // wait for all results - for _ = range cols { - result := <-ended - tot += result.met - fmt.Printf("%v%v\n", result.met, spell(result.same, true)) - } - fmt.Printf("%v\n\n", spell(tot, true)) -} - -// in this function, variables ending in 0 refer to the local creature, -// variables ending in 1 to the creature we've met. -func creature(info0 info, meetingplace chan rendez, ended chan result) { - c0 := make(chan info) - met := 0 - same := 0 - for { - var othername int - // get access to rendez data and decide what to do. - switch r := <-meetingplace; { - case r.n >= n: - // if no more meetings left, then send our result data and exit. - meetingplace <- rendez{n: r.n} - ended <- result{met, same} - return - case r.mate == nil: - // no creature waiting; wait for someone to meet us, - // get their info and send our info in reply. - meetingplace <- rendez{n: r.n, info: info0, mate: c0} - info1 := <-c0 - othername = info1.name - info0.colour = complement[info0.colour|info1.colour<<2] - default: - // another creature is waiting for us with its info; - // increment meeting count, - // send them our info in reply. - r.n++ - meetingplace <- rendez{n: r.n, mate: nil} - r.mate <- info0 - othername = r.info.name - info0.colour = complement[info0.colour|r.info.colour<<2] - } - if othername == info0.name { - same++ - } - met++ - } -} - -var digits = [...]string{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"} - -func spell(n int, required bool) string { - if n == 0 && !required { - return "" - } - return spell(n/10, false) + " " + digits[n%10] -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.txt b/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.txt deleted file mode 100644 index 6016d59a8c9..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/chameneosredux.txt +++ /dev/null @@ -1,29 +0,0 @@ -blue + blue -> blue -blue + red -> yellow -blue + yellow -> red -red + blue -> yellow -red + red -> red -red + yellow -> blue -yellow + blue -> red -yellow + red -> blue -yellow + yellow -> yellow - - blue red yellow -400 zero -400 zero -400 zero - one two zero zero - - blue red yellow red yellow blue red yellow red blue -120 zero -120 zero -120 zero -120 zero -120 zero -120 zero -120 zero -120 zero -120 zero -120 zero - one two zero zero - diff --git a/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.go b/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.go deleted file mode 100644 index 7e9b98d5051..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.go +++ /dev/null @@ -1,224 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * Based on fannkuch.scala by Rex Kerr - */ - -package main - -import ( - "flag" - "fmt" - "runtime" -) - -var n = flag.Int("n", 7, "count") -var nCPU = flag.Int("ncpu", 4, "number of cpus") - -type Job struct { - start []int - n int -} - -type Found struct { - who *Kucher - k int -} - -type Kucher struct { - perm []int - temp []int - flip []int - in chan Job -} - -func NewKucher(length int) *Kucher { - return &Kucher{ - perm: make([]int, length), - temp: make([]int, length), - flip: make([]int, length), - in: make(chan Job), - } -} - -func (k *Kucher) permute(n int) bool { - i := 0 - for ; i < n-1 && k.flip[i] == 0; i++ { - t := k.perm[0] - j := 0 - for ; j <= i; j++ { - k.perm[j] = k.perm[j+1] - } - k.perm[j] = t - } - k.flip[i]-- - for i > 0 { - i-- - k.flip[i] = i - } - return k.flip[n-1] >= 0 -} - -func (k *Kucher) count() int { - K := 0 - copy(k.temp, k.perm) - for k.temp[0] != 0 { - m := k.temp[0] - for i := 0; i < m; i++ { - k.temp[i], k.temp[m] = k.temp[m], k.temp[i] - m-- - } - K++ - } - return K -} - -func (k *Kucher) Run(foreman chan<- Found) { - for job := range k.in { - verbose := 30 - copy(k.perm, job.start) - for i, v := range k.perm { - if v != i { - verbose = 0 - } - k.flip[i] = i - } - K := 0 - for { - if verbose > 0 { - for _, p := range k.perm { - fmt.Print(p + 1) - } - fmt.Println() - verbose-- - } - count := k.count() - if count > K { - K = count - } - if !k.permute(job.n) { - break - } - } - foreman <- Found{k, K} - } -} - -type Fanner struct { - jobind int - jobsdone int - k int - jobs []Job - workers []*Kucher - in chan Found - result chan int -} - -func NewFanner(jobs []Job, workers []*Kucher) *Fanner { - return &Fanner{ - jobs: jobs, workers: workers, - in: make(chan Found), - result: make(chan int), - } -} - -func (f *Fanner) Run(N int) { - for msg := range f.in { - if msg.k > f.k { - f.k = msg.k - } - if msg.k >= 0 { - f.jobsdone++ - } - if f.jobind < len(f.jobs) { - msg.who.in <- f.jobs[f.jobind] - f.jobind++ - } else if f.jobsdone == len(f.jobs) { - f.result <- f.k - return - } - } -} - -func swapped(a []int, i, j int) []int { - b := make([]int, len(a)) - copy(b, a) - b[i], b[j] = a[j], a[i] - return b -} - -func main() { - flag.Parse() - runtime.GOMAXPROCS(*nCPU) - N := *n - base := make([]int, N) - for i := range base { - base[i] = i - } - - njobs := 1 - if N > 8 { - njobs += (N*(N-1))/2 - 28 // njobs = 1 + sum(8..N-1) = 1 + sum(1..N-1) - sum(1..7) - } - jobs := make([]Job, njobs) - jobsind := 0 - - firstN := N - if firstN > 8 { - firstN = 8 - } - jobs[jobsind] = Job{base, firstN} - jobsind++ - for i := N - 1; i >= 8; i-- { - for j := 0; j < i; j++ { - jobs[jobsind] = Job{swapped(base, i, j), i} - jobsind++ - } - } - - nworkers := *nCPU - if njobs < nworkers { - nworkers = njobs - } - workers := make([]*Kucher, nworkers) - foreman := NewFanner(jobs, workers) - go foreman.Run(N) - for i := range workers { - k := NewKucher(N) - workers[i] = k - go k.Run(foreman.in) - foreman.in <- Found{k, -1} - } - fmt.Printf("Pfannkuchen(%d) = %d\n", N, <-foreman.result) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.txt b/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.txt deleted file mode 100644 index e66f779ea1d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fannkuch-parallel.txt +++ /dev/null @@ -1,31 +0,0 @@ -1234567 -2134567 -2314567 -3214567 -3124567 -1324567 -2341567 -3241567 -3421567 -4321567 -4231567 -2431567 -3412567 -4312567 -4132567 -1432567 -1342567 -3142567 -4123567 -1423567 -1243567 -2143567 -2413567 -4213567 -2345167 -3245167 -3425167 -4325167 -4235167 -2435167 -Pfannkuchen(7) = 16 diff --git a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.c b/gcc/testsuite/go.test/test/bench/shootout/fannkuch.c deleted file mode 100644 index e576b5441f9..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * The Computer Language Shootout - * http://shootout.alioth.debian.org/ - * Contributed by Heiner Marxen - * - * "fannkuch" for C gcc - * - * $Id: fannkuch.1.gcc.code,v 1.15 2009-04-28 15:39:31 igouy-guest Exp $ - */ - -#include -#include - -#define Int int -#define Aint int - - static long -fannkuch( int n ) -{ - Aint* perm; - Aint* perm1; - Aint* count; - long flips; - long flipsMax; - Int r; - Int i; - Int k; - Int didpr; - const Int n1 = n - 1; - - if( n < 1 ) return 0; - - perm = calloc(n, sizeof(*perm )); - perm1 = calloc(n, sizeof(*perm1)); - count = calloc(n, sizeof(*count)); - - for( i=0 ; i k>0 */ - Int j; - for( i=1, j=k-1 ; i 0 ) { - break; - } - ++r; - } - } -} - - int -main( int argc, char* argv[] ) -{ - int n = (argc>1) ? atoi(argv[1]) : 0; - - printf("Pfannkuchen(%d) = %ld\n", n, fannkuch(n)); - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.go b/gcc/testsuite/go.test/test/bench/shootout/fannkuch.go deleted file mode 100644 index b554c77b104..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * Based on fannkuch.c by Heiner Marxen - */ - -package main - -import ( - "flag" - "fmt" -) - -var n = flag.Int("n", 7, "count") - -func fannkuch(n int) int { - if n < 1 { - return 0 - } - - n1 := n - 1 - perm := make([]int, n) - perm1 := make([]int, n) - count := make([]int, n) - - for i := 0; i < n; i++ { - perm1[i] = i // initial (trivial) permutation - } - - r := n - didpr := 0 - flipsMax := 0 - for { - if didpr < 30 { - for i := 0; i < n; i++ { - fmt.Printf("%d", 1+perm1[i]) - } - fmt.Printf("\n") - didpr++ - } - for ; r != 1; r-- { - count[r-1] = r - } - - if perm1[0] != 0 && perm1[n1] != n1 { - flips := 0 - for i := 1; i < n; i++ { // perm = perm1 - perm[i] = perm1[i] - } - k := perm1[0] // cache perm[0] in k - for { // k!=0 ==> k>0 - for i, j := 1, k-1; i < j; i, j = i+1, j-1 { - perm[i], perm[j] = perm[j], perm[i] - } - flips++ - // Now exchange k (caching perm[0]) and perm[k]... with care! - j := perm[k] - perm[k] = k - k = j - if k == 0 { - break - } - } - if flipsMax < flips { - flipsMax = flips - } - } - - for ; r < n; r++ { - // rotate down perm[0..r] by one - perm0 := perm1[0] - for i := 0; i < r; i++ { - perm1[i] = perm1[i+1] - } - perm1[r] = perm0 - count[r]-- - if count[r] > 0 { - break - } - } - if r == n { - return flipsMax - } - } - return 0 -} - -func main() { - flag.Parse() - fmt.Printf("Pfannkuchen(%d) = %d\n", *n, fannkuch(*n)) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.txt b/gcc/testsuite/go.test/test/bench/shootout/fannkuch.txt deleted file mode 100644 index e66f779ea1d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fannkuch.txt +++ /dev/null @@ -1,31 +0,0 @@ -1234567 -2134567 -2314567 -3214567 -3124567 -1324567 -2341567 -3241567 -3421567 -4321567 -4231567 -2431567 -3412567 -4312567 -4132567 -1432567 -1342567 -3142567 -4123567 -1423567 -1243567 -2143567 -2413567 -4213567 -2345167 -3245167 -3425167 -4325167 -4235167 -2435167 -Pfannkuchen(7) = 16 diff --git a/gcc/testsuite/go.test/test/bench/shootout/fasta-1000.out b/gcc/testsuite/go.test/test/bench/shootout/fasta-1000.out deleted file mode 100644 index f1caba0d628..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fasta-1000.out +++ /dev/null @@ -1,171 +0,0 @@ ->ONE Homo sapiens alu -GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA -TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT -AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG -GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG -CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT -GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA -GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA -TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG -AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA -GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT -AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC -AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG -GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC -CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG -AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT -TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA -TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT -GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG -TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT -CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG -CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG -TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA -CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG -AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG -GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC -TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA -TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA -GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT -GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC -ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT -TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC -CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG -CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG -GGCGACAGAGCGAGACTCCG ->TWO IUB ambiguity codes -cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg -tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa -NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt -cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga -gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa -HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca -tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt -tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt -acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct -tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt -gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa -accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt -RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt -tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag -cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg -ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat -actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg -YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa -KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata -aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa -aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg -gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc -tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK -tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt -ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg -ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa -BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt -aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc -tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc -cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac -aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga -tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga -aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD -gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg -ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV -taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa -ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat -gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg -gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa -tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt -tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt -taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca -cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag -aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt -cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt -ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW -attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag -ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa -attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc -tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta ->THREE Homo sapiens frequency -aacacttcaccaggtatcgtgaaggctcaagattacccagagaacctttgcaatataaga -atatgtatgcagcattaccctaagtaattatattctttttctgactcaaagtgacaagcc -ctagtgtatattaaatcggtatatttgggaaattcctcaaactatcctaatcaggtagcc -atgaaagtgatcaaaaaagttcgtacttataccatacatgaattctggccaagtaaaaaa -tagattgcgcaaaattcgtaccttaagtctctcgccaagatattaggatcctattactca -tatcgtgtttttctttattgccgccatccccggagtatctcacccatccttctcttaaag -gcctaatattacctatgcaaataaacatatattgttgaaaattgagaacctgatcgtgat -tcttatgtgtaccatatgtatagtaatcacgcgactatatagtgctttagtatcgcccgt -gggtgagtgaatattctgggctagcgtgagatagtttcttgtcctaatatttttcagatc -gaatagcttctatttttgtgtttattgacatatgtcgaaactccttactcagtgaaagtc -atgaccagatccacgaacaatcttcggaatcagtctcgttttacggcggaatcttgagtc -taacttatatcccgtcgcttactttctaacaccccttatgtatttttaaaattacgttta -ttcgaacgtacttggcggaagcgttattttttgaagtaagttacattgggcagactcttg -acattttcgatacgactttctttcatccatcacaggactcgttcgtattgatatcagaag -ctcgtgatgattagttgtcttctttaccaatactttgaggcctattctgcgaaatttttg -ttgccctgcgaacttcacataccaaggaacacctcgcaacatgccttcatatccatcgtt -cattgtaattcttacacaatgaatcctaagtaattacatccctgcgtaaaagatggtagg -ggcactgaggatatattaccaagcatttagttatgagtaatcagcaatgtttcttgtatt -aagttctctaaaatagttacatcgtaatgttatctcgggttccgcgaataaacgagatag -attcattatatatggccctaagcaaaaacctcctcgtattctgttggtaattagaatcac -acaatacgggttgagatattaattatttgtagtacgaagagatataaaaagatgaacaat -tactcaagtcaagatgtatacgggatttataataaaaatcgggtagagatctgctttgca -attcagacgtgccactaaatcgtaatatgtcgcgttacatcagaaagggtaactattatt -aattaataaagggcttaatcactacatattagatcttatccgatagtcttatctattcgt -tgtatttttaagcggttctaattcagtcattatatcagtgctccgagttctttattattg -ttttaaggatgacaaaatgcctcttgttataacgctgggagaagcagactaagagtcgga -gcagttggtagaatgaggctgcaaaagacggtctcgacgaatggacagactttactaaac -caatgaaagacagaagtagagcaaagtctgaagtggtatcagcttaattatgacaaccct -taatacttccctttcgccgaatactggcgtggaaaggttttaaaagtcgaagtagttaga -ggcatctctcgctcataaataggtagactactcgcaatccaatgtgactatgtaatactg -ggaacatcagtccgcgatgcagcgtgtttatcaaccgtccccactcgcctggggagacat -gagaccacccccgtggggattattagtccgcagtaatcgactcttgacaatccttttcga -ttatgtcatagcaatttacgacagttcagcgaagtgactactcggcgaaatggtattact -aaagcattcgaacccacatgaatgtgattcttggcaatttctaatccactaaagcttttc -cgttgaatctggttgtagatatttatataagttcactaattaagatcacggtagtatatt -gatagtgatgtctttgcaagaggttggccgaggaatttacggattctctattgatacaat -ttgtctggcttataactcttaaggctgaaccaggcgtttttagacgacttgatcagctgt -tagaatggtttggactccctctttcatgtcagtaacatttcagccgttattgttacgata -tgcttgaacaatattgatctaccacacacccatagtatattttataggtcatgctgttac -ctacgagcatggtattccacttcccattcaatgagtattcaacatcactagcctcagaga -tgatgacccacctctaataacgtcacgttgcggccatgtgaaacctgaacttgagtagac -gatatcaagcgctttaaattgcatataacatttgagggtaaagctaagcggatgctttat -ataatcaatactcaataataagatttgattgcattttagagttatgacacgacatagttc -actaacgagttactattcccagatctagactgaagtactgatcgagacgatccttacgtc -gatgatcgttagttatcgacttaggtcgggtctctagcggtattggtacttaaccggaca -ctatactaataacccatgatcaaagcataacagaatacagacgataatttcgccaacata -tatgtacagaccccaagcatgagaagctcattgaaagctatcattgaagtcccgctcaca -atgtgtcttttccagacggtttaactggttcccgggagtcctggagtttcgacttacata -aatggaaacaatgtattttgctaatttatctatagcgtcatttggaccaatacagaatat -tatgttgcctagtaatccactataacccgcaagtgctgatagaaaatttttagacgattt -ataaatgccccaagtatccctcccgtgaatcctccgttatactaattagtattcgttcat -acgtataccgcgcatatatgaacatttggcgataaggcgcgtgaattgttacgtgacaga -gatagcagtttcttgtgatatggttaacagacgtacatgaagggaaactttatatctata -gtgatgcttccgtagaaataccgccactggtctgccaatgatgaagtatgtagctttagg -tttgtactatgaggctttcgtttgtttgcagagtataacagttgcgagtgaaaaaccgac -gaatttatactaatacgctttcactattggctacaaaatagggaagagtttcaatcatga -gagggagtatatggatgctttgtagctaaaggtagaacgtatgtatatgctgccgttcat -tcttgaaagatacataagcgataagttacgacaattataagcaacatccctaccttcgta -acgatttcactgttactgcgcttgaaatacactatggggctattggcggagagaagcaga -tcgcgccgagcatatacgagacctataatgttgatgatagagaaggcgtctgaattgata -catcgaagtacactttctttcgtagtatctctcgtcctctttctatctccggacacaaga -attaagttatatatatagagtcttaccaatcatgttgaatcctgattctcagagttcttt -ggcgggccttgtgatgactgagaaacaatgcaatattgctccaaatttcctaagcaaatt -ctcggttatgttatgttatcagcaaagcgttacgttatgttatttaaatctggaatgacg -gagcgaagttcttatgtcggtgtgggaataattcttttgaagacagcactccttaaataa -tatcgctccgtgtttgtatttatcgaatgggtctgtaaccttgcacaagcaaatcggtgg -tgtatatatcggataacaattaatacgatgttcatagtgacagtatactgatcgagtcct -ctaaagtcaattacctcacttaacaatctcattgatgttgtgtcattcccggtatcgccc -gtagtatgtgctctgattgaccgagtgtgaaccaaggaacatctactaatgcctttgtta -ggtaagatctctctgaattccttcgtgccaacttaaaacattatcaaaatttcttctact -tggattaactacttttacgagcatggcaaattcccctgtggaagacggttcattattatc -ggaaaccttatagaaattgcgtgttgactgaaattagatttttattgtaagagttgcatc -tttgcgattcctctggtctagcttccaatgaacagtcctcccttctattcgacatcgggt -ccttcgtacatgtctttgcgatgtaataattaggttcggagtgtggccttaatgggtgca -actaggaatacaacgcaaatttgctgacatgatagcaaatcggtatgccggcaccaaaac -gtgctccttgcttagcttgtgaatgagactcagtagttaaataaatccatatctgcaatc -gattccacaggtattgtccactatctttgaactactctaagagatacaagcttagctgag -accgaggtgtatatgactacgctgatatctgtaaggtaccaatgcaggcaaagtatgcga -gaagctaataccggctgtttccagctttataagattaaaatttggctgtcctggcggcct -cagaattgttctatcgtaatcagttggttcattaattagctaagtacgaggtacaactta -tctgtcccagaacagctccacaagtttttttacagccgaaacccctgtgtgaatcttaat -atccaagcgcgttatctgattagagtttacaactcagtattttatcagtacgttttgttt -ccaacattacccggtatgacaaaatgacgccacgtgtcgaataatggtctgaccaatgta -ggaagtgaaaagataaatat diff --git a/gcc/testsuite/go.test/test/bench/shootout/fasta.c b/gcc/testsuite/go.test/test/bench/shootout/fasta.c deleted file mode 100644 index 64c1c520581..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fasta.c +++ /dev/null @@ -1,219 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * http://shootout.alioth.debian.org/u32/program.php?test=fasta&lang=gcc&id=3 - */ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by Petr Prokhorenkov - */ - -#include -#include -#include - -#ifndef fwrite_unlocked -// not available on OS X -#define fwrite_unlocked fwrite -#define fputc_unlocked fputc -#define fputs_unlocked fputs -#endif - -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) -#define unlikely(x) __builtin_expect((x), 0) - -#define IM 139968 -#define IA 3877 -#define IC 29573 - -#define LINE_LEN 60 -#define LOOKUP_SIZE 4096 -#define LOOKUP_SCALE ((float)(LOOKUP_SIZE - 1)) - -typedef unsigned random_t; - -void -random_init(random_t *random) { - *random = 42; -} - -// Special version with result rescaled to LOOKUP_SCALE. -static inline -float -random_next_lookup(random_t *random) { - *random = (*random*IA + IC)%IM; - - return (*random)*(LOOKUP_SCALE/IM); -} - -struct amino_acid { - char sym; - float prob; - float cprob_lookup; -}; - -void -repeat(const char *alu, const char *title, int n) { - int len = strlen(alu); - char buffer[len + LINE_LEN]; - int pos = 0; - - memcpy(buffer, alu, len); - memcpy(buffer + len, alu, LINE_LEN); - - fputs_unlocked(title, stdout); - while (n > 0) { - int bytes = n > LINE_LEN ? LINE_LEN : n; - - fwrite_unlocked(buffer + pos, bytes, 1, stdout); - pos += bytes; - if (pos > len) { - pos -= len; - } - fputc_unlocked('\n', stdout); - n -= bytes; - } -} - -/* - * Lookup table contains mapping from real values to cumulative - * probabilities. Careful selection of table size allows lookup - * virtually in constant time. - * - * All cumulative probabilities are rescaled to LOOKUP_SCALE, - * this allows to save one multiplication operation on each iteration - * in randomize(). - */ - -void * -fill_lookup(struct amino_acid **lookup, struct amino_acid *amino_acid, int amino_acid_size) { - float p = 0; - int i, j; - - for (i = 0; i < amino_acid_size; i++) { - p += amino_acid[i].prob; - amino_acid[i].cprob_lookup = p*LOOKUP_SCALE; - } - - // Prevent rounding error. - amino_acid[amino_acid_size - 1].cprob_lookup = LOOKUP_SIZE - 1; - - for (i = 0, j = 0; i < LOOKUP_SIZE; i++) { - while (amino_acid[j].cprob_lookup < i) { - j++; - } - lookup[i] = &amino_acid[j]; - } - - return 0; -} - -void -randomize(struct amino_acid *amino_acid, int amino_acid_size, - const char *title, int n, random_t *rand) { - struct amino_acid *lookup[LOOKUP_SIZE]; - char line_buffer[LINE_LEN + 1]; - int i, j; - - line_buffer[LINE_LEN] = '\n'; - - fill_lookup(lookup, amino_acid, amino_acid_size); - - fputs_unlocked(title, stdout); - - for (i = 0, j = 0; i < n; i++, j++) { - if (j == LINE_LEN) { - fwrite_unlocked(line_buffer, LINE_LEN + 1, 1, stdout); - j = 0; - } - - float r = random_next_lookup(rand); - struct amino_acid *u = lookup[(short)r]; - while (unlikely(u->cprob_lookup < r)) { - ++u; - } - line_buffer[j] = u->sym; - } - line_buffer[j] = '\n'; - fwrite_unlocked(line_buffer, j + 1, 1, stdout); -} - -struct amino_acid amino_acid[] = { - { 'a', 0.27 }, - { 'c', 0.12 }, - { 'g', 0.12 }, - { 't', 0.27 }, - - { 'B', 0.02 }, - { 'D', 0.02 }, - { 'H', 0.02 }, - { 'K', 0.02 }, - { 'M', 0.02 }, - { 'N', 0.02 }, - { 'R', 0.02 }, - { 'S', 0.02 }, - { 'V', 0.02 }, - { 'W', 0.02 }, - { 'Y', 0.02 }, -}; - -struct amino_acid homo_sapiens[] = { - { 'a', 0.3029549426680 }, - { 'c', 0.1979883004921 }, - { 'g', 0.1975473066391 }, - { 't', 0.3015094502008 }, -}; - -static const char alu[] = - "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG" - "GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA" - "GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA" - "AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT" - "CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC" - "CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG" - "CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; - -int -main(int argc, const char **argv) { - int n = argc > 1 ? atoi( argv[1] ) : 512; - random_t rand; - - random_init(&rand); - - repeat(alu, ">ONE Homo sapiens alu\n", n*2); - randomize(amino_acid, ARRAY_SIZE(amino_acid), - ">TWO IUB ambiguity codes\n", n*3, &rand); - randomize(homo_sapiens, ARRAY_SIZE(homo_sapiens), - ">THREE Homo sapiens frequency\n", n*5, &rand); - - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/fasta.go b/gcc/testsuite/go.test/test/bench/shootout/fasta.go deleted file mode 100644 index 17ff5dae55d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fasta.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * Based on C program by by Petr Prokhorenkov. - */ - -package main - -import ( - "flag" - "os" -) - -var out = make(buffer, 0, 32768) - -var n = flag.Int("n", 1000, "length of result") - -const Line = 60 - -func Repeat(alu []byte, n int) { - buf := append(alu, alu...) - off := 0 - for n > 0 { - m := n - if m > Line { - m = Line - } - buf1 := out.NextWrite(m + 1) - copy(buf1, buf[off:]) - buf1[m] = '\n' - if off += m; off >= len(alu) { - off -= len(alu) - } - n -= m - } -} - -const ( - IM = 139968 - IA = 3877 - IC = 29573 - - LookupSize = 4096 - LookupScale float64 = LookupSize - 1 -) - -var rand uint32 = 42 - -type Acid struct { - sym byte - prob float64 - cprob float64 - next *Acid -} - -func computeLookup(acid []Acid) *[LookupSize]*Acid { - var lookup [LookupSize]*Acid - var p float64 - for i := range acid { - p += acid[i].prob - acid[i].cprob = p * LookupScale - if i > 0 { - acid[i-1].next = &acid[i] - } - } - acid[len(acid)-1].cprob = 1.0 * LookupScale - - j := 0 - for i := range lookup { - for acid[j].cprob < float64(i) { - j++ - } - lookup[i] = &acid[j] - } - - return &lookup -} - -func Random(acid []Acid, n int) { - lookup := computeLookup(acid) - for n > 0 { - m := n - if m > Line { - m = Line - } - buf := out.NextWrite(m + 1) - f := LookupScale / IM - myrand := rand - for i := 0; i < m; i++ { - myrand = (myrand*IA + IC) % IM - r := float64(int(myrand)) * f - a := lookup[int(r)] - for a.cprob < r { - a = a.next - } - buf[i] = a.sym - } - rand = myrand - buf[m] = '\n' - n -= m - } -} - -func main() { - defer out.Flush() - - flag.Parse() - - iub := []Acid{ - {prob: 0.27, sym: 'a'}, - {prob: 0.12, sym: 'c'}, - {prob: 0.12, sym: 'g'}, - {prob: 0.27, sym: 't'}, - {prob: 0.02, sym: 'B'}, - {prob: 0.02, sym: 'D'}, - {prob: 0.02, sym: 'H'}, - {prob: 0.02, sym: 'K'}, - {prob: 0.02, sym: 'M'}, - {prob: 0.02, sym: 'N'}, - {prob: 0.02, sym: 'R'}, - {prob: 0.02, sym: 'S'}, - {prob: 0.02, sym: 'V'}, - {prob: 0.02, sym: 'W'}, - {prob: 0.02, sym: 'Y'}, - } - - homosapiens := []Acid{ - {prob: 0.3029549426680, sym: 'a'}, - {prob: 0.1979883004921, sym: 'c'}, - {prob: 0.1975473066391, sym: 'g'}, - {prob: 0.3015094502008, sym: 't'}, - } - - alu := []byte( - "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + - "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + - "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + - "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + - "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + - "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + - "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA") - - out.WriteString(">ONE Homo sapiens alu\n") - Repeat(alu, 2**n) - out.WriteString(">TWO IUB ambiguity codes\n") - Random(iub, 3**n) - out.WriteString(">THREE Homo sapiens frequency\n") - Random(homosapiens, 5**n) -} - -type buffer []byte - -func (b *buffer) Flush() { - p := *b - if len(p) > 0 { - os.Stdout.Write(p) - } - *b = p[0:0] -} - -func (b *buffer) WriteString(s string) { - p := b.NextWrite(len(s)) - copy(p, s) -} - -func (b *buffer) NextWrite(n int) []byte { - p := *b - if len(p)+n > cap(p) { - b.Flush() - p = *b - } - out := p[len(p) : len(p)+n] - *b = p[:len(p)+n] - return out -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/fasta.txt b/gcc/testsuite/go.test/test/bench/shootout/fasta.txt deleted file mode 100644 index f1caba0d628..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/fasta.txt +++ /dev/null @@ -1,171 +0,0 @@ ->ONE Homo sapiens alu -GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA -TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT -AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG -GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG -CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT -GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA -GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA -TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG -AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA -GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT -AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC -AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG -GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC -CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG -AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT -TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA -TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT -GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG -TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT -CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG -CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG -TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA -CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG -AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG -GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC -TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA -TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA -GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT -GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC -ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT -TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC -CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG -CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG -GGCGACAGAGCGAGACTCCG ->TWO IUB ambiguity codes -cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg -tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa -NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt -cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga -gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa -HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca -tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt -tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt -acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct -tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt -gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa -accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt -RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt -tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag -cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg -ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat -actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg -YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa -KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata -aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa -aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg -gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc -tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK -tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt -ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg -ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa -BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt -aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc -tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc -cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac -aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga -tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga -aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD -gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg -ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV -taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa -ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat -gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg -gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa -tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt -tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt -taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca -cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag -aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt -cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt -ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW -attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag -ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa -attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc -tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta ->THREE Homo sapiens frequency -aacacttcaccaggtatcgtgaaggctcaagattacccagagaacctttgcaatataaga -atatgtatgcagcattaccctaagtaattatattctttttctgactcaaagtgacaagcc -ctagtgtatattaaatcggtatatttgggaaattcctcaaactatcctaatcaggtagcc -atgaaagtgatcaaaaaagttcgtacttataccatacatgaattctggccaagtaaaaaa -tagattgcgcaaaattcgtaccttaagtctctcgccaagatattaggatcctattactca -tatcgtgtttttctttattgccgccatccccggagtatctcacccatccttctcttaaag -gcctaatattacctatgcaaataaacatatattgttgaaaattgagaacctgatcgtgat -tcttatgtgtaccatatgtatagtaatcacgcgactatatagtgctttagtatcgcccgt -gggtgagtgaatattctgggctagcgtgagatagtttcttgtcctaatatttttcagatc -gaatagcttctatttttgtgtttattgacatatgtcgaaactccttactcagtgaaagtc -atgaccagatccacgaacaatcttcggaatcagtctcgttttacggcggaatcttgagtc -taacttatatcccgtcgcttactttctaacaccccttatgtatttttaaaattacgttta -ttcgaacgtacttggcggaagcgttattttttgaagtaagttacattgggcagactcttg -acattttcgatacgactttctttcatccatcacaggactcgttcgtattgatatcagaag -ctcgtgatgattagttgtcttctttaccaatactttgaggcctattctgcgaaatttttg -ttgccctgcgaacttcacataccaaggaacacctcgcaacatgccttcatatccatcgtt -cattgtaattcttacacaatgaatcctaagtaattacatccctgcgtaaaagatggtagg -ggcactgaggatatattaccaagcatttagttatgagtaatcagcaatgtttcttgtatt -aagttctctaaaatagttacatcgtaatgttatctcgggttccgcgaataaacgagatag -attcattatatatggccctaagcaaaaacctcctcgtattctgttggtaattagaatcac -acaatacgggttgagatattaattatttgtagtacgaagagatataaaaagatgaacaat -tactcaagtcaagatgtatacgggatttataataaaaatcgggtagagatctgctttgca -attcagacgtgccactaaatcgtaatatgtcgcgttacatcagaaagggtaactattatt -aattaataaagggcttaatcactacatattagatcttatccgatagtcttatctattcgt -tgtatttttaagcggttctaattcagtcattatatcagtgctccgagttctttattattg -ttttaaggatgacaaaatgcctcttgttataacgctgggagaagcagactaagagtcgga -gcagttggtagaatgaggctgcaaaagacggtctcgacgaatggacagactttactaaac -caatgaaagacagaagtagagcaaagtctgaagtggtatcagcttaattatgacaaccct -taatacttccctttcgccgaatactggcgtggaaaggttttaaaagtcgaagtagttaga -ggcatctctcgctcataaataggtagactactcgcaatccaatgtgactatgtaatactg -ggaacatcagtccgcgatgcagcgtgtttatcaaccgtccccactcgcctggggagacat -gagaccacccccgtggggattattagtccgcagtaatcgactcttgacaatccttttcga -ttatgtcatagcaatttacgacagttcagcgaagtgactactcggcgaaatggtattact -aaagcattcgaacccacatgaatgtgattcttggcaatttctaatccactaaagcttttc -cgttgaatctggttgtagatatttatataagttcactaattaagatcacggtagtatatt -gatagtgatgtctttgcaagaggttggccgaggaatttacggattctctattgatacaat -ttgtctggcttataactcttaaggctgaaccaggcgtttttagacgacttgatcagctgt -tagaatggtttggactccctctttcatgtcagtaacatttcagccgttattgttacgata -tgcttgaacaatattgatctaccacacacccatagtatattttataggtcatgctgttac -ctacgagcatggtattccacttcccattcaatgagtattcaacatcactagcctcagaga -tgatgacccacctctaataacgtcacgttgcggccatgtgaaacctgaacttgagtagac -gatatcaagcgctttaaattgcatataacatttgagggtaaagctaagcggatgctttat -ataatcaatactcaataataagatttgattgcattttagagttatgacacgacatagttc -actaacgagttactattcccagatctagactgaagtactgatcgagacgatccttacgtc -gatgatcgttagttatcgacttaggtcgggtctctagcggtattggtacttaaccggaca -ctatactaataacccatgatcaaagcataacagaatacagacgataatttcgccaacata -tatgtacagaccccaagcatgagaagctcattgaaagctatcattgaagtcccgctcaca -atgtgtcttttccagacggtttaactggttcccgggagtcctggagtttcgacttacata -aatggaaacaatgtattttgctaatttatctatagcgtcatttggaccaatacagaatat -tatgttgcctagtaatccactataacccgcaagtgctgatagaaaatttttagacgattt -ataaatgccccaagtatccctcccgtgaatcctccgttatactaattagtattcgttcat -acgtataccgcgcatatatgaacatttggcgataaggcgcgtgaattgttacgtgacaga -gatagcagtttcttgtgatatggttaacagacgtacatgaagggaaactttatatctata -gtgatgcttccgtagaaataccgccactggtctgccaatgatgaagtatgtagctttagg -tttgtactatgaggctttcgtttgtttgcagagtataacagttgcgagtgaaaaaccgac -gaatttatactaatacgctttcactattggctacaaaatagggaagagtttcaatcatga -gagggagtatatggatgctttgtagctaaaggtagaacgtatgtatatgctgccgttcat -tcttgaaagatacataagcgataagttacgacaattataagcaacatccctaccttcgta -acgatttcactgttactgcgcttgaaatacactatggggctattggcggagagaagcaga -tcgcgccgagcatatacgagacctataatgttgatgatagagaaggcgtctgaattgata -catcgaagtacactttctttcgtagtatctctcgtcctctttctatctccggacacaaga -attaagttatatatatagagtcttaccaatcatgttgaatcctgattctcagagttcttt -ggcgggccttgtgatgactgagaaacaatgcaatattgctccaaatttcctaagcaaatt -ctcggttatgttatgttatcagcaaagcgttacgttatgttatttaaatctggaatgacg -gagcgaagttcttatgtcggtgtgggaataattcttttgaagacagcactccttaaataa -tatcgctccgtgtttgtatttatcgaatgggtctgtaaccttgcacaagcaaatcggtgg -tgtatatatcggataacaattaatacgatgttcatagtgacagtatactgatcgagtcct -ctaaagtcaattacctcacttaacaatctcattgatgttgtgtcattcccggtatcgccc -gtagtatgtgctctgattgaccgagtgtgaaccaaggaacatctactaatgcctttgtta -ggtaagatctctctgaattccttcgtgccaacttaaaacattatcaaaatttcttctact -tggattaactacttttacgagcatggcaaattcccctgtggaagacggttcattattatc -ggaaaccttatagaaattgcgtgttgactgaaattagatttttattgtaagagttgcatc -tttgcgattcctctggtctagcttccaatgaacagtcctcccttctattcgacatcgggt -ccttcgtacatgtctttgcgatgtaataattaggttcggagtgtggccttaatgggtgca -actaggaatacaacgcaaatttgctgacatgatagcaaatcggtatgccggcaccaaaac -gtgctccttgcttagcttgtgaatgagactcagtagttaaataaatccatatctgcaatc -gattccacaggtattgtccactatctttgaactactctaagagatacaagcttagctgag -accgaggtgtatatgactacgctgatatctgtaaggtaccaatgcaggcaaagtatgcga -gaagctaataccggctgtttccagctttataagattaaaatttggctgtcctggcggcct -cagaattgttctatcgtaatcagttggttcattaattagctaagtacgaggtacaactta -tctgtcccagaacagctccacaagtttttttacagccgaaacccctgtgtgaatcttaat -atccaagcgcgttatctgattagagtttacaactcagtattttatcagtacgttttgttt -ccaacattacccggtatgacaaaatgacgccacgtgtcgaataatggtctgaccaatgta -ggaagtgaaaagataaatat diff --git a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.go b/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.go deleted file mode 100644 index 96c80d8f0c8..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "bufio" - "bytes" - "fmt" - "io/ioutil" - "os" - "runtime" - "sort" -) - -func count(data string, n int) map[string]int { - counts := make(map[string]int) - top := len(data) - n - for i := 0; i <= top; i++ { - s := data[i : i+n] - counts[s]++ - } - return counts -} - -func countOne(data string, s string) int { - return count(data, len(s))[s] -} - -type kNuc struct { - name string - count int -} - -type kNucArray []kNuc - -func (kn kNucArray) Len() int { return len(kn) } -func (kn kNucArray) Swap(i, j int) { kn[i], kn[j] = kn[j], kn[i] } -func (kn kNucArray) Less(i, j int) bool { - if kn[i].count == kn[j].count { - return kn[i].name > kn[j].name // sort down - } - return kn[i].count > kn[j].count -} - -func sortedArray(m map[string]int) kNucArray { - kn := make(kNucArray, len(m)) - i := 0 - for k, v := range m { - kn[i] = kNuc{k, v} - i++ - } - sort.Sort(kn) - return kn -} - -func printKnucs(a kNucArray) { - sum := 0 - for _, kn := range a { - sum += kn.count - } - for _, kn := range a { - fmt.Printf("%s %.3f\n", kn.name, 100*float64(kn.count)/float64(sum)) - } - fmt.Print("\n") -} - -func main() { - runtime.GOMAXPROCS(4) - in := bufio.NewReader(os.Stdin) - three := []byte(">THREE ") - for { - line, err := in.ReadSlice('\n') - if err != nil { - fmt.Fprintln(os.Stderr, "ReadLine err:", err) - os.Exit(2) - } - if line[0] == '>' && bytes.Equal(line[0:len(three)], three) { - break - } - } - data, err := ioutil.ReadAll(in) - if err != nil { - fmt.Fprintln(os.Stderr, "ReadAll err:", err) - os.Exit(2) - } - // delete the newlines and convert to upper case - j := 0 - for i := 0; i < len(data); i++ { - if data[i] != '\n' { - data[j] = data[i] &^ ' ' // upper case - j++ - } - } - str := string(data[0:j]) - - var arr1, arr2 kNucArray - countsdone := make(chan bool) - go func() { - arr1 = sortedArray(count(str, 1)) - countsdone <- true - }() - go func() { - arr2 = sortedArray(count(str, 2)) - countsdone <- true - }() - - interests := []string{"GGT", "GGTA", "GGTATT", "GGTATTTTAATT", "GGTATTTTAATTTATAGT"} - results := make([]chan string, len(interests)) - for i, s := range interests { - ch := make(chan string) - results[i] = ch - go func(result chan string, ss string) { - result <- fmt.Sprintf("%d %s\n", countOne(str, ss), ss) - }(ch, s) - } - <-countsdone - <-countsdone - printKnucs(arr1) - printKnucs(arr2) - for _, rc := range results { - fmt.Print(<-rc) - } - -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.txt b/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.txt deleted file mode 100644 index 84169b8ec36..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide-parallel.txt +++ /dev/null @@ -1,27 +0,0 @@ -T 31.520 -A 29.600 -C 19.480 -G 19.400 - -AT 9.922 -TT 9.602 -TA 9.402 -AA 8.402 -GA 6.321 -TC 6.301 -TG 6.201 -GT 6.041 -CT 5.961 -AG 5.841 -CA 5.461 -AC 5.441 -CC 4.041 -CG 4.021 -GC 3.701 -GG 3.341 - -54 GGT -24 GGTA -4 GGTATT -0 GGTATTTTAATT -0 GGTATTTTAATTTATAGT diff --git a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.c b/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.c deleted file mode 100644 index 9c30620209e..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.c +++ /dev/null @@ -1,228 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include - -typedef struct stat_s stat_t; -struct stat_s -{ - const gchar *key; - long stat; -}; - -#define MAX_ELM (8192 / sizeof (stat_t)) - -static int -generate_frequencies (int fl, char *buffer, long buflen, - GHashTable *ht, GTrashStack **ts, GPtrArray *roots, GStringChunk *sc) -{ - gchar *key; - long i; - - if (fl > buflen) return 0; - if (fl == 0) return 0; - - for (i = 0; i < buflen - fl + 1; ++i) - { - char nulled; - stat_t *stat; - - nulled = buffer[i + fl]; - buffer[i + fl] = '\0'; - - key = g_string_chunk_insert_const(sc, buffer + i); - - stat = g_hash_table_lookup(ht, key); - if (!stat) - { - stat = g_trash_stack_pop(ts); - if (!stat) - { - int j; - - stat = malloc(sizeof (stat_t) * MAX_ELM); - g_ptr_array_add(roots, stat); - - for (j = 1; j < MAX_ELM; ++j) - g_trash_stack_push(ts, stat + j); - } - stat->stat = 1; - stat->key = key; - - g_hash_table_insert(ht, key, stat); - } - else - stat->stat++; - - buffer[i + fl] = nulled; - } - - return buflen - fl + 1; -} - -static int -cmp_func(gconstpointer a, gconstpointer b) -{ - const stat_t *left = a; - const stat_t *right = b; - - return right->stat - left->stat; -} - -static void -sorted_list(gpointer key, gpointer value, gpointer user_data) -{ - stat_t *data = value; - GList **lst = user_data; - - *lst = g_list_insert_sorted(*lst, data, cmp_func); -} - -static void -display_stat(gpointer data, gpointer user_data) -{ - long *total = user_data; - stat_t *st = data; - - printf("%s %.3f\n", st->key, 100 * (float) st->stat / *total); -} - -void -write_frequencies (int fl, char *buffer, long buflen, GTrashStack **ts, GPtrArray *roots) -{ - GStringChunk *sc; - GHashTable *ht; - GList *lst; - long total; - - ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL /* free key */, NULL /* free value */); - sc = g_string_chunk_new(buflen); - lst = NULL; - - total = generate_frequencies (fl, buffer, buflen, ht, ts, roots, sc); - - if (!total) goto on_error; - - g_hash_table_foreach(ht, sorted_list, &lst); - g_list_foreach(lst, display_stat, &total); - g_list_free(lst); - - on_error: - g_hash_table_destroy(ht); - g_string_chunk_free(sc); -} - -void -write_count (char *searchFor, char *buffer, long buflen, GTrashStack **ts, GPtrArray *roots) -{ - GStringChunk *sc; - GHashTable *ht; - stat_t *result; - GList *lst; - long total; - long fl; - - fl = strlen(searchFor); - - ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL /* free key */, NULL /* free value */); - sc = g_string_chunk_new(buflen); - lst = NULL; - result = NULL; - - total = generate_frequencies (fl, buffer, buflen, ht, ts, roots, sc); - - if (!total) goto on_error; - - result = g_hash_table_lookup(ht, searchFor); - - on_error: - printf("%ld\t%s\n", result ? result->stat : 0, searchFor); - - g_hash_table_destroy(ht); - g_string_chunk_free(sc); -} - -int -main () -{ - char buffer[4096]; - GTrashStack *ts; - GPtrArray *roots; - GString *stuff; - gchar *s; - int len; - - roots = g_ptr_array_new(); - ts = NULL; - - while (fgets(buffer, sizeof (buffer), stdin)) - if (strncmp(buffer, ">THREE", 6) == 0) - break; - - stuff = g_string_new(NULL); - - while (fgets(buffer, sizeof (buffer), stdin)) - { - size_t sz; - - if (buffer[0] == '>') - break; - - sz = strlen(buffer); - if (buffer[sz - 1] == '\n') - --sz; - - stuff = g_string_append_len(stuff, buffer, sz); - } - - stuff = g_string_ascii_up(stuff); - len = stuff->len; - s = g_string_free(stuff, FALSE); - - write_frequencies(1, s, len, &ts, roots); - printf("\n"); - write_frequencies(2, s, len, &ts, roots); - printf("\n"); - write_count("GGT", s, len, &ts, roots); - write_count("GGTA", s, len, &ts, roots); - write_count("GGTATT", s, len, &ts, roots); - write_count("GGTATTTTAATT", s, len, &ts, roots); - write_count("GGTATTTTAATTTATAGT", s, len, &ts, roots); - - free(s); - - g_ptr_array_foreach(roots, (GFunc)free, NULL); - g_ptr_array_free(roots, TRUE); - - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.go b/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.go deleted file mode 100644 index fdc98ed4725..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "bufio" - "bytes" - "fmt" - "io/ioutil" - "os" - "sort" -) - -var in *bufio.Reader - -func count(data string, n int) map[string]int { - counts := make(map[string]int) - top := len(data) - n - for i := 0; i <= top; i++ { - s := data[i : i+n] - counts[s]++ - } - return counts -} - -func countOne(data string, s string) int { - return count(data, len(s))[s] -} - -type kNuc struct { - name string - count int -} - -type kNucArray []kNuc - -func (kn kNucArray) Len() int { return len(kn) } -func (kn kNucArray) Swap(i, j int) { kn[i], kn[j] = kn[j], kn[i] } -func (kn kNucArray) Less(i, j int) bool { - if kn[i].count == kn[j].count { - return kn[i].name > kn[j].name // sort down - } - return kn[i].count > kn[j].count -} - -func sortedArray(m map[string]int) kNucArray { - kn := make(kNucArray, len(m)) - i := 0 - for k, v := range m { - kn[i].name = k - kn[i].count = v - i++ - } - sort.Sort(kn) - return kn -} - -func print(m map[string]int) { - a := sortedArray(m) - sum := 0 - for _, kn := range a { - sum += kn.count - } - for _, kn := range a { - fmt.Printf("%s %.3f\n", kn.name, 100*float64(kn.count)/float64(sum)) - } -} - -func main() { - in = bufio.NewReader(os.Stdin) - three := []byte(">THREE ") - for { - line, err := in.ReadSlice('\n') - if err != nil { - fmt.Fprintln(os.Stderr, "ReadLine err:", err) - os.Exit(2) - } - if line[0] == '>' && bytes.Equal(line[0:len(three)], three) { - break - } - } - data, err := ioutil.ReadAll(in) - if err != nil { - fmt.Fprintln(os.Stderr, "ReadAll err:", err) - os.Exit(2) - } - // delete the newlines and convert to upper case - j := 0 - for i := 0; i < len(data); i++ { - if data[i] != '\n' { - data[j] = data[i] &^ ' ' // upper case - j++ - } - } - str := string(data[0:j]) - - print(count(str, 1)) - fmt.Print("\n") - - print(count(str, 2)) - fmt.Print("\n") - - interests := []string{"GGT", "GGTA", "GGTATT", "GGTATTTTAATT", "GGTATTTTAATTTATAGT"} - for _, s := range interests { - fmt.Printf("%d %s\n", countOne(str, s), s) - } -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.txt b/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.txt deleted file mode 100644 index 84169b8ec36..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/k-nucleotide.txt +++ /dev/null @@ -1,27 +0,0 @@ -T 31.520 -A 29.600 -C 19.480 -G 19.400 - -AT 9.922 -TT 9.602 -TA 9.402 -AA 8.402 -GA 6.321 -TC 6.301 -TG 6.201 -GT 6.041 -CT 5.961 -AG 5.841 -CA 5.461 -AC 5.441 -CC 4.041 -CG 4.021 -GC 3.701 -GG 3.341 - -54 GGT -24 GGTA -4 GGTATT -0 GGTATTTTAATT -0 GGTATTTTAATTTATAGT diff --git a/gcc/testsuite/go.test/test/bench/shootout/mandelbrot.c b/gcc/testsuite/go.test/test/bench/shootout/mandelbrot.c deleted file mode 100644 index c177c088ca6..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/mandelbrot.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Shootout - http://shootout.alioth.debian.org/ - - contributed by Greg Buchholz - - for the debian (AMD) machine... - compile flags: -O3 -ffast-math -march=athlon-xp -funroll-loops - - for the gp4 (Intel) machine... - compile flags: -O3 -ffast-math -march=pentium4 -funroll-loops -*/ - -#include - -int main (int argc, char **argv) -{ - int w, h, bit_num = 0; - char byte_acc = 0; - int i, iter = 50; - double x, y, limit = 2.0; - double Zr, Zi, Cr, Ci, Tr, Ti; - - w = h = atoi(argv[1]); - - printf("P4\n%d %d\n",w,h); - - for(y=0;y -#include -#define TRUE 1 -#define FALSE 0 - -/* The board is a 50 cell hexagonal pattern. For . . . . . - * maximum speed the board will be implemented as . . . . . - * 50 bits, which will fit into a 64 bit long long . . . . . - * int. . . . . . - * . . . . . - * I will represent 0's as empty cells and 1's . . . . . - * as full cells. . . . . . - * . . . . . - * . . . . . - * . . . . . - */ - -unsigned long long board = 0xFFFC000000000000ULL; - -/* The puzzle pieces must be specified by the path followed - * from one end to the other along 12 hexagonal directions. - * - * Piece 0 Piece 1 Piece 2 Piece 3 Piece 4 - * - * O O O O O O O O O O O O O O O - * O O O O O O O - * O O O - * - * Piece 5 Piece 6 Piece 7 Piece 8 Piece 9 - * - * O O O O O O O O O O O O O - * O O O O O O O O O - * O O O - * - * I had to make it 12 directions because I wanted all of the - * piece definitions to fit into the same size arrays. It is - * not possible to define piece 4 in terms of the 6 cardinal - * directions in 4 moves. - */ - -#define E 0 -#define ESE 1 -#define SE 2 -#define S 3 -#define SW 4 -#define WSW 5 -#define W 6 -#define WNW 7 -#define NW 8 -#define N 9 -#define NE 10 -#define ENE 11 -#define PIVOT 12 - -char piece_def[10][4] = { - { E, E, E, SE}, - { SE, E, NE, E}, - { E, E, SE, SW}, - { E, E, SW, SE}, - { SE, E, NE, S}, - { E, E, SW, E}, - { E, SE, SE, NE}, - { E, SE, SE, W}, - { E, SE, E, E}, - { E, E, E, SW} -}; - - -/* To minimize the amount of work done in the recursive solve function below, - * I'm going to allocate enough space for all legal rotations of each piece - * at each position on the board. That's 10 pieces x 50 board positions x - * 12 rotations. However, not all 12 rotations will fit on every cell, so - * I'll have to keep count of the actual number that do. - * The pieces are going to be unsigned long long ints just like the board so - * they can be bitwise-anded with the board to determine if they fit. - * I'm also going to record the next possible open cell for each piece and - * location to reduce the burden on the solve function. - */ -unsigned long long pieces[10][50][12]; -int piece_counts[10][50]; -char next_cell[10][50][12]; - -/* Returns the direction rotated 60 degrees clockwise */ -char rotate(char dir) { - return (dir + 2) % PIVOT; -} - -/* Returns the direction flipped on the horizontal axis */ -char flip(char dir) { - return (PIVOT - dir) % PIVOT; -} - - -/* Returns the new cell index from the specified cell in the - * specified direction. The index is only valid if the - * starting cell and direction have been checked by the - * out_of_bounds function first. - */ -char shift(char cell, char dir) { - switch(dir) { - case E: - return cell + 1; - case ESE: - if((cell / 5) % 2) - return cell + 7; - else - return cell + 6; - case SE: - if((cell / 5) % 2) - return cell + 6; - else - return cell + 5; - case S: - return cell + 10; - case SW: - if((cell / 5) % 2) - return cell + 5; - else - return cell + 4; - case WSW: - if((cell / 5) % 2) - return cell + 4; - else - return cell + 3; - case W: - return cell - 1; - case WNW: - if((cell / 5) % 2) - return cell - 6; - else - return cell - 7; - case NW: - if((cell / 5) % 2) - return cell - 5; - else - return cell - 6; - case N: - return cell - 10; - case NE: - if((cell / 5) % 2) - return cell - 4; - else - return cell - 5; - case ENE: - if((cell / 5) % 2) - return cell - 3; - else - return cell - 4; - default: - return cell; - } -} - -/* Returns wether the specified cell and direction will land outside - * of the board. Used to determine if a piece is at a legal board - * location or not. - */ -char out_of_bounds(char cell, char dir) { - char i; - switch(dir) { - case E: - return cell % 5 == 4; - case ESE: - i = cell % 10; - return i == 4 || i == 8 || i == 9 || cell >= 45; - case SE: - return cell % 10 == 9 || cell >= 45; - case S: - return cell >= 40; - case SW: - return cell % 10 == 0 || cell >= 45; - case WSW: - i = cell % 10; - return i == 0 || i == 1 || i == 5 || cell >= 45; - case W: - return cell % 5 == 0; - case WNW: - i = cell % 10; - return i == 0 || i == 1 || i == 5 || cell < 5; - case NW: - return cell % 10 == 0 || cell < 5; - case N: - return cell < 10; - case NE: - return cell % 10 == 9 || cell < 5; - case ENE: - i = cell % 10; - return i == 4 || i == 8 || i == 9 || cell < 5; - default: - return FALSE; - } -} - -/* Rotate a piece 60 degrees clockwise */ -void rotate_piece(int piece) { - int i; - for(i = 0; i < 4; i++) - piece_def[piece][i] = rotate(piece_def[piece][i]); -} - -/* Flip a piece along the horizontal axis */ -void flip_piece(int piece) { - int i; - for(i = 0; i < 4; i++) - piece_def[piece][i] = flip(piece_def[piece][i]); -} - -/* Convenience function to quickly calculate all of the indices for a piece */ -void calc_cell_indices(char *cell, int piece, char index) { - cell[0] = index; - cell[1] = shift(cell[0], piece_def[piece][0]); - cell[2] = shift(cell[1], piece_def[piece][1]); - cell[3] = shift(cell[2], piece_def[piece][2]); - cell[4] = shift(cell[3], piece_def[piece][3]); -} - -/* Convenience function to quickly calculate if a piece fits on the board */ -int cells_fit_on_board(char *cell, int piece) { - return (!out_of_bounds(cell[0], piece_def[piece][0]) && - !out_of_bounds(cell[1], piece_def[piece][1]) && - !out_of_bounds(cell[2], piece_def[piece][2]) && - !out_of_bounds(cell[3], piece_def[piece][3])); -} - -/* Returns the lowest index of the cells of a piece. - * I use the lowest index that a piece occupies as the index for looking up - * the piece in the solve function. - */ -char minimum_of_cells(char *cell) { - char minimum = cell[0]; - minimum = cell[1] < minimum ? cell[1] : minimum; - minimum = cell[2] < minimum ? cell[2] : minimum; - minimum = cell[3] < minimum ? cell[3] : minimum; - minimum = cell[4] < minimum ? cell[4] : minimum; - return minimum; -} - -/* Calculate the lowest possible open cell if the piece is placed on the board. - * Used to later reduce the amount of time searching for open cells in the - * solve function. - */ -char first_empty_cell(char *cell, char minimum) { - char first_empty = minimum; - while(first_empty == cell[0] || first_empty == cell[1] || - first_empty == cell[2] || first_empty == cell[3] || - first_empty == cell[4]) - first_empty++; - return first_empty; -} - -/* Generate the unsigned long long int that will later be anded with the - * board to determine if it fits. - */ -unsigned long long bitmask_from_cells(char *cell) { - unsigned long long piece_mask = 0ULL; - int i; - for(i = 0; i < 5; i++) - piece_mask |= 1ULL << cell[i]; - return piece_mask; -} - -/* Record the piece and other important information in arrays that will - * later be used by the solve function. - */ -void record_piece(int piece, int minimum, char first_empty, - unsigned long long piece_mask) { - pieces[piece][minimum][piece_counts[piece][minimum]] = piece_mask; - next_cell[piece][minimum][piece_counts[piece][minimum]] = first_empty; - piece_counts[piece][minimum]++; -} - - -/* Fill the entire board going cell by cell. If any cells are "trapped" - * they will be left alone. - */ -void fill_contiguous_space(char *board, int index) { - if(board[index] == 1) - return; - board[index] = 1; - if(!out_of_bounds(index, E)) - fill_contiguous_space(board, shift(index, E)); - if(!out_of_bounds(index, SE)) - fill_contiguous_space(board, shift(index, SE)); - if(!out_of_bounds(index, SW)) - fill_contiguous_space(board, shift(index, SW)); - if(!out_of_bounds(index, W)) - fill_contiguous_space(board, shift(index, W)); - if(!out_of_bounds(index, NW)) - fill_contiguous_space(board, shift(index, NW)); - if(!out_of_bounds(index, NE)) - fill_contiguous_space(board, shift(index, NE)); -} - - -/* To thin the number of pieces, I calculate if any of them trap any empty - * cells at the edges. There are only a handful of exceptions where the - * the board can be solved with the trapped cells. For example: piece 8 can - * trap 5 cells in the corner, but piece 3 can fit in those cells, or piece 0 - * can split the board in half where both halves are viable. - */ -int has_island(char *cell, int piece) { - char temp_board[50]; - char c; - int i; - for(i = 0; i < 50; i++) - temp_board[i] = 0; - for(i = 0; i < 5; i++) - temp_board[((int)cell[i])] = 1; - i = 49; - while(temp_board[i] == 1) - i--; - fill_contiguous_space(temp_board, i); - c = 0; - for(i = 0; i < 50; i++) - if(temp_board[i] == 0) - c++; - if(c == 0 || (c == 5 && piece == 8) || (c == 40 && piece == 8) || - (c % 5 == 0 && piece == 0)) - return FALSE; - else - return TRUE; -} - - -/* Calculate all six rotations of the specified piece at the specified index. - * We calculate only half of piece 3's rotations. This is because any solution - * found has an identical solution rotated 180 degrees. Thus we can reduce the - * number of attempted pieces in the solve algorithm by not including the 180- - * degree-rotated pieces of ONE of the pieces. I chose piece 3 because it gave - * me the best time ;) - */ - void calc_six_rotations(char piece, char index) { - char rotation, cell[5]; - char minimum, first_empty; - unsigned long long piece_mask; - - for(rotation = 0; rotation < 6; rotation++) { - if(piece != 3 || rotation < 3) { - calc_cell_indices(cell, piece, index); - if(cells_fit_on_board(cell, piece) && !has_island(cell, piece)) { - minimum = minimum_of_cells(cell); - first_empty = first_empty_cell(cell, minimum); - piece_mask = bitmask_from_cells(cell); - record_piece(piece, minimum, first_empty, piece_mask); - } - } - rotate_piece(piece); - } -} - -/* Calculate every legal rotation for each piece at each board location. */ -void calc_pieces(void) { - char piece, index; - - for(piece = 0; piece < 10; piece++) { - for(index = 0; index < 50; index++) { - calc_six_rotations(piece, index); - flip_piece(piece); - calc_six_rotations(piece, index); - } - } -} - - - -/* Calculate all 32 possible states for a 5-bit row and all rows that will - * create islands that follow any of the 32 possible rows. These pre- - * calculated 5-bit rows will be used to find islands in a partially solved - * board in the solve function. - */ -#define ROW_MASK 0x1F -#define TRIPLE_MASK 0x7FFF -char all_rows[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; -int bad_even_rows[32][32]; -int bad_odd_rows[32][32]; -int bad_even_triple[32768]; -int bad_odd_triple[32768]; - -int rows_bad(char row1, char row2, int even) { - /* even is referring to row1 */ - int i, in_zeroes, group_okay; - char block, row2_shift; - /* Test for blockages at same index and shifted index */ - if(even) - row2_shift = ((row2 << 1) & ROW_MASK) | 0x01; - else - row2_shift = (row2 >> 1) | 0x10; - block = ((row1 ^ row2) & row2) & ((row1 ^ row2_shift) & row2_shift); - /* Test for groups of 0's */ - in_zeroes = FALSE; - group_okay = FALSE; - for(i = 0; i < 5; i++) { - if(row1 & (1 << i)) { - if(in_zeroes) { - if(!group_okay) - return TRUE; - in_zeroes = FALSE; - group_okay = FALSE; - } - } else { - if(!in_zeroes) - in_zeroes = TRUE; - if(!(block & (1 << i))) - group_okay = TRUE; - } - } - if(in_zeroes) - return !group_okay; - else - return FALSE; -} - -/* Check for cases where three rows checked sequentially cause a false - * positive. One scenario is when 5 cells may be surrounded where piece 5 - * or 7 can fit. The other scenario is when piece 2 creates a hook shape. - */ -int triple_is_okay(char row1, char row2, char row3, int even) { - if(even) { - /* There are four cases: - * row1: 00011 00001 11001 10101 - * row2: 01011 00101 10001 10001 - * row3: 011?? 00110 ????? ????? - */ - return ((row1 == 0x03) && (row2 == 0x0B) && ((row3 & 0x1C) == 0x0C)) || - ((row1 == 0x01) && (row2 == 0x05) && (row3 == 0x06)) || - ((row1 == 0x19) && (row2 == 0x11)) || - ((row1 == 0x15) && (row2 == 0x11)); - } else { - /* There are two cases: - * row1: 10011 10101 - * row2: 10001 10001 - * row3: ????? ????? - */ - return ((row1 == 0x13) && (row2 == 0x11)) || - ((row1 == 0x15) && (row2 == 0x11)); - } -} - - -void calc_rows(void) { - int row1, row2, row3; - int result1, result2; - for(row1 = 0; row1 < 32; row1++) { - for(row2 = 0; row2 < 32; row2++) { - bad_even_rows[row1][row2] = rows_bad(row1, row2, TRUE); - bad_odd_rows[row1][row2] = rows_bad(row1, row2, FALSE); - } - } - for(row1 = 0; row1 < 32; row1++) { - for(row2 = 0; row2 < 32; row2++) { - for(row3 = 0; row3 < 32; row3++) { - result1 = bad_even_rows[row1][row2]; - result2 = bad_odd_rows[row2][row3]; - if(result1 == FALSE && result2 == TRUE - && triple_is_okay(row1, row2, row3, TRUE)) - bad_even_triple[row1+(row2*32)+(row3*1024)] = FALSE; - else - bad_even_triple[row1+(row2*32)+(row3*1024)] = result1 || result2; - - result1 = bad_odd_rows[row1][row2]; - result2 = bad_even_rows[row2][row3]; - if(result1 == FALSE && result2 == TRUE - && triple_is_okay(row1, row2, row3, FALSE)) - bad_odd_triple[row1+(row2*32)+(row3*1024)] = FALSE; - else - bad_odd_triple[row1+(row2*32)+(row3*1024)] = result1 || result2; - } - } - } -} - - - -/* Calculate islands while solving the board. - */ -int boardHasIslands(char cell) { - /* Too low on board, don't bother checking */ - if(cell >= 40) - return FALSE; - int current_triple = (board >> ((cell / 5) * 5)) & TRIPLE_MASK; - if((cell / 5) % 2) - return bad_odd_triple[current_triple]; - else - return bad_even_triple[current_triple]; -} - - -/* The recursive solve algorithm. Try to place each permutation in the upper- - * leftmost empty cell. Mark off available pieces as it goes along. - * Because the board is a bit mask, the piece number and bit mask must be saved - * at each successful piece placement. This data is used to create a 50 char - * array if a solution is found. - */ -short avail = 0x03FF; -char sol_nums[10]; -unsigned long long sol_masks[10]; -signed char solutions[2100][50]; -int solution_count = 0; -int max_solutions = 2100; - -void record_solution(void) { - int sol_no, index; - unsigned long long sol_mask; - for(sol_no = 0; sol_no < 10; sol_no++) { - sol_mask = sol_masks[sol_no]; - for(index = 0; index < 50; index++) { - if(sol_mask & 1ULL) { - solutions[solution_count][index] = sol_nums[sol_no]; - /* Board rotated 180 degrees is a solution too! */ - solutions[solution_count+1][49-index] = sol_nums[sol_no]; - } - sol_mask = sol_mask >> 1; - } - } - solution_count += 2; -} - -void solve(int depth, int cell) { - int piece, rotation, max_rots; - unsigned long long *piece_mask; - short piece_no_mask; - - if(solution_count >= max_solutions) - return; - - while(board & (1ULL << cell)) - cell++; - - for(piece = 0; piece < 10; piece++) { - piece_no_mask = 1 << piece; - if(!(avail & piece_no_mask)) - continue; - avail ^= piece_no_mask; - max_rots = piece_counts[piece][cell]; - piece_mask = pieces[piece][cell]; - for(rotation = 0; rotation < max_rots; rotation++) { - if(!(board & *(piece_mask + rotation))) { - sol_nums[depth] = piece; - sol_masks[depth] = *(piece_mask + rotation); - if(depth == 9) { - /* Solution found!!!!!11!!ONE! */ - record_solution(); - avail ^= piece_no_mask; - return; - } - board |= *(piece_mask + rotation); - if(!boardHasIslands(next_cell[piece][cell][rotation])) - solve(depth + 1, next_cell[piece][cell][rotation]); - board ^= *(piece_mask + rotation); - } - } - avail ^= piece_no_mask; - } -} - - -/* qsort comparator - used to find first and last solutions */ -int solution_sort(const void *elem1, const void *elem2) { - signed char *char1 = (signed char *) elem1; - signed char *char2 = (signed char *) elem2; - int i = 0; - while(i < 50 && char1[i] == char2[i]) - i++; - return char1[i] - char2[i]; -} - - -/* pretty print a board in the specified hexagonal format */ -void pretty(signed char *b) { - int i; - for(i = 0; i < 50; i += 10) { - printf("%c %c %c %c %c \n %c %c %c %c %c \n", b[i]+'0', b[i+1]+'0', - b[i+2]+'0', b[i+3]+'0', b[i+4]+'0', b[i+5]+'0', b[i+6]+'0', - b[i+7]+'0', b[i+8]+'0', b[i+9]+'0'); - } - printf("\n"); -} - -int main(int argc, char **argv) { - if(argc > 1) - max_solutions = atoi(argv[1]); - calc_pieces(); - calc_rows(); - solve(0, 0); - printf("%d solutions found\n\n", solution_count); - qsort(solutions, solution_count, 50 * sizeof(signed char), solution_sort); - pretty(solutions[0]); - pretty(solutions[solution_count-1]); - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.go b/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.go deleted file mode 100644 index 34a4e23f97b..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.go +++ /dev/null @@ -1,656 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * based on meteor-contest.c by Christian Vosteen - */ - -package main - -import ( - "flag" - "fmt" -) - -var max_solutions = flag.Int("n", 2100, "maximum number of solutions") - -func boolInt(b bool) int8 { - if b { - return 1 - } - return 0 -} - -/* The board is a 50 cell hexagonal pattern. For . . . . . - * maximum speed the board will be implemented as . . . . . - * 50 bits, which will fit into a 64 bit long long . . . . . - * int. . . . . . - * . . . . . - * I will represent 0's as empty cells and 1's . . . . . - * as full cells. . . . . . - * . . . . . - * . . . . . - * . . . . . - */ - -var board uint64 = 0xFFFC000000000000 - -/* The puzzle pieces must be specified by the path followed - * from one end to the other along 12 hexagonal directions. - * - * Piece 0 Piece 1 Piece 2 Piece 3 Piece 4 - * - * O O O O O O O O O O O O O O O - * O O O O O O O - * O O O - * - * Piece 5 Piece 6 Piece 7 Piece 8 Piece 9 - * - * O O O O O O O O O O O O O - * O O O O O O O O O - * O O O - * - * I had to make it 12 directions because I wanted all of the - * piece definitions to fit into the same size arrays. It is - * not possible to define piece 4 in terms of the 6 cardinal - * directions in 4 moves. - */ - -const ( - E = iota - ESE - SE - S - SW - WSW - W - WNW - NW - N - NE - ENE - PIVOT -) - -var piece_def = [10][4]int8{ - [4]int8{E, E, E, SE}, - [4]int8{SE, E, NE, E}, - [4]int8{E, E, SE, SW}, - [4]int8{E, E, SW, SE}, - [4]int8{SE, E, NE, S}, - [4]int8{E, E, SW, E}, - [4]int8{E, SE, SE, NE}, - [4]int8{E, SE, SE, W}, - [4]int8{E, SE, E, E}, - [4]int8{E, E, E, SW}, -} - -/* To minimize the amount of work done in the recursive solve function below, - * I'm going to allocate enough space for all legal rotations of each piece - * at each position on the board. That's 10 pieces x 50 board positions x - * 12 rotations. However, not all 12 rotations will fit on every cell, so - * I'll have to keep count of the actual number that do. - * The pieces are going to be unsigned long long ints just like the board so - * they can be bitwise-anded with the board to determine if they fit. - * I'm also going to record the next possible open cell for each piece and - * location to reduce the burden on the solve function. - */ -var ( - pieces [10][50][12]uint64 - piece_counts [10][50]int - next_cell [10][50][12]int8 -) - -/* Returns the direction rotated 60 degrees clockwise */ -func rotate(dir int8) int8 { return (dir + 2) % PIVOT } - -/* Returns the direction flipped on the horizontal axis */ -func flip(dir int8) int8 { return (PIVOT - dir) % PIVOT } - -/* Returns the new cell index from the specified cell in the - * specified direction. The index is only valid if the - * starting cell and direction have been checked by the - * out_of_bounds function first. - */ -func shift(cell, dir int8) int8 { - switch dir { - case E: - return cell + 1 - case ESE: - if ((cell / 5) % 2) != 0 { - return cell + 7 - } else { - return cell + 6 - } - case SE: - if ((cell / 5) % 2) != 0 { - return cell + 6 - } else { - return cell + 5 - } - case S: - return cell + 10 - case SW: - if ((cell / 5) % 2) != 0 { - return cell + 5 - } else { - return cell + 4 - } - case WSW: - if ((cell / 5) % 2) != 0 { - return cell + 4 - } else { - return cell + 3 - } - case W: - return cell - 1 - case WNW: - if ((cell / 5) % 2) != 0 { - return cell - 6 - } else { - return cell - 7 - } - case NW: - if ((cell / 5) % 2) != 0 { - return cell - 5 - } else { - return cell - 6 - } - case N: - return cell - 10 - case NE: - if ((cell / 5) % 2) != 0 { - return cell - 4 - } else { - return cell - 5 - } - case ENE: - if ((cell / 5) % 2) != 0 { - return cell - 3 - } else { - return cell - 4 - } - } - return cell -} - -/* Returns wether the specified cell and direction will land outside - * of the board. Used to determine if a piece is at a legal board - * location or not. - */ -func out_of_bounds(cell, dir int8) bool { - switch dir { - case E: - return cell%5 == 4 - case ESE: - i := cell % 10 - return i == 4 || i == 8 || i == 9 || cell >= 45 - case SE: - return cell%10 == 9 || cell >= 45 - case S: - return cell >= 40 - case SW: - return cell%10 == 0 || cell >= 45 - case WSW: - i := cell % 10 - return i == 0 || i == 1 || i == 5 || cell >= 45 - case W: - return cell%5 == 0 - case WNW: - i := cell % 10 - return i == 0 || i == 1 || i == 5 || cell < 5 - case NW: - return cell%10 == 0 || cell < 5 - case N: - return cell < 10 - case NE: - return cell%10 == 9 || cell < 5 - case ENE: - i := cell % 10 - return i == 4 || i == 8 || i == 9 || cell < 5 - } - return false -} - -/* Rotate a piece 60 degrees clockwise */ -func rotate_piece(piece int) { - for i := 0; i < 4; i++ { - piece_def[piece][i] = rotate(piece_def[piece][i]) - } -} - -/* Flip a piece along the horizontal axis */ -func flip_piece(piece int) { - for i := 0; i < 4; i++ { - piece_def[piece][i] = flip(piece_def[piece][i]) - } -} - -/* Convenience function to quickly calculate all of the indices for a piece */ -func calc_cell_indices(cell []int8, piece int, index int8) { - cell[0] = index - for i := 1; i < 5; i++ { - cell[i] = shift(cell[i-1], piece_def[piece][i-1]) - } -} - -/* Convenience function to quickly calculate if a piece fits on the board */ -func cells_fit_on_board(cell []int8, piece int) bool { - return !out_of_bounds(cell[0], piece_def[piece][0]) && - !out_of_bounds(cell[1], piece_def[piece][1]) && - !out_of_bounds(cell[2], piece_def[piece][2]) && - !out_of_bounds(cell[3], piece_def[piece][3]) -} - -/* Returns the lowest index of the cells of a piece. - * I use the lowest index that a piece occupies as the index for looking up - * the piece in the solve function. - */ -func minimum_of_cells(cell []int8) int8 { - minimum := cell[0] - for i := 1; i < 5; i++ { - if cell[i] < minimum { - minimum = cell[i] - } - } - return minimum -} - -/* Calculate the lowest possible open cell if the piece is placed on the board. - * Used to later reduce the amount of time searching for open cells in the - * solve function. - */ -func first_empty_cell(cell []int8, minimum int8) int8 { - first_empty := minimum - for first_empty == cell[0] || first_empty == cell[1] || - first_empty == cell[2] || first_empty == cell[3] || - first_empty == cell[4] { - first_empty++ - } - return first_empty -} - -/* Generate the unsigned long long int that will later be anded with the - * board to determine if it fits. - */ -func bitmask_from_cells(cell []int8) uint64 { - var piece_mask uint64 - for i := 0; i < 5; i++ { - piece_mask |= 1 << uint(cell[i]) - } - return piece_mask -} - -/* Record the piece and other important information in arrays that will - * later be used by the solve function. - */ -func record_piece(piece int, minimum int8, first_empty int8, piece_mask uint64) { - pieces[piece][minimum][piece_counts[piece][minimum]] = piece_mask - next_cell[piece][minimum][piece_counts[piece][minimum]] = first_empty - piece_counts[piece][minimum]++ -} - -/* Fill the entire board going cell by cell. If any cells are "trapped" - * they will be left alone. - */ -func fill_contiguous_space(board []int8, index int8) { - if board[index] == 1 { - return - } - board[index] = 1 - if !out_of_bounds(index, E) { - fill_contiguous_space(board, shift(index, E)) - } - if !out_of_bounds(index, SE) { - fill_contiguous_space(board, shift(index, SE)) - } - if !out_of_bounds(index, SW) { - fill_contiguous_space(board, shift(index, SW)) - } - if !out_of_bounds(index, W) { - fill_contiguous_space(board, shift(index, W)) - } - if !out_of_bounds(index, NW) { - fill_contiguous_space(board, shift(index, NW)) - } - if !out_of_bounds(index, NE) { - fill_contiguous_space(board, shift(index, NE)) - } -} - -/* To thin the number of pieces, I calculate if any of them trap any empty - * cells at the edges. There are only a handful of exceptions where the - * the board can be solved with the trapped cells. For example: piece 8 can - * trap 5 cells in the corner, but piece 3 can fit in those cells, or piece 0 - * can split the board in half where both halves are viable. - */ -func has_island(cell []int8, piece int) bool { - temp_board := make([]int8, 50) - var i int - for i = 0; i < 5; i++ { - temp_board[cell[i]] = 1 - } - i = 49 - for temp_board[i] == 1 { - i-- - } - fill_contiguous_space(temp_board, int8(i)) - c := 0 - for i = 0; i < 50; i++ { - if temp_board[i] == 0 { - c++ - } - } - if c == 0 || (c == 5 && piece == 8) || (c == 40 && piece == 8) || - (c%5 == 0 && piece == 0) { - return false - } - return true -} - -/* Calculate all six rotations of the specified piece at the specified index. - * We calculate only half of piece 3's rotations. This is because any solution - * found has an identical solution rotated 180 degrees. Thus we can reduce the - * number of attempted pieces in the solve algorithm by not including the 180- - * degree-rotated pieces of ONE of the pieces. I chose piece 3 because it gave - * me the best time ;) - */ -func calc_six_rotations(piece, index int) { - cell := make([]int8, 5) - for rotation := 0; rotation < 6; rotation++ { - if piece != 3 || rotation < 3 { - calc_cell_indices(cell, piece, int8(index)) - if cells_fit_on_board(cell, piece) && !has_island(cell, piece) { - minimum := minimum_of_cells(cell) - first_empty := first_empty_cell(cell, minimum) - piece_mask := bitmask_from_cells(cell) - record_piece(piece, minimum, first_empty, piece_mask) - } - } - rotate_piece(piece) - } -} - -/* Calculate every legal rotation for each piece at each board location. */ -func calc_pieces() { - for piece := 0; piece < 10; piece++ { - for index := 0; index < 50; index++ { - calc_six_rotations(piece, index) - flip_piece(piece) - calc_six_rotations(piece, index) - } - } -} - -/* Calculate all 32 possible states for a 5-bit row and all rows that will - * create islands that follow any of the 32 possible rows. These pre- - * calculated 5-bit rows will be used to find islands in a partially solved - * board in the solve function. - */ -const ( - ROW_MASK = 0x1F - TRIPLE_MASK = 0x7FFF -) - -var ( - all_rows = [32]int8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - } - bad_even_rows [32][32]int8 - bad_odd_rows [32][32]int8 - bad_even_triple [32768]int8 - bad_odd_triple [32768]int8 -) - -func rows_bad(row1, row2 int8, even bool) int8 { - /* even is referring to row1 */ - var row2_shift int8 - /* Test for blockages at same index and shifted index */ - if even { - row2_shift = ((row2 << 1) & ROW_MASK) | 0x01 - } else { - row2_shift = (row2 >> 1) | 0x10 - } - block := ((row1 ^ row2) & row2) & ((row1 ^ row2_shift) & row2_shift) - /* Test for groups of 0's */ - in_zeroes := false - group_okay := false - for i := uint8(0); i < 5; i++ { - if row1&(1<= 40 { - return 0 - } - current_triple := (board >> uint((cell/5)*5)) & TRIPLE_MASK - if (cell/5)%2 != 0 { - return bad_odd_triple[current_triple] - } - return bad_even_triple[current_triple] -} - -/* The recursive solve algorithm. Try to place each permutation in the upper- - * leftmost empty cell. Mark off available pieces as it goes along. - * Because the board is a bit mask, the piece number and bit mask must be saved - * at each successful piece placement. This data is used to create a 50 char - * array if a solution is found. - */ -var ( - avail uint16 = 0x03FF - sol_nums [10]int8 - sol_masks [10]uint64 - solutions [2100][50]int8 - solution_count = 0 -) - -func record_solution() { - for sol_no := 0; sol_no < 10; sol_no++ { - sol_mask := sol_masks[sol_no] - for index := 0; index < 50; index++ { - if sol_mask&1 == 1 { - solutions[solution_count][index] = sol_nums[sol_no] - /* Board rotated 180 degrees is a solution too! */ - solutions[solution_count+1][49-index] = sol_nums[sol_no] - } - sol_mask = sol_mask >> 1 - } - } - solution_count += 2 -} - -func solve(depth, cell int8) { - if solution_count >= *max_solutions { - return - } - - for board&(1< s { - largest = candidate - } - break - } - } - return -} - -func main() { - flag.Parse() - calc_pieces() - calc_rows() - solve(0, 0) - fmt.Printf("%d solutions found\n\n", solution_count) - smallest, largest := smallest_largest() - pretty(smallest) - pretty(largest) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.txt b/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.txt deleted file mode 100644 index 38d9783d64f..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/meteor-contest.txt +++ /dev/null @@ -1,24 +0,0 @@ -2098 solutions found - -0 0 0 0 1 - 2 2 2 0 1 -2 6 6 1 1 - 2 6 1 5 5 -8 6 5 5 5 - 8 6 3 3 3 -4 8 8 9 3 - 4 4 8 9 3 -4 7 4 7 9 - 7 7 7 9 9 - -9 9 9 9 8 - 9 6 6 8 5 -6 6 8 8 5 - 6 8 2 5 5 -7 7 7 2 5 - 7 4 7 2 0 -1 4 2 2 0 - 1 4 4 0 3 -1 4 0 0 3 - 1 1 3 3 3 - diff --git a/gcc/testsuite/go.test/test/bench/shootout/nbody.c b/gcc/testsuite/go.test/test/bench/shootout/nbody.c deleted file mode 100644 index 3b95b05929e..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/nbody.c +++ /dev/null @@ -1,170 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * The Great Computer Language Shootout - * http://shootout.alioth.debian.org/ - * - * contributed by Christoph Bauer - * - */ - -#include -#include -#include - -#define pi 3.141592653589793 -#define solar_mass (4 * pi * pi) -#define days_per_year 365.24 - -struct planet { - double x, y, z; - double vx, vy, vz; - double mass; -}; - -void advance(int nbodies, struct planet * bodies, double dt) -{ - int i, j; - - for (i = 0; i < nbodies; i++) { - struct planet * b = &(bodies[i]); - for (j = i + 1; j < nbodies; j++) { - struct planet * b2 = &(bodies[j]); - double dx = b->x - b2->x; - double dy = b->y - b2->y; - double dz = b->z - b2->z; - double distance = sqrt(dx * dx + dy * dy + dz * dz); - double mag = dt / (distance * distance * distance); - b->vx -= dx * b2->mass * mag; - b->vy -= dy * b2->mass * mag; - b->vz -= dz * b2->mass * mag; - b2->vx += dx * b->mass * mag; - b2->vy += dy * b->mass * mag; - b2->vz += dz * b->mass * mag; - } - } - for (i = 0; i < nbodies; i++) { - struct planet * b = &(bodies[i]); - b->x += dt * b->vx; - b->y += dt * b->vy; - b->z += dt * b->vz; - } -} - -double energy(int nbodies, struct planet * bodies) -{ - double e; - int i, j; - - e = 0.0; - for (i = 0; i < nbodies; i++) { - struct planet * b = &(bodies[i]); - e += 0.5 * b->mass * (b->vx * b->vx + b->vy * b->vy + b->vz * b->vz); - for (j = i + 1; j < nbodies; j++) { - struct planet * b2 = &(bodies[j]); - double dx = b->x - b2->x; - double dy = b->y - b2->y; - double dz = b->z - b2->z; - double distance = sqrt(dx * dx + dy * dy + dz * dz); - e -= (b->mass * b2->mass) / distance; - } - } - return e; -} - -void offset_momentum(int nbodies, struct planet * bodies) -{ - double px = 0.0, py = 0.0, pz = 0.0; - int i; - for (i = 0; i < nbodies; i++) { - px += bodies[i].vx * bodies[i].mass; - py += bodies[i].vy * bodies[i].mass; - pz += bodies[i].vz * bodies[i].mass; - } - bodies[0].vx = - px / solar_mass; - bodies[0].vy = - py / solar_mass; - bodies[0].vz = - pz / solar_mass; -} - -#define NBODIES 5 -struct planet bodies[NBODIES] = { - { /* sun */ - 0, 0, 0, 0, 0, 0, solar_mass - }, - { /* jupiter */ - 4.84143144246472090e+00, - -1.16032004402742839e+00, - -1.03622044471123109e-01, - 1.66007664274403694e-03 * days_per_year, - 7.69901118419740425e-03 * days_per_year, - -6.90460016972063023e-05 * days_per_year, - 9.54791938424326609e-04 * solar_mass - }, - { /* saturn */ - 8.34336671824457987e+00, - 4.12479856412430479e+00, - -4.03523417114321381e-01, - -2.76742510726862411e-03 * days_per_year, - 4.99852801234917238e-03 * days_per_year, - 2.30417297573763929e-05 * days_per_year, - 2.85885980666130812e-04 * solar_mass - }, - { /* uranus */ - 1.28943695621391310e+01, - -1.51111514016986312e+01, - -2.23307578892655734e-01, - 2.96460137564761618e-03 * days_per_year, - 2.37847173959480950e-03 * days_per_year, - -2.96589568540237556e-05 * days_per_year, - 4.36624404335156298e-05 * solar_mass - }, - { /* neptune */ - 1.53796971148509165e+01, - -2.59193146099879641e+01, - 1.79258772950371181e-01, - 2.68067772490389322e-03 * days_per_year, - 1.62824170038242295e-03 * days_per_year, - -9.51592254519715870e-05 * days_per_year, - 5.15138902046611451e-05 * solar_mass - } -}; - -int main(int argc, char ** argv) -{ - int n = atoi(argv[1]); - int i; - - offset_momentum(NBODIES, bodies); - printf ("%.9f\n", energy(NBODIES, bodies)); - for (i = 1; i <= n; i++) - advance(NBODIES, bodies, 0.01); - printf ("%.9f\n", energy(NBODIES, bodies)); - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/nbody.go b/gcc/testsuite/go.test/test/bench/shootout/nbody.go deleted file mode 100644 index 988f3ba9cc0..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/nbody.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * based on C program by Christoph Bauer - */ - -package main - -import ( - "flag" - "fmt" - "math" -) - -var n = flag.Int("n", 1000, "number of iterations") - -type Body struct { - x, y, z, vx, vy, vz, mass float64 -} - -const ( - solarMass = 4 * math.Pi * math.Pi - daysPerYear = 365.24 -) - -func (b *Body) offsetMomentum(px, py, pz float64) { - b.vx = -px / solarMass - b.vy = -py / solarMass - b.vz = -pz / solarMass -} - -type System []*Body - -func NewSystem(body []Body) System { - n := make(System, len(body)) - for i := 0; i < len(body); i++ { - n[i] = new(Body) // copy to avoid overwriting the inputs - *n[i] = body[i] - } - var px, py, pz float64 - for _, body := range n { - px += body.vx * body.mass - py += body.vy * body.mass - pz += body.vz * body.mass - } - n[0].offsetMomentum(px, py, pz) - return n -} - -func (sys System) energy() float64 { - var e float64 - for i, body := range sys { - e += 0.5 * body.mass * - (body.vx*body.vx + body.vy*body.vy + body.vz*body.vz) - for j := i + 1; j < len(sys); j++ { - body2 := sys[j] - dx := body.x - body2.x - dy := body.y - body2.y - dz := body.z - body2.z - distance := math.Sqrt(dx*dx + dy*dy + dz*dz) - e -= (body.mass * body2.mass) / distance - } - } - return e -} - -func (sys System) advance(dt float64) { - for i, body := range sys { - for j := i + 1; j < len(sys); j++ { - body2 := sys[j] - dx := body.x - body2.x - dy := body.y - body2.y - dz := body.z - body2.z - - dSquared := dx*dx + dy*dy + dz*dz - distance := math.Sqrt(dSquared) - mag := dt / (dSquared * distance) - - body.vx -= dx * body2.mass * mag - body.vy -= dy * body2.mass * mag - body.vz -= dz * body2.mass * mag - - body2.vx += dx * body.mass * mag - body2.vy += dy * body.mass * mag - body2.vz += dz * body.mass * mag - } - } - - for _, body := range sys { - body.x += dt * body.vx - body.y += dt * body.vy - body.z += dt * body.vz - } -} - -var ( - jupiter = Body{ - x: 4.84143144246472090e+00, - y: -1.16032004402742839e+00, - z: -1.03622044471123109e-01, - vx: 1.66007664274403694e-03 * daysPerYear, - vy: 7.69901118419740425e-03 * daysPerYear, - vz: -6.90460016972063023e-05 * daysPerYear, - mass: 9.54791938424326609e-04 * solarMass, - } - saturn = Body{ - x: 8.34336671824457987e+00, - y: 4.12479856412430479e+00, - z: -4.03523417114321381e-01, - vx: -2.76742510726862411e-03 * daysPerYear, - vy: 4.99852801234917238e-03 * daysPerYear, - vz: 2.30417297573763929e-05 * daysPerYear, - mass: 2.85885980666130812e-04 * solarMass, - } - uranus = Body{ - x: 1.28943695621391310e+01, - y: -1.51111514016986312e+01, - z: -2.23307578892655734e-01, - vx: 2.96460137564761618e-03 * daysPerYear, - vy: 2.37847173959480950e-03 * daysPerYear, - vz: -2.96589568540237556e-05 * daysPerYear, - mass: 4.36624404335156298e-05 * solarMass, - } - neptune = Body{ - x: 1.53796971148509165e+01, - y: -2.59193146099879641e+01, - z: 1.79258772950371181e-01, - vx: 2.68067772490389322e-03 * daysPerYear, - vy: 1.62824170038242295e-03 * daysPerYear, - vz: -9.51592254519715870e-05 * daysPerYear, - mass: 5.15138902046611451e-05 * solarMass, - } - sun = Body{ - mass: solarMass, - } -) - -func main() { - flag.Parse() - - system := NewSystem([]Body{sun, jupiter, saturn, uranus, neptune}) - fmt.Printf("%.9f\n", system.energy()) - for i := 0; i < *n; i++ { - system.advance(0.01) - } - fmt.Printf("%.9f\n", system.energy()) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/nbody.txt b/gcc/testsuite/go.test/test/bench/shootout/nbody.txt deleted file mode 100644 index 1731557ce19..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/nbody.txt +++ /dev/null @@ -1,2 +0,0 @@ --0.169075164 --0.169087605 diff --git a/gcc/testsuite/go.test/test/bench/shootout/pidigits.c b/gcc/testsuite/go.test/test/bench/shootout/pidigits.c deleted file mode 100644 index c064da0dd20..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/pidigits.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - http://shootout.alioth.debian.org/ - - contributed by Paolo Bonzini & Sean Bartlett - modified by Michael Mellor -*/ - -#include -#include -#include - -static mpz_t numer, accum, denom, tmp1, tmp2; - -static int extract_digit() -{ - if (mpz_cmp(numer, accum) > 0) - return -1; - - /* Compute (numer * 3 + accum) / denom */ - mpz_mul_2exp(tmp1, numer, 1); - mpz_add(tmp1, tmp1, numer); - mpz_add(tmp1, tmp1, accum); - mpz_fdiv_qr(tmp1, tmp2, tmp1, denom); - - /* Now, if (numer * 4 + accum) % denom... */ - mpz_add(tmp2, tmp2, numer); - - /* ... is normalized, then the two divisions have the same result. */ - if (mpz_cmp(tmp2, denom) >= 0) - return -1; - - return mpz_get_ui(tmp1); -} - -static void next_term(unsigned int k) -{ - unsigned int y2 = k*2 + 1; - - mpz_mul_2exp(tmp1, numer, 1); - mpz_add(accum, accum, tmp1); - mpz_mul_ui(accum, accum, y2); - mpz_mul_ui(numer, numer, k); - mpz_mul_ui(denom, denom, y2); -} - -static void eliminate_digit(unsigned int d) -{ - mpz_submul_ui(accum, denom, d); - mpz_mul_ui(accum, accum, 10); - mpz_mul_ui(numer, numer, 10); -} - -static void pidigits(unsigned int n) -{ - int d; - unsigned int i = 0, k = 0, m; - mpz_init(tmp1); - mpz_init(tmp2); - mpz_init_set_ui(numer, 1); - mpz_init_set_ui(accum, 0); - mpz_init_set_ui(denom, 1); - - for(;;) - { - do { - k++; - next_term(k); - d = extract_digit(); - } while(d == -1); - - putchar(d + '0'); - - i++; - m = i%10; - if(m == 0) - printf("\t:%d\n", i); - if(i >= n) - break; - eliminate_digit(d); - } - - if(m) { - m = 10 - m; - while(m--) - putchar(' '); - printf("\t:%d\n", n); - } -} - -int main(int argc, char **argv) -{ - pidigits(argc > 1 ? atoi(argv[1]) : 27); - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/pidigits.go b/gcc/testsuite/go.test/test/bench/shootout/pidigits.go deleted file mode 100644 index a0f21a91db6..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/pidigits.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * based on pidigits.c (by Paolo Bonzini & Sean Bartlett, - * modified by Michael Mellor) - */ - -package main - -import ( - "flag" - "fmt" - "math/big" -) - -var n = flag.Int("n", 27, "number of digits") -var silent = flag.Bool("s", false, "don't print result") - -var ( - tmp1 = big.NewInt(0) - tmp2 = big.NewInt(0) - tmp3 = big.NewInt(0) - y2 = big.NewInt(0) - bigk = big.NewInt(0) - numer = big.NewInt(1) - accum = big.NewInt(0) - denom = big.NewInt(1) - ten = big.NewInt(10) -) - -func extract_digit() int64 { - if numer.Cmp(accum) > 0 { - return -1 - } - - // Compute (numer * 3 + accum) / denom - tmp1.Lsh(numer, 1) - tmp1.Add(tmp1, numer) - tmp1.Add(tmp1, accum) - tmp1.DivMod(tmp1, denom, tmp2) - - // Now, if (numer * 4 + accum) % denom... - tmp2.Add(tmp2, numer) - - // ... is normalized, then the two divisions have the same result. - if tmp2.Cmp(denom) >= 0 { - return -1 - } - - return tmp1.Int64() -} - -func next_term(k int64) { - y2.SetInt64(k*2 + 1) - bigk.SetInt64(k) - - tmp1.Lsh(numer, 1) - accum.Add(accum, tmp1) - accum.Mul(accum, y2) - numer.Mul(numer, bigk) - denom.Mul(denom, y2) -} - -func eliminate_digit(d int64) { - tmp3.SetInt64(d) - accum.Sub(accum, tmp3.Mul(denom, tmp3)) - accum.Mul(accum, ten) - numer.Mul(numer, ten) -} - -func printf(s string, arg ...interface{}) { - if !*silent { - fmt.Printf(s, arg...) - } -} - -func main() { - flag.Parse() - - var m int // 0 <= m < 10 - for i, k := 0, int64(0); ; { - d := int64(-1) - for d < 0 { - k++ - next_term(k) - d = extract_digit() - } - - printf("%c", d+'0') - - i++ - m = i % 10 - if m == 0 { - printf("\t:%d\n", i) - } - if i >= *n { - break - } - eliminate_digit(d) - } - - if m > 0 { - printf("%s\t:%d\n", " "[m:10], *n) - } -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/pidigits.txt b/gcc/testsuite/go.test/test/bench/shootout/pidigits.txt deleted file mode 100644 index ad946a9e85d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/pidigits.txt +++ /dev/null @@ -1,3 +0,0 @@ -3141592653 :10 -5897932384 :20 -6264338 :27 diff --git a/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.go b/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.go deleted file mode 100644 index 9c6d42101d9..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "fmt" - "io/ioutil" - "os" - "regexp" - "runtime" -) - -var variants = []string{ - "agggtaaa|tttaccct", - "[cgt]gggtaaa|tttaccc[acg]", - "a[act]ggtaaa|tttacc[agt]t", - "ag[act]gtaaa|tttac[agt]ct", - "agg[act]taaa|ttta[agt]cct", - "aggg[acg]aaa|ttt[cgt]ccct", - "agggt[cgt]aa|tt[acg]accct", - "agggta[cgt]a|t[acg]taccct", - "agggtaa[cgt]|[acg]ttaccct", -} - -type Subst struct { - pat, repl string -} - -var substs = []Subst{ - Subst{"B", "(c|g|t)"}, - Subst{"D", "(a|g|t)"}, - Subst{"H", "(a|c|t)"}, - Subst{"K", "(g|t)"}, - Subst{"M", "(a|c)"}, - Subst{"N", "(a|c|g|t)"}, - Subst{"R", "(a|g)"}, - Subst{"S", "(c|g)"}, - Subst{"V", "(a|c|g)"}, - Subst{"W", "(a|t)"}, - Subst{"Y", "(c|t)"}, -} - -func countMatches(pat string, bytes []byte) int { - re := regexp.MustCompile(pat) - n := 0 - for { - e := re.FindIndex(bytes) - if e == nil { - break - } - n++ - bytes = bytes[e[1]:] - } - return n -} - -func main() { - runtime.GOMAXPROCS(4) - bytes, err := ioutil.ReadAll(os.Stdin) - if err != nil { - fmt.Fprintf(os.Stderr, "can't read input: %s\n", err) - os.Exit(2) - } - ilen := len(bytes) - // Delete the comment lines and newlines - bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}) - clen := len(bytes) - - mresults := make([]chan int, len(variants)) - for i, s := range variants { - ch := make(chan int) - mresults[i] = ch - go func(ss string) { - ch <- countMatches(ss, bytes) - }(s) - } - - lenresult := make(chan int) - bb := bytes - go func() { - for _, sub := range substs { - bb = regexp.MustCompile(sub.pat).ReplaceAll(bb, []byte(sub.repl)) - } - lenresult <- len(bb) - }() - - for i, s := range variants { - fmt.Printf("%s %d\n", s, <-mresults[i]) - } - fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, <-lenresult) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.txt b/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.txt deleted file mode 100644 index e23e71fd6eb..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/regex-dna-parallel.txt +++ /dev/null @@ -1,13 +0,0 @@ -agggtaaa|tttaccct 1 -[cgt]gggtaaa|tttaccc[acg] 0 -a[act]ggtaaa|tttacc[agt]t 0 -ag[act]gtaaa|tttac[agt]ct 0 -agg[act]taaa|ttta[agt]cct 1 -aggg[acg]aaa|ttt[cgt]ccct 0 -agggt[cgt]aa|tt[acg]accct 0 -agggta[cgt]a|t[acg]taccct 0 -agggtaa[cgt]|[acg]ttaccct 2 - -10245 -10000 -13348 diff --git a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.c b/gcc/testsuite/go.test/test/bench/shootout/regex-dna.c deleted file mode 100644 index 134f8215c7f..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.c +++ /dev/null @@ -1,154 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -** The Computer Language Shootout -** http://shootout.alioth.debian.org/ -** contributed by Mike Pall -** -** regex-dna benchmark using PCRE -** -** compile with: -** gcc -O3 -fomit-frame-pointer -o regexdna regexdna.c -lpcre -*/ - -#define __USE_STRING_INLINES -#include -#include -#include -#include - -typedef struct fbuf { - char *buf; - size_t size, len; -} fbuf_t; - -static void fb_init(fbuf_t *b) -{ - b->buf = NULL; - b->len = b->size = 0; -} - -static char *fb_need(fbuf_t *b, size_t need) -{ - need += b->len; - if (need > b->size) { - if (b->size == 0) b->size = need; - else while (need > b->size) b->size += b->size; - if (!(b->buf = realloc(b->buf, b->size))) exit(1); - } - return b->buf+b->len; -} - -#define FB_MINREAD (3<<16) - -/* Read all of a stdio stream into dst buffer. */ -static size_t fb_readall(fbuf_t *dst, FILE *fp) -{ - char *dp; - int n; - for (dp = fb_need(dst, FB_MINREAD); - (n = fread(dp, 1, dst->size-dst->len, fp)) > 0; - dp = fb_need(dst, FB_MINREAD)) dst->len += n; - if (ferror(fp)) exit(1); - return dst->len; -} - -/* Substitute pattern p with replacement r, copying from src to dst buffer. */ -static size_t fb_subst(fbuf_t *dst, fbuf_t *src, const char *p, const char *r) -{ - pcre *re; - pcre_extra *re_ex; - const char *re_e; - char *dp; - int re_eo, m[3], pos, rlen, clen; - if (!(re = pcre_compile(p, PCRE_CASELESS, &re_e, &re_eo, NULL))) exit(1); - re_ex = pcre_study(re, 0, &re_e); - for (dst->len = 0, rlen = strlen(r), pos = 0; - pcre_exec(re, re_ex, src->buf, src->len, pos, 0, m, 3) >= 0; - pos = m[1]) { - clen = m[0]-pos; - dp = fb_need(dst, clen+rlen); - dst->len += clen+rlen; - memcpy(dp, src->buf+pos, clen); - memcpy(dp+clen, r, rlen); - } - clen = src->len-pos; - dp = fb_need(dst, clen); - dst->len += clen; - memcpy(dp, src->buf+pos, clen); - return dst->len; -} - -/* Count all matches with pattern p in src buffer. */ -static int fb_countmatches(fbuf_t *src, const char *p) -{ - pcre *re; - pcre_extra *re_ex; - const char *re_e; - int re_eo, m[3], pos, count; - if (!(re = pcre_compile(p, PCRE_CASELESS, &re_e, &re_eo, NULL))) exit(1); - re_ex = pcre_study(re, 0, &re_e); - for (count = 0, pos = 0; - pcre_exec(re, re_ex, src->buf, src->len, pos, 0, m, 3) >= 0; - pos = m[1]) count++; - return count; -} - -static const char *variants[] = { - "agggtaaa|tttaccct", "[cgt]gggtaaa|tttaccc[acg]", - "a[act]ggtaaa|tttacc[agt]t", "ag[act]gtaaa|tttac[agt]ct", - "agg[act]taaa|ttta[agt]cct", "aggg[acg]aaa|ttt[cgt]ccct", - "agggt[cgt]aa|tt[acg]accct", "agggta[cgt]a|t[acg]taccct", - "agggtaa[cgt]|[acg]ttaccct", NULL -}; - -static const char *subst[] = { - "B", "(c|g|t)", "D", "(a|g|t)", "H", "(a|c|t)", "K", "(g|t)", - "M", "(a|c)", "N", "(a|c|g|t)", "R", "(a|g)", "S", "(c|g)", - "V", "(a|c|g)", "W", "(a|t)", "Y", "(c|t)", NULL -}; - -int main(int argc, char **argv) -{ - fbuf_t seq[2]; - const char **pp; - size_t ilen, clen, slen; - int flip; - fb_init(&seq[0]); - fb_init(&seq[1]); - ilen = fb_readall(&seq[0], stdin); - clen = fb_subst(&seq[1], &seq[0], ">.*|\n", ""); - for (pp = variants; *pp; pp++) - printf("%s %d\n", *pp, fb_countmatches(&seq[1], *pp)); - for (slen = 0, flip = 1, pp = subst; *pp; pp += 2, flip = 1-flip) - slen = fb_subst(&seq[1-flip], &seq[flip], *pp, pp[1]); - printf("\n%zu\n%zu\n%zu\n", ilen, clen, slen); - return 0; -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.go b/gcc/testsuite/go.test/test/bench/shootout/regex-dna.go deleted file mode 100644 index 042d7f28361..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "fmt" - "io/ioutil" - "os" - "regexp" -) - -var variants = []string{ - "agggtaaa|tttaccct", - "[cgt]gggtaaa|tttaccc[acg]", - "a[act]ggtaaa|tttacc[agt]t", - "ag[act]gtaaa|tttac[agt]ct", - "agg[act]taaa|ttta[agt]cct", - "aggg[acg]aaa|ttt[cgt]ccct", - "agggt[cgt]aa|tt[acg]accct", - "agggta[cgt]a|t[acg]taccct", - "agggtaa[cgt]|[acg]ttaccct", -} - -type Subst struct { - pat, repl string -} - -var substs = []Subst{ - Subst{"B", "(c|g|t)"}, - Subst{"D", "(a|g|t)"}, - Subst{"H", "(a|c|t)"}, - Subst{"K", "(g|t)"}, - Subst{"M", "(a|c)"}, - Subst{"N", "(a|c|g|t)"}, - Subst{"R", "(a|g)"}, - Subst{"S", "(c|g)"}, - Subst{"V", "(a|c|g)"}, - Subst{"W", "(a|t)"}, - Subst{"Y", "(c|t)"}, -} - -func countMatches(pat string, bytes []byte) int { - re := regexp.MustCompile(pat) - n := 0 - for { - e := re.FindIndex(bytes) - if len(e) == 0 { - break - } - n++ - bytes = bytes[e[1]:] - } - return n -} - -func main() { - bytes, err := ioutil.ReadAll(os.Stdin) - if err != nil { - fmt.Fprintf(os.Stderr, "can't read input: %s\n", err) - os.Exit(2) - } - ilen := len(bytes) - // Delete the comment lines and newlines - bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}) - clen := len(bytes) - for _, s := range variants { - fmt.Printf("%s %d\n", s, countMatches(s, bytes)) - } - for _, sub := range substs { - bytes = regexp.MustCompile(sub.pat).ReplaceAll(bytes, []byte(sub.repl)) - } - fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes)) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.txt b/gcc/testsuite/go.test/test/bench/shootout/regex-dna.txt deleted file mode 100644 index e23e71fd6eb..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/regex-dna.txt +++ /dev/null @@ -1,13 +0,0 @@ -agggtaaa|tttaccct 1 -[cgt]gggtaaa|tttaccc[acg] 0 -a[act]ggtaaa|tttacc[agt]t 0 -ag[act]gtaaa|tttac[agt]ct 0 -agg[act]taaa|ttta[agt]cct 1 -aggg[acg]aaa|ttt[cgt]ccct 0 -agggt[cgt]aa|tt[acg]accct 0 -agggta[cgt]a|t[acg]taccct 0 -agggtaa[cgt]|[acg]ttaccct 2 - -10245 -10000 -13348 diff --git a/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.c b/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.c deleted file mode 100644 index b34c84696ed..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org - * - * contributed by Bob W - */ - -#include -#include - -#define JBFSIZE 82 // line input buffer size -#define QBFSIZE 5200 // output buffer initial size -#define Z16 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" -#define V32 "\0TVGH\0\0CD\0\0M\0KN\0\0\0YSA\0BW\0R\0\0\0\0\0\0" -#define VALL Z16 Z16 Z16 Z16 V32 V32 Z16 Z16 Z16 Z16 Z16 Z16 Z16 Z16 - -int errex(char *s, int n) { // error message+value, return 1 - fprintf(stderr,"\n*** Error: %s [%d]!\n", s, n); - return 1; -} - -int main () { // ***** main ***** - char *pj, *pq, *pr; // buffer pointers: inp,out,/out - char *jjj = malloc(JBFSIZE); // allocate input line buffer - char *qqq = malloc(QBFSIZE); // output buffer (dyn. size) - char *pqstop = qqq+QBFSIZE; // end-of-buffer pointer - char xtab[256] = VALL; // char conversion table - - if (!jjj || !qqq) - return errex("Buffer allocation", !jjj + !qqq); - pj = fgets(jjj,JBFSIZE,stdin); // fetch 1st line - if (!pj) - return errex("No input data",0); - if (*jjj != '>') - return errex("1st char not '>'", 0); - - while (pj) { // MAIN LOOP: process data - fputs(jjj, stdout); // output ID line - - for (pq=qqq+1, pr=pqstop; ; pq++) { // LOOP: fill output buffer - pj = fgets(jjj, JBFSIZE, stdin); // get line from stdin - if (!pj || (*jjj=='>')) break; // EOF or new ID line - if (pr <= (pq+61)) { // need to resize buffer - char *newstop = pqstop + 12777888; - char *newptr = realloc(qqq, newstop-qqq); - if (!newptr) - return errex("Out of memory", 0); - if (newptr != qqq) { // new base: adj. pointers - size_t x = newptr-qqq; // offset for pointer update - pq+=x; pr+=x; qqq+=x; - newstop+=x; pqstop+=x; - } - pr = __builtin_memmove(newstop-(pqstop-pr), pr, pqstop-pr); - pqstop = newstop; // buffer resize complete - } - while (*pj) { // LOOP: conv. & revert line - char c = xtab[(unsigned char)(*pj++)]; - if (c) // conversion valid - *(--pr) = c; - } - } - - for (pq = qqq; pr' { - break - } - line = line[0 : len(line)-1] - nchar += len(line) - if len(line)+nchar/60+128 >= w { - nbuf := make([]byte, len(buf)*5) - copy(nbuf[len(nbuf)-len(buf):], buf) - w += len(nbuf) - len(buf) - buf = nbuf - } - - // This loop is the bottleneck. - for _, c := range line { - w-- - buf[w] = complement[c] - } - } - - // Copy down to beginning of buffer, inserting newlines. - // The loop left room for the newlines and 128 bytes of padding. - i := 0 - for j := w; j < len(buf); j += 60 { - n := copy(buf[i:i+60], buf[j:]) - buf[i+n] = '\n' - i += n + 1 - } - os.Stdout.Write(buf[0:i]) - } -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.txt b/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.txt deleted file mode 100644 index 14d792ade8d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/reverse-complement.txt +++ /dev/null @@ -1,171 +0,0 @@ ->ONE Homo sapiens alu -CGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAAC -CTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACA -GGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCAT -GTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAA -AGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTC -TGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGG -GTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACC -ACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTG -GTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTA -CAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCT -GGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTC -TCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAAT -TTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCT -GACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCA -CCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGC -GCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCC -TCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTA -GTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGAT -CCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCT -TTTTGAGACGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTC -ACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTG -GGATTACAGGCGCGCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGT -TTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGG -CCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAG -TCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCG -CCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGC -GCGCCACCACGCCCGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGG -CCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGC -TGGGATTACAGGCGTGAGCCACCGCGCCCGGCCTTTTTGAGACGGAGTCTCGCTCTGTCG -CCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCA -AGCGATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGGCGCGCGCCACCACGCC -CGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGTTGGCCAGGCTGGTCTC -GAACTCCTGACCTCAGGTGATCCGCCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGC -GTGAGCCACCGCGCCCGGCC ->TWO IUB ambiguity codes -TAGGDHACHATCRGTRGVTGAGWTATGYTGCTGTCABACDWVTRTAAGAVVAGATTTNDA -GASMTCTGCATBYTTCAAKTTACMTATTACTTCATARGGYACMRTGTTTTYTATACVAAT -TTCTAKGDACKADACTATATNTANTCGTTCACGBCGYSCBHTANGGTGATCGTAAAGTAA -CTATBAAAAGATSTGWATBCSGAKHTTABBAACGTSYCATGCAAVATKTSKTASCGGAAT -WVATTTNTCCTTCTTCTTDDAGTGGTTGGATACVGTTAYMTMTBTACTTTHAGCTAGBAA -AAGAGKAAGTTRATWATCAGATTMDDTTTAAAVAAATATTKTCYTAAATTVCNKTTRACG -ADTATATTTATGATSADSCAATAWAGCGRTAGTGTAAGTGACVGRADYGTGCTACHVSDT -CTVCARCSYTTAATATARAAAATTTAATTTACDAATTGBACAGTAYAABATBTGCAGBVG -TGATGGDCAAAATBNMSTTABKATTGGSTCCTAGBTTACTTGTTTAGTTTATHCGATSTA -AAGTCGAKAAASTGTTTTAWAKCAGATATACTTTTMTTTTGBATAGAGGAGCMATGATRA -AAGGNCAYDCCDDGAAAGTHGBTAATCKYTBTACBGTBCTTTTTGDTAASSWTAAWAARA -TTGGCTAAGWGRADTYACATAGCTCBTAGATAWAGCAATNGTATMATGTTKMMAGTAWTC -CCNTSGAAWATWCAAAAMACTGAADNTYGATNAATCCGAYWNCTAACGTTAGAGDTTTTC -ATCTGGKRTAVGAABVCTGWGBTCTDVGKATTBTCTAAGGVADAAAVWTCTAGGGGAGGG -TTAGAACAATTAAHTAATNAAATGCATKATCTAAYRTDTCAGSAYTTYHGATRTTWAVTA -BGNTCDACAGBCCRCAGWCRTCABTGMMAWGMCTCAACCGATRTGBCAVAATCGTDWDAA -CAYAWAATWCTGGTAHCCCTAAGATAACSCTTAGTGSAACAWTBGTCDTTDGACWDBAAC -HTTTNGSKTYYAAYGGATNTGATTTAARTTAMBAATCTAAGTBTCATYTAACTTADTGTT -TCGATACGAAHGGCYATATACCWDTKYATDCSHTDTCAAAATGTGBACTGSCCVGATGTA -TCMMAGCCTTDAAABAATGAAGAGTAACTHATMGVTTAATAACCCGGTTVSANTGCAATT -GTGAGATTTAMGTTTAMAAYGCTGACAYAAAAAGGCACAMYTAAGVGGCTGGAABVTACG -GATTSTYGTBVAKTATWACCGTGTKAGTDTGTATGTTTAAAGGAAAAAGTAACATARAAA -GGTYCAMNYAAABTATAGNTSATANAGTCATCCTATWADKAACTRGTMSACDGTATSAYT -AAHSHGTAABYGACTYTATADTGSTATAGAGAAATCGNTAAAGGAAATCAGTTGTNCYMV -TNACDRTATBNATATASTAGAAMSCGGGANRCKKMCAAACATTNAGTCTRMAATBMTACC -CGTACTTCTBGDSYAATWGAAAATGACADDCHAKAAAYATATTKTTTTCACANACWAGAA -AKATCCTTATTAYKHKCTAAACARTATTTTDATBTVWCYGCAATACTAGGKAAASTTDGA -MGGCHTTHAATVCAHDRYAGGRCTATACGTCMAGAGAGCTBTHGNACARTCCBDCTAAGA -GCGGCTTTARTAAAGAATCCNAGTAWBTGACTTGAATTACWTVACAGAAABCAATNAAAC -CGTNTRANTTGAYCMAWBADTANABRGGTKTHTWTAGTTVCTMBKTAGMTVKCCAGCANT -TVAGSWTTAGCCGCRHTTTCCTTHNTATTAAGAAGAATAGGMTRAARTCTABGTACDTTT -TATAAVDHAHTATAGATCCTAGTAAGYTWATDWCATGAGGGATAGTAAMDMNGBASTWAM -TSTATRBAYDABATGTATATYCGCACTGTTTTAACMCWBTATAWAGTATBTSTATVTTAR -CCTMTTAAKADATCAACTAATYTSVTAKGDATTATGCKTCAYCAKAATACTTKAANGAGT -ATTSDAGATCGGAAATACTTAAYAAVGTATMCGCTTGTGTDCTAATYTATTTTATTTWAA -CAGWRCTATGTAGMTGTTTGTTYKTNGTTKTCAGAACNTRACCTACKTGSRATGTGGGGG -CTGTCATTAAGTAAATNGSTTABCCCCTCGCAGCTCWHTCGCGAAGCAVATGCKACGHCA -ACAKTTAATAACASAAADATTWNYTGTAATTGTTCGTMHACHTWATGTGCWTTTTGAAHY -ACTTTGTAYAMSAAACTTAADAAATATAGTABMATATYAATGSGGTAGTTTGTGTBYGGT -TWSGSVGWMATTDMTCCWWCABTCSVACAGBAATGTTKATBGTCAATAATCTTCTTAAAC -ARVAATHAGYBWCTRWCABGTWWAATCTAAGTCASTAAAKTAAGVKBAATTBGABACGTA -AGGTTAAATAAAAACTRMDTWBCTTTTTAATAAAAGATMGCCTACKAKNTBAGYRASTGT -ASSTCGTHCGAAKTTATTATATTYTTTGTAGAACATGTCAAAACTWTWTHGKTCCYAATA -AAGTGGAYTMCYTAARCSTAAATWAKTGAATTTRAGTCTSSATACGACWAKAASATDAAA -TGYYACTSAACAAHAKTSHYARGASTATTATTHAGGYGGASTTTBGAKGATSANAACACD -TRGSTTRAAAAAAAACAAGARTCVTAGTAAGATAWATGVHAAKATWGAAAAGTYAHVTAC -TCTGRTGTCAWGATRVAAKTCGCAAVCGASWGGTTRTCSAMCCTAACASGWKKAWDAATG -ACRCBACTATGTGTCTTCAAAHGSCTATATTTCGTVWAGAAGTAYCKGARAKSGKAGTAN -TTTCYACATWATGTCTAAAADMDTWCAATSTKDACAMAADADBSAAATAGGCTHAHAGTA -CGACVGAATTATAAAGAHCCVAYHGHTTTACATSTTTATGNCCMTAGCATATGATAVAAG ->THREE Homo sapiens frequency -ATATTTATCTTTTCACTTCCTACATTGGTCAGACCATTATTCGACACGTGGCGTCATTTT -GTCATACCGGGTAATGTTGGAAACAAAACGTACTGATAAAATACTGAGTTGTAAACTCTA -ATCAGATAACGCGCTTGGATATTAAGATTCACACAGGGGTTTCGGCTGTAAAAAAACTTG -TGGAGCTGTTCTGGGACAGATAAGTTGTACCTCGTACTTAGCTAATTAATGAACCAACTG -ATTACGATAGAACAATTCTGAGGCCGCCAGGACAGCCAAATTTTAATCTTATAAAGCTGG -AAACAGCCGGTATTAGCTTCTCGCATACTTTGCCTGCATTGGTACCTTACAGATATCAGC -GTAGTCATATACACCTCGGTCTCAGCTAAGCTTGTATCTCTTAGAGTAGTTCAAAGATAG -TGGACAATACCTGTGGAATCGATTGCAGATATGGATTTATTTAACTACTGAGTCTCATTC -ACAAGCTAAGCAAGGAGCACGTTTTGGTGCCGGCATACCGATTTGCTATCATGTCAGCAA -ATTTGCGTTGTATTCCTAGTTGCACCCATTAAGGCCACACTCCGAACCTAATTATTACAT -CGCAAAGACATGTACGAAGGACCCGATGTCGAATAGAAGGGAGGACTGTTCATTGGAAGC -TAGACCAGAGGAATCGCAAAGATGCAACTCTTACAATAAAAATCTAATTTCAGTCAACAC -GCAATTTCTATAAGGTTTCCGATAATAATGAACCGTCTTCCACAGGGGAATTTGCCATGC -TCGTAAAAGTAGTTAATCCAAGTAGAAGAAATTTTGATAATGTTTTAAGTTGGCACGAAG -GAATTCAGAGAGATCTTACCTAACAAAGGCATTAGTAGATGTTCCTTGGTTCACACTCGG -TCAATCAGAGCACATACTACGGGCGATACCGGGAATGACACAACATCAATGAGATTGTTA -AGTGAGGTAATTGACTTTAGAGGACTCGATCAGTATACTGTCACTATGAACATCGTATTA -ATTGTTATCCGATATATACACCACCGATTTGCTTGTGCAAGGTTACAGACCCATTCGATA -AATACAAACACGGAGCGATATTATTTAAGGAGTGCTGTCTTCAAAAGAATTATTCCCACA -CCGACATAAGAACTTCGCTCCGTCATTCCAGATTTAAATAACATAACGTAACGCTTTGCT -GATAACATAACATAACCGAGAATTTGCTTAGGAAATTTGGAGCAATATTGCATTGTTTCT -CAGTCATCACAAGGCCCGCCAAAGAACTCTGAGAATCAGGATTCAACATGATTGGTAAGA -CTCTATATATATAACTTAATTCTTGTGTCCGGAGATAGAAAGAGGACGAGAGATACTACG -AAAGAAAGTGTACTTCGATGTATCAATTCAGACGCCTTCTCTATCATCAACATTATAGGT -CTCGTATATGCTCGGCGCGATCTGCTTCTCTCCGCCAATAGCCCCATAGTGTATTTCAAG -CGCAGTAACAGTGAAATCGTTACGAAGGTAGGGATGTTGCTTATAATTGTCGTAACTTAT -CGCTTATGTATCTTTCAAGAATGAACGGCAGCATATACATACGTTCTACCTTTAGCTACA -AAGCATCCATATACTCCCTCTCATGATTGAAACTCTTCCCTATTTTGTAGCCAATAGTGA -AAGCGTATTAGTATAAATTCGTCGGTTTTTCACTCGCAACTGTTATACTCTGCAAACAAA -CGAAAGCCTCATAGTACAAACCTAAAGCTACATACTTCATCATTGGCAGACCAGTGGCGG -TATTTCTACGGAAGCATCACTATAGATATAAAGTTTCCCTTCATGTACGTCTGTTAACCA -TATCACAAGAAACTGCTATCTCTGTCACGTAACAATTCACGCGCCTTATCGCCAAATGTT -CATATATGCGCGGTATACGTATGAACGAATACTAATTAGTATAACGGAGGATTCACGGGA -GGGATACTTGGGGCATTTATAAATCGTCTAAAAATTTTCTATCAGCACTTGCGGGTTATA -GTGGATTACTAGGCAACATAATATTCTGTATTGGTCCAAATGACGCTATAGATAAATTAG -CAAAATACATTGTTTCCATTTATGTAAGTCGAAACTCCAGGACTCCCGGGAACCAGTTAA -ACCGTCTGGAAAAGACACATTGTGAGCGGGACTTCAATGATAGCTTTCAATGAGCTTCTC -ATGCTTGGGGTCTGTACATATATGTTGGCGAAATTATCGTCTGTATTCTGTTATGCTTTG -ATCATGGGTTATTAGTATAGTGTCCGGTTAAGTACCAATACCGCTAGAGACCCGACCTAA -GTCGATAACTAACGATCATCGACGTAAGGATCGTCTCGATCAGTACTTCAGTCTAGATCT -GGGAATAGTAACTCGTTAGTGAACTATGTCGTGTCATAACTCTAAAATGCAATCAAATCT -TATTATTGAGTATTGATTATATAAAGCATCCGCTTAGCTTTACCCTCAAATGTTATATGC -AATTTAAAGCGCTTGATATCGTCTACTCAAGTTCAGGTTTCACATGGCCGCAACGTGACG -TTATTAGAGGTGGGTCATCATCTCTGAGGCTAGTGATGTTGAATACTCATTGAATGGGAA -GTGGAATACCATGCTCGTAGGTAACAGCATGACCTATAAAATATACTATGGGTGTGTGGT -AGATCAATATTGTTCAAGCATATCGTAACAATAACGGCTGAAATGTTACTGACATGAAAG -AGGGAGTCCAAACCATTCTAACAGCTGATCAAGTCGTCTAAAAACGCCTGGTTCAGCCTT -AAGAGTTATAAGCCAGACAAATTGTATCAATAGAGAATCCGTAAATTCCTCGGCCAACCT -CTTGCAAAGACATCACTATCAATATACTACCGTGATCTTAATTAGTGAACTTATATAAAT -ATCTACAACCAGATTCAACGGAAAAGCTTTAGTGGATTAGAAATTGCCAAGAATCACATT -CATGTGGGTTCGAATGCTTTAGTAATACCATTTCGCCGAGTAGTCACTTCGCTGAACTGT -CGTAAATTGCTATGACATAATCGAAAAGGATTGTCAAGAGTCGATTACTGCGGACTAATA -ATCCCCACGGGGGTGGTCTCATGTCTCCCCAGGCGAGTGGGGACGGTTGATAAACACGCT -GCATCGCGGACTGATGTTCCCAGTATTACATAGTCACATTGGATTGCGAGTAGTCTACCT -ATTTATGAGCGAGAGATGCCTCTAACTACTTCGACTTTTAAAACCTTTCCACGCCAGTAT -TCGGCGAAAGGGAAGTATTAAGGGTTGTCATAATTAAGCTGATACCACTTCAGACTTTGC -TCTACTTCTGTCTTTCATTGGTTTAGTAAAGTCTGTCCATTCGTCGAGACCGTCTTTTGC -AGCCTCATTCTACCAACTGCTCCGACTCTTAGTCTGCTTCTCCCAGCGTTATAACAAGAG -GCATTTTGTCATCCTTAAAACAATAATAAAGAACTCGGAGCACTGATATAATGACTGAAT -TAGAACCGCTTAAAAATACAACGAATAGATAAGACTATCGGATAAGATCTAATATGTAGT -GATTAAGCCCTTTATTAATTAATAATAGTTACCCTTTCTGATGTAACGCGACATATTACG -ATTTAGTGGCACGTCTGAATTGCAAAGCAGATCTCTACCCGATTTTTATTATAAATCCCG -TATACATCTTGACTTGAGTAATTGTTCATCTTTTTATATCTCTTCGTACTACAAATAATT -AATATCTCAACCCGTATTGTGTGATTCTAATTACCAACAGAATACGAGGAGGTTTTTGCT -TAGGGCCATATATAATGAATCTATCTCGTTTATTCGCGGAACCCGAGATAACATTACGAT -GTAACTATTTTAGAGAACTTAATACAAGAAACATTGCTGATTACTCATAACTAAATGCTT -GGTAATATATCCTCAGTGCCCCTACCATCTTTTACGCAGGGATGTAATTACTTAGGATTC -ATTGTGTAAGAATTACAATGAACGATGGATATGAAGGCATGTTGCGAGGTGTTCCTTGGT -ATGTGAAGTTCGCAGGGCAACAAAAATTTCGCAGAATAGGCCTCAAAGTATTGGTAAAGA -AGACAACTAATCATCACGAGCTTCTGATATCAATACGAACGAGTCCTGTGATGGATGAAA -GAAAGTCGTATCGAAAATGTCAAGAGTCTGCCCAATGTAACTTACTTCAAAAAATAACGC -TTCCGCCAAGTACGTTCGAATAAACGTAATTTTAAAAATACATAAGGGGTGTTAGAAAGT -AAGCGACGGGATATAAGTTAGACTCAAGATTCCGCCGTAAAACGAGACTGATTCCGAAGA -TTGTTCGTGGATCTGGTCATGACTTTCACTGAGTAAGGAGTTTCGACATATGTCAATAAA -CACAAAAATAGAAGCTATTCGATCTGAAAAATATTAGGACAAGAAACTATCTCACGCTAG -CCCAGAATATTCACTCACCCACGGGCGATACTAAAGCACTATATAGTCGCGTGATTACTA -TACATATGGTACACATAAGAATCACGATCAGGTTCTCAATTTTCAACAATATATGTTTAT -TTGCATAGGTAATATTAGGCCTTTAAGAGAAGGATGGGTGAGATACTCCGGGGATGGCGG -CAATAAAGAAAAACACGATATGAGTAATAGGATCCTAATATCTTGGCGAGAGACTTAAGG -TACGAATTTTGCGCAATCTATTTTTTACTTGGCCAGAATTCATGTATGGTATAAGTACGA -ACTTTTTTGATCACTTTCATGGCTACCTGATTAGGATAGTTTGAGGAATTTCCCAAATAT -ACCGATTTAATATACACTAGGGCTTGTCACTTTGAGTCAGAAAAAGAATATAATTACTTA -GGGTAATGCTGCATACATATTCTTATATTGCAAAGGTTCTCTGGGTAATCTTGAGCCTTC -ACGATACCTGGTGAAGTGTT diff --git a/gcc/testsuite/go.test/test/bench/shootout/spectral-norm-parallel.go b/gcc/testsuite/go.test/test/bench/shootout/spectral-norm-parallel.go deleted file mode 100644 index 2706f39ec3d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/spectral-norm-parallel.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - * Based on spectral-norm.c by Sebastien Loisel - */ - -package main - -import ( - "flag" - "fmt" - "math" - "runtime" -) - -var n = flag.Int("n", 2000, "count") -var nCPU = flag.Int("ncpu", 4, "number of cpus") - -func evalA(i, j int) float64 { return 1 / float64(((i+j)*(i+j+1)/2 + i + 1)) } - -type Vec []float64 - -func (v Vec) Times(i, n int, u Vec, c chan int) { - for ; i < n; i++ { - v[i] = 0 - for j := 0; j < len(u); j++ { - v[i] += evalA(i, j) * u[j] - } - } - c <- 1 -} - -func (v Vec) TimesTransp(i, n int, u Vec, c chan int) { - for ; i < n; i++ { - v[i] = 0 - for j := 0; j < len(u); j++ { - v[i] += evalA(j, i) * u[j] - } - } - c <- 1 -} - -func wait(c chan int) { - for i := 0; i < *nCPU; i++ { - <-c - } -} - -func (v Vec) ATimesTransp(u Vec) { - x := make(Vec, len(u)) - c := make(chan int, *nCPU) - for i := 0; i < *nCPU; i++ { - go x.Times(i*len(v) / *nCPU, (i+1)*len(v) / *nCPU, u, c) - } - wait(c) - for i := 0; i < *nCPU; i++ { - go v.TimesTransp(i*len(v) / *nCPU, (i+1)*len(v) / *nCPU, x, c) - } - wait(c) -} - -func main() { - flag.Parse() - runtime.GOMAXPROCS(*nCPU) - N := *n - u := make(Vec, N) - for i := 0; i < N; i++ { - u[i] = 1 - } - v := make(Vec, N) - for i := 0; i < 10; i++ { - v.ATimesTransp(u) - u.ATimesTransp(v) - } - var vBv, vv float64 - for i := 0; i < N; i++ { - vBv += u[i] * v[i] - vv += v[i] * v[i] - } - fmt.Printf("%0.9f\n", math.Sqrt(vBv/vv)) -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/spectral-norm.c b/gcc/testsuite/go.test/test/bench/shootout/spectral-norm.c deleted file mode 100644 index 832eb3d2176..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/spectral-norm.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -*- mode: c -*- - * - * The Great Computer Language Shootout - * http://shootout.alioth.debian.org/ - * - * Contributed by Sebastien Loisel - */ - -#include -#include -#include - -double eval_A(int i, int j) { return 1.0/((i+j)*(i+j+1)/2+i+1); } - -void eval_A_times_u(int N, const double u[], double Au[]) -{ - int i,j; - for(i=0;i -#include -#include -#include -#include -#include - -#define THREADS (503) - - -struct stack { - char x[PTHREAD_STACK_MIN]; -}; - - -/* staticaly initialize mutex[0] mutex */ -static pthread_mutex_t mutex[THREADS]; -static int data[THREADS]; -static struct stack stacks[THREADS]; -/* stacks must be defined staticaly, or my i386 box run of virtual memory for this - * process while creating thread +- #400 */ - -static void* thread(void *num) -{ - int l = (int)(uintptr_t)num; - int r = (l+1) % THREADS; - int token; - - while(1) { - pthread_mutex_lock(mutex + l); - token = data[l]; - if (token) { - data[r] = token - 1; - pthread_mutex_unlock(mutex + r); - } - else { - printf("%i\n", l+1); - exit(0); - } - } -} - - - -int main(int argc, char **argv) -{ - int i; - pthread_t cthread; - pthread_attr_t stack_attr; - - if (argc != 2) - exit(255); - data[0] = atoi(argv[1]); - - pthread_attr_init(&stack_attr); - - for (i = 0; i < THREADS; i++) { - pthread_mutex_init(mutex + i, NULL); - pthread_mutex_lock(mutex + i); - - pthread_attr_setstack(&stack_attr, &stacks[i], sizeof(struct stack)); - pthread_create(&cthread, &stack_attr, thread, (void*)(uintptr_t)i); - } - - pthread_mutex_unlock(mutex + 0); - pthread_join(cthread, NULL); -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/threadring.go b/gcc/testsuite/go.test/test/bench/shootout/threadring.go deleted file mode 100644 index e76dd0b452d..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/threadring.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of "The Computer Language Benchmarks Game" nor the - name of "The Computer Language Shootout Benchmarks" nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/* The Computer Language Benchmarks Game - * http://shootout.alioth.debian.org/ - * - * contributed by The Go Authors. - */ - -package main - -import ( - "flag" - "fmt" - "os" -) - -var n = flag.Int("n", 1000, "how many passes") - -const Nthread = 503 - -func f(i int, in <-chan int, out chan<- int) { - for { - n := <-in - if n == 0 { - fmt.Printf("%d\n", i) - os.Exit(0) - } - out <- n - 1 - } -} - -func main() { - flag.Parse() - - one := make(chan int) // will be input to thread 1 - var in, out chan int = nil, one - for i := 1; i <= Nthread-1; i++ { - in, out = out, make(chan int) - go f(i, in, out) - } - go f(Nthread, out, one) - one <- *n - <-make(chan int) // hang until ring completes -} diff --git a/gcc/testsuite/go.test/test/bench/shootout/threadring.txt b/gcc/testsuite/go.test/test/bench/shootout/threadring.txt deleted file mode 100644 index f9aaa4d565f..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/threadring.txt +++ /dev/null @@ -1 +0,0 @@ -498 diff --git a/gcc/testsuite/go.test/test/bench/shootout/timing.log b/gcc/testsuite/go.test/test/bench/shootout/timing.log deleted file mode 100644 index 4e7d17a11b9..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/timing.log +++ /dev/null @@ -1,1254 +0,0 @@ -All tests on r45 or r70 - -Aug 3 2009 - -First version of fasta. Translation of fasta.c, fetched from - http://shootout.alioth.debian.org/u32q/benchmark.php?test=fasta&lang=gpp&id=4 - -fasta -n 25000000 - gcc -O2 fasta.c 5.98u 0.00s 6.01r - gccgo -O2 fasta.go 8.82u 0.02s 8.85r - 6g fasta.go 13.50u 0.02s 13.53r - 6g -B fata.go 12.99u 0.02s 13.02r - -Aug 4 2009 -[added timing.sh] - -# myrandom: -# hand-written optimization of integer division -# use int32->float conversion -fasta -n 25000000 - # probably I/O library inefficiencies - gcc -O2 fasta.c 5.99u 0.00s 6.00r - gccgo -O2 fasta.go 8.82u 0.02s 8.85r - gc fasta 10.70u 0.00s 10.77r - gc_B fasta 10.09u 0.03s 10.12r - -reverse-complement < output-of-fasta-25000000 - # we don't know - memory cache behavior? - gcc -O2 reverse-complement.c 2.04u 0.94s 10.54r - gccgo -O2 reverse-complement.go 6.54u 0.63s 7.17r - gc reverse-complement 6.55u 0.70s 7.26r - gc_B reverse-complement 6.32u 0.70s 7.10r - -nbody 50000000 - # math.Sqrt needs to be in assembly; inlining is probably the other 50% - gcc -O2 nbody.c 21.61u 0.01s 24.80r - gccgo -O2 nbody.go 118.55u 0.02s 120.32r - gc nbody 100.84u 0.00s 100.85r - gc_B nbody 103.33u 0.00s 103.39r -[ -hacked Sqrt in assembler - gc nbody 31.97u 0.00s 32.01r -] - -binary-tree 15 # too slow to use 20 - # memory allocation and garbage collection - gcc -O2 binary-tree.c -lm 0.86u 0.00s 0.87r - gccgo -O2 binary-tree.go 1.69u 0.46s 2.15r - gccgo -O2 binary-tree-freelist.go 8.48u 0.00s 8.48r - gc binary-tree 9.60u 0.01s 9.62r - gc binary-tree-freelist 0.48u 0.01s 0.50r - -August 5, 2009 - -fannkuch 12 - # bounds checking is half the difference - # rest might be registerization - gcc -O2 fannkuch.c 60.09u 0.01s 60.32r - gccgo -O2 fannkuch.go 64.89u 0.00s 64.92r - gc fannkuch 124.59u 0.00s 124.67r - gc_B fannkuch 91.14u 0.00s 91.16r - -regex-dna 100000 - # regexp code is slow on trivial regexp - gcc -O2 regex-dna.c -lpcre 0.92u 0.00s 0.99r - gc regexp-dna 26.94u 0.18s 28.75r - gc_B regexp-dna 26.51u 0.09s 26.75r - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 11.54u 0.00s 11.55r - gccgo -O2 spectral-norm.go 12.20u 0.00s 12.23r - gc spectral-norm 50.23u 0.00s 50.36r - gc_B spectral-norm 49.69u 0.01s 49.83r - gc spectral-norm-parallel 24.47u 0.03s 11.05r # has shift >>1 not div /2 - [using >>1 instead of /2 : gc gives 24.33u 0.00s 24.33r] - -August 6, 2009 - -k-nucleotide 5000000 - # string maps are slower than glib string maps - gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0 k-nucleotide.c: 10.72u 0.01s 10.74r - gccgo -O2 k-nucleotide.go 21.64u 0.83s 22.78r - gc k-nucleotide 16.08u 0.06s 16.50r - gc_B k-nucleotide 17.32u 0.02s 17.37r - -mandelbrot 5500 - # floating point code generator should use more registers - gcc -O2 mandelbrot.c 56.13u 0.02s 56.17r - gccgo -O2 mandelbrot.go 57.49u 0.01s 57.51r - gc mandelbrot 74.32u 0.00s 74.35r - gc_B mandelbrot 74.28u 0.01s 74.31r - -meteor 2100 - # we don't know - gcc -O2 meteor-contest.c 0.10u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.12u 0.00s 0.14r - gc meteor-contest 0.24u 0.00s 0.26r - gc_B meteor-contest 0.23u 0.00s 0.24r - -pidigits 10000 - # bignum is slower than gmp - gcc -O2 pidigits.c -lgmp 2.60u 0.00s 2.62r - gc pidigits 77.69u 0.14s 78.18r - gc_B pidigits 74.26u 0.18s 75.41r - gc_B pidigits 68.48u 0.20s 69.31r # special case: no bounds checking in bignum - -August 7 2009 - -# New gc does better division by powers of 2. Significant improvements: - -spectral-norm 5500 - # floating point code generator should use more registers; possibly inline evalA - gcc -O2 spectral-norm.c -lm 11.50u 0.00s 11.50r - gccgo -O2 spectral-norm.go 12.02u 0.00s 12.02r - gc spectral-norm 23.98u 0.00s 24.00r # new time is 0.48 times old time, 52% faster - gc_B spectral-norm 23.71u 0.01s 23.72r # ditto - gc spectral-norm-parallel 24.04u 0.00s 6.26r # /2 put back. note: 4x faster (on r70, idle) - -k-nucleotide 1000000 - # string maps are slower than glib string maps - gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0 10.82u 0.04s 10.87r - gccgo -O2 k-nucleotide.go 22.73u 0.89s 23.63r - gc k-nucleotide 15.97u 0.03s 16.04r - gc_B k-nucleotide 15.86u 0.06s 15.93r # 8.5% faster, but probably due to weird cache effeccts in previous version - -pidigits 10000 - # bignum is slower than gmp - gcc -O2 pidigits.c -lgmp 2.58u 0.00s 2.58r - gc pidigits 71.24u 0.04s 71.28r # 8.5% faster - gc_B pidigits 71.25u 0.03s 71.29r # 4% faster - -threadring 50000000 - gcc -O2 threadring.c -lpthread 35.51u 160.21s 199.50r - gccgo -O2 threadring.go 90.33u 459.95s 448.03r - gc threadring 33.11u 0.00s 33.14r - GOMAXPROCS=4 gc threadring 114.48u 226.65s 371.59r - # change wait code to do <-make(chan int) instead of time.Sleep - gc threadring 28.41u 0.01s 29.35r - GOMAXPROCS=4 gc threadring 112.59u 232.83s 384.72r - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 18.14u 276.52s 76.93r - gc chameneosredux 20.19u 0.01s 20.23r - -Aug 10 2009 - -# new 6g with better fp registers, fast div and mod of integers -# complete set of timings listed. significant changes marked *** - -fasta -n 25000000 - # probably I/O library inefficiencies - gcc -O2 fasta.c 5.96u 0.00s 5.97r - gc fasta 10.59u 0.01s 10.61r - gc_B fasta 9.92u 0.02s 9.95r - -reverse-complement < output-of-fasta-25000000 - # we don't know - memory cache behavior? - gcc -O2 reverse-complement.c 1.96u 1.56s 16.23r - gccgo -O2 reverse-complement.go 6.41u 0.62s 7.05r - gc reverse-complement 6.46u 0.70s 7.17r - gc_B reverse-complement 6.22u 0.72s 6.95r - -nbody 50000000 - # math.Sqrt needs to be in assembly; inlining is probably the other 50% - gcc -O2 nbody.c 21.26u 0.01s 21.28r - gccgo -O2 nbody.go 116.68u 0.07s 116.80r - gc nbody 86.64u 0.01s 86.68r # -14% - gc_B nbody 85.72u 0.02s 85.77r # *** -17% - -binary-tree 15 # too slow to use 20 - # memory allocation and garbage collection - gcc -O2 binary-tree.c -lm 0.87u 0.00s 0.87r - gccgo -O2 binary-tree.go 1.61u 0.47s 2.09r - gccgo -O2 binary-tree-freelist.go 0.00u 0.00s 0.01r - gc binary-tree 9.11u 0.01s 9.13r # *** -5% - gc binary-tree-freelist 0.47u 0.01s 0.48r - -fannkuch 12 - # bounds checking is half the difference - # rest might be registerization - gcc -O2 fannkuch.c 59.92u 0.00s 59.94r - gccgo -O2 fannkuch.go 65.54u 0.00s 65.58r - gc fannkuch 123.98u 0.01s 124.04r - gc_B fannkuch 90.75u 0.00s 90.78r - -regex-dna 100000 - # regexp code is slow on trivial regexp - gcc -O2 regex-dna.c -lpcre 0.91u 0.00s 0.92r - gc regex-dna 27.25u 0.02s 27.28r - gc_B regex-dna 29.51u 0.03s 29.55r - -spectral-norm 5500 - # possibly inline evalA - gcc -O2 spectral-norm.c -lm 11.57u 0.00s 11.57r - gccgo -O2 spectral-norm.go 12.07u 0.01s 12.08r - gc spectral-norm 23.99u 0.00s 24.00r - gc_B spectral-norm 23.73u 0.00s 23.75r - -k-nucleotide 1000000 - # string maps are slower than glib string maps - gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0 10.63u 0.02s 10.69r - gccgo -O2 k-nucleotide.go 23.19u 0.91s 24.12r - gc k-nucleotide 16.73u 0.04s 16.78r # *** +5% (but this one seems to vary by more than that) - gc_B k-nucleotide 16.46u 0.04s 16.51r # *** +5% - -mandelbrot 16000 - gcc -O2 mandelbrot.c 56.16u 0.00s 56.16r - gccgo -O2 mandelbrot.go 57.41u 0.01s 57.42r - gc mandelbrot 64.05u 0.02s 64.08r # *** -14% - gc_B mandelbrot 64.10u 0.02s 64.14r # *** -14% - -meteor 2100 - # we don't know - gcc -O2 meteor-contest.c 0.10u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.12u 0.00s 0.12r - gc meteor-contest 0.18u 0.00s 0.20r # *** -25% - gc_B meteor-contest 0.17u 0.00s 0.18r # *** -24% - -pidigits 10000 - # bignum is slower than gmp - gcc -O2 pidigits.c -lgmp 2.57u 0.00s 2.57r - gc pidigits 71.82u 0.04s 71.89r - gc_B pidigits 71.84u 0.08s 71.98r - -threadring 50000000 - gcc -O2 threadring.c -lpthread 30.91u 164.33s 204.57r - gccgo -O2 threadring.go 87.12u 460.04s 447.61r - gc threadring 38.55u 0.00s 38.56r # *** +16% - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 17.93u 323.65s 88.47r - gc chameneosredux 21.72u 0.00s 21.73r - -August 10 2009 - -# In-place versions for some bignum operations. -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.56u 0.00s 2.57r - gc pidigits 55.22u 0.04s 55.29r # *** -23% - gc_B pidigits 55.49u 0.02s 55.60r # *** -23% - -September 3 2009 - -# New 6g inlines slices, has a few other tweaks. -# Complete rerun. Significant changes marked. - -fasta -n 25000000 - # probably I/O library inefficiencies - gcc -O2 fasta.c 5.96u 0.00s 5.96r - gc fasta 10.63u 0.02s 10.66r - gc_B fasta 9.92u 0.01s 9.94r - -reverse-complement < output-of-fasta-25000000 - # we don't know - memory cache behavior? - gcc -O2 reverse-complement.c 1.92u 0.33s 2.93r - gccgo -O2 reverse-complement.go 6.76u 0.72s 7.58r # +5% - gc reverse-complement 6.59u 0.70s 7.29r # +2% - gc_B reverse-complement 5.57u 0.80s 6.37r # -10% - -nbody 50000000 - # math.Sqrt needs to be in assembly; inlining is probably the other 50% - # also loop alignment appears to be critical - gcc -O2 nbody.c 21.28u 0.00s 21.28r - gccgo -O2 nbody.go 119.21u 0.00s 119.22r # +2% - gc nbody 109.72u 0.00s 109.78r # + 28% ***** - gc_B nbody 85.90u 0.00s 85.91r - -binary-tree 15 # too slow to use 20 - # memory allocation and garbage collection - gcc -O2 binary-tree.c -lm 0.86u 0.00s 0.87r - gccgo -O2 binary-tree.go 1.88u 0.54s 2.42r # +17% - gccgo -O2 binary-tree-freelist.go 0.01u 0.01s 0.02r - gc binary-tree 8.94u 0.01s 8.96r # -2% - gc binary-tree-freelist 0.47u 0.01s 0.48r - -fannkuch 12 - # bounds checking is half the difference - # rest might be registerization - gcc -O2 fannkuch.c 60.12u 0.00s 60.12r - gccgo -O2 fannkuch.go 92.62u 0.00s 92.66r # +41% *** - gc fannkuch 123.90u 0.00s 123.92r - gc_B fannkuch 89.71u 0.00s 89.74r # -1% - -regex-dna 100000 - # regexp code is slow on trivial regexp - gcc -O2 regex-dna.c -lpcre 0.88u 0.00s 0.88r - gc regex-dna 25.77u 0.01s 25.79r # -5% - gc_B regex-dna 26.05u 0.02s 26.09r # -12% *** - -spectral-norm 5500 - # possibly inline evalA - gcc -O2 spectral-norm.c -lm 11.51u 0.00s 11.51r - gccgo -O2 spectral-norm.go 11.95u 0.00s 11.96r - gc spectral-norm 24.23u 0.00s 24.23r - gc_B spectral-norm 23.83u 0.00s 23.84r - -k-nucleotide 1000000 - # string maps are slower than glib string maps - gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0 10.68u 0.04s 10.72r - gccgo -O2 k-nucleotide.go 23.03u 0.88s 23.92r - gc k-nucleotide 15.79u 0.05s 15.85r # -5% (but this one seems to vary by more than that) - gc_B k-nucleotide 17.88u 0.05s 17.95r # +8% (ditto) - -mandelbrot 16000 - gcc -O2 mandelbrot.c 56.17u 0.02s 56.20r - gccgo -O2 mandelbrot.go 56.74u 0.02s 56.79r # -1% - gc mandelbrot 63.31u 0.01s 63.35r # -1% - gc_B mandelbrot 63.29u 0.00s 63.31r # -1% - -meteor 2100 - # we don't know - gcc -O2 meteor-contest.c 0.10u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.11u 0.00s 0.12r - gc meteor-contest 0.18u 0.00s 0.19r - gc_B meteor-contest 0.17u 0.00s 0.18r - -pidigits 10000 - # bignum is slower than gmp - gcc -O2 pidigits.c -lgmp 2.56u 0.00s 2.57r - gc pidigits 55.87u 0.03s 55.91r - gc_B pidigits 55.93u 0.03s 55.99r - -# these tests are compared using real time, since they run multiple processors -# accuracy probably low -threadring 50000000 - gcc -O2 threadring.c -lpthread 26.31u 164.69s 199.92r # -2% - gccgo -O2 threadring.go 87.90u 487.26s 472.81r # +6% - gc threadring 28.89u 0.00s 28.90r # -25% *** - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 16.41u 296.91s 81.17r # -8% - gc chameneosredux 19.97u 0.00s 19.97r # -8% - -Sep 22, 2009 - -# 6g inlines sliceslice in most cases. - -fasta -n 25000000 - # probably I/O library inefficiencies - gc fasta 10.24u 0.00s 10.25r # -4% - gc_B fasta 9.68u 0.01s 9.69r # -3% - -reverse-complement < output-of-fasta-25000000 - # we don't know - memory cache behavior? - gc reverse-complement 6.67u 0.69s 7.37r # +1% - gc_B reverse-complement 6.00u 0.64s 6.65r # +7% - -nbody -n 50000000 - # math.Sqrt needs to be in assembly; inlining is probably the other 50% - # also loop alignment appears to be critical - gc nbody 86.27u 0.00s 86.29r # -21% - gc_B nbody 104.52u 0.00s 104.54r # +22% - -fannkuch 12 - # bounds checking is half the difference - # rest might be registerization - gc fannkuch 128.36u 0.00s 128.37r # +4% - gc_B fannkuch 89.32u 0.00s 89.34r - -regex-dna 100000 - # regexp code is slow on trivial regexp - gc regex-dna 24.82u 0.01s 24.86r # -4% - gc_B regex-dna 24.55u 0.01s 24.57r # -6% - -spectral-norm 5500 - # possibly inline evalA - gc spectral-norm 24.05u 0.00s 24.07r # -1% - gc_B spectral-norm 23.60u 0.00s 23.65r # -1% - -k-nucleotide 1000000 - # string maps are slower than glib string maps - gc k-nucleotide 17.84u 0.04s 17.89r # +13% but mysterious variation continues - gc_B k-nucleotide 15.56u 0.08s 15.65r # -13% (ditto) - -mandelbrot 16000 - gc mandelbrot 64.08u 0.01s 64.11r # +1% - gc_B mandelbrot 64.04u 0.00s 64.05r # +1% - -pidigits 10000 - # bignum is slower than gmp - gc pidigits 58.68u 0.02s 58.72r # +5% - gc_B pidigits 58.86u 0.05s 58.99r # +5% - -# these tests are compared using real time, since they run multiple processors -# accuracy probably low -threadring 50000000 - gc threadring 32.70u 0.02s 32.77r # +13% - -chameneos 6000000 - gc chameneosredux 26.62u 0.00s 26.63r # +13% - -Sep 24, 2009 - -# Sqrt now in assembler for 6g. -nbody -n 50000000 - # remember, at least for 6g, alignment of loops may be important - gcc -O2 nbody.c 21.24u 0.00s 21.25r - gccgo -O2 nbody.go 121.03u 0.00s 121.04r - gc nbody 30.26u 0.00s 30.27r # -65% *** - gc_B nbody 30.20u 0.02s 30.22r # -72% *** - -Nov 13 2009 - -# fix bug in regexp; take performance hit. good regexps will come in time. -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.92u 0.00s 0.94r - gc regex-dna 29.78u 0.03s 29.83r - gc_B regex-dna 32.63u 0.03s 32.74r - -Nov 24 2009 - -# Roger Peppe's rewrite of the benchmark -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 18.00u 303.29s 83.64r - gc chameneosredux 12.10u 0.00s 12.10r # 2.22X faster - -Jan 6, 2010 - -# Long-overdue update. All numbers included in this complete run. -# Some programs (e.g. reverse-complement) rewritten for speed. -# Regular expressions much faster in common cases (although still far behind PCRE) -# Bignum stuff improved -# Better (but sometimes slower) locking in channels. - -fasta -n 25000000 - gcc -O2 fasta.c 5.99u 0.01s 6.00r - gc fasta 9.11u 0.00s 9.12r # -11% - gc_B fasta 8.60u 0.00s 8.62r # +12% ?? - -reverse-complement < output-of-fasta-25000000 - gcc -O2 reverse-complement.c 2.00u 0.80s 9.54r -# gccgo -O2 reverse-complement.go 4.57u 0.35s 4.94r # 33% faster - gc reverse-complement 2.01u 0.38s 2.40r # 3.3X faster - gc_B reverse-complement 1.88u 0.36s 2.24r # 3.2X faster -GOGC=off - gc reverse-complement 2.01u 0.35s 2.37r - gc_B reverse-complement 1.86u 0.32s 2.19r - -nbody -n 50000000 - gcc -O2 nbody.c 21.28u 0.00s 21.31r - gccgo -O2 nbody.go 80.02u 0.00s 80.05r # 33% faster - gc nbody 30.13u 0.00s 30.13r - gc_B nbody 29.89u 0.01s 29.91r - -binary-tree 15 # too slow to use 20 - gcc -O2 binary-tree.c -lm 0.86u 0.00s 0.87r - gccgo -O2 binary-tree.go 4.82u 0.41s 5.24r # 2.5X slower - gc binary-tree 7.23u 0.01s 7.25r # # -19% - gc binary-tree-freelist 0.43u 0.00s 0.44r # -9% - -fannkuch 12 - gcc -O2 fannkuch.c 60.17u 0.00s 60.17r - gccgo -O2 fannkuch.go 78.47u 0.01s 78.49r - gc fannkuch 128.86u 0.00s 128.96r - gc_B fannkuch 90.17u 0.00s 90.21r - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.90u 0.00s 0.92r - gc regex-dna 9.48u 0.01s 9.50r # 3.1X faster - gc_B regex-dna 9.08u 0.00s 9.10r # 3.6X faster - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 11.48u 0.00s 11.48r - gccgo -O2 spectral-norm.go 11.68u 0.00s 11.70r - gc spectral-norm 23.98u 0.00s 23.99r - gc_B spectral-norm 23.68u 0.00s 23.69r - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c 10.85u 0.04s 10.90r - gccgo -O2 k-nucleotide.go 25.26u 0.87s 26.14r - gc k-nucleotide 15.28u 0.06s 15.37r # restored; mysterious variation continues - gc_B k-nucleotide 15.97u 0.03s 16.00r - -mandelbrot 16000 - gcc -O2 mandelbrot.c 56.12u 0.01s 56.15r - gccgo -O2 mandelbrot.go 56.86u 0.01s 56.89r - gc mandelbrot 66.05u 0.00s 66.07r # -3% - gc_B mandelbrot 66.06u 0.00s 66.07r # -3% - -meteor 2100 - gcc -O2 meteor-contest.c 0.10u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.12u 0.00s 0.12r - gc meteor-contest 0.17u 0.00s 0.17r - gc_B meteor-contest 0.15u 0.00s 0.16r - -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.57u 0.00s 2.59r - gc pidigits 38.27u 0.02s 38.30r # 1.5X faster - gc_B pidigits 38.27u 0.02s 38.31r # 1.5X faster - -threadring 50000000 - gcc -O2 threadring.c 37.11u 170.59s 212.75r - gccgo -O2 threadring.go 89.67u 447.56s 442.55r # -6.5% - gc threadring 36.08u 0.04s 36.15r # +10% - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 19.02u 331.08s 90.79r - gc chameneosredux 12.54u 0.00s 12.55r - -Oct 19, 2010 - -# Another long-overdue update. Some of the code is new; parallel versions -# of some are added. A few significant improvements. - -fasta -n 25000000 - gcc -O2 fasta.c 4.92u 0.00s 4.93r - gccgo -O2 fasta.go 3.31u 0.00s 3.34r # new code - gc fasta 3.68u 0.00s 3.69r # 2.5X faster with no code - gc_B fasta 3.68u 0.00s 3.69r # 2.3X faster with no code - -reverse-complement < output-of-fasta-25000000 - gcc -O2 reverse-complement.c 1.93u 0.81s 11.24r - gccgo -O2 reverse-complement.go 1.58u 0.43s 2.04r # first run with new code? - gc reverse-complement 1.84u 0.34s 2.20r # 10% faster - gc_B reverse-complement 1.85u 0.32s 2.18r - -nbody -n 50000000 - gcc -O2 nbody.c 21.35u 0.00s 21.36r - gccgo -O2 nbody.go 21.62u 0.00s 21.66r # 3.7X faster - why?? - gc nbody 29.78u 0.00s 29.79r - gc_B nbody 29.72u 0.00s 29.72r - -binary-tree 15 # too slow to use 20 - gcc -O2 binary-tree.c -lm 0.86u 0.00s 0.88r - gccgo -O2 binary-tree.go 4.05u 0.02s 4.08r # 28% faster - gccgo -O2 binary-tree-freelist 0.34u 0.08s 0.34r - gc binary-tree 5.94u 0.00s 5.95r # 20% faster - gc binary-tree-freelist 0.50u 0.01s 0.54r - -fannkuch 12 - gcc -O2 fannkuch.c 60.45u 0.00s 60.45r - gccgo -O2 fannkuch.go 64.64u 0.00s 64.64r - gccgo -O2 fannkuch-parallel.go 115.63u 0.00s 31.58r - gc fannkuch 126.52u 0.04s 126.68r - gc fannkuch-parallel 238.82u 0.10s 65.93r # GOMAXPROCS=4 - gc_B fannkuch 88.99u 0.00s 89.02r - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.89u 0.00s 0.89r - gc regex-dna 8.99u 0.02s 9.03r - gc regex-dna-parallel 8.94u 0.02s 3.68r # GOMAXPROCS=4 - gc_B regex-dna 9.12u 0.00s 9.14r - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 11.55u 0.00s 11.57r - gccgo -O2 spectral-norm.go 11.73u 0.00s 11.75r - gc spectral-norm 23.74u 0.00s 23.79r - gc_B spectral-norm 24.49u 0.02s 24.54r - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c 11.44u 0.06s 11.50r - gccgo -O2 k-nucleotide.go 8.65u 0.04s 8.71r - gccgo -O2 k-nucleotide-parallel.go 8.75u 0.03s 2.97r # set GOMAXPROCS=4 - gc k-nucleotide 14.92u 0.05s 15.01r - gc k-nucleotide-parallel 16.96u 0.06s 6.53r # set GOMAXPROCS=4 - gc_B k-nucleotide 15.97u 0.03s 16.08r - -mandelbrot 16000 - gcc -O2 mandelbrot.c 56.32u 0.00s 56.35r - gccgo -O2 mandelbrot.go 55.62u 0.02s 55.77r - gc mandelbrot 64.85u 0.01s 64.94r - gc_B mandelbrot 65.02u 0.01s 65.14r - -meteor 2100 - gcc -O2 meteor-contest.c 0.10u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.10u 0.00s 0.11r - gc meteor-contest 0.17u 0.00s 0.18r - gc_B meteor-contest 0.16u 0.00s 0.16r - -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.58u 0.00s 2.59r - gccgo -O2 pidigits.go 14.06u 0.01s 14.09r # first run? - gc pidigits 8.47u 0.05s 8.55r # 4.5X faster due to package big - gc_B pidigits 8.33u 0.01s 8.36r # 4.5X faster due to package big - -threadring 50000000 - gcc -O2 threadring.c 28.18u 153.19s 186.47r - gccgo -O2 threadring.go 110.10u 516.48s 515.25r - gc threadring 40.39u 0.00s 40.40r - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 18.20u 301.55s 83.10r - gccgo -O2 chameneosredux.go 52.22u 324.54s 201.21r - gc chameneosredux 13.52u 0.00s 13.54r - -Dec 14, 2010 - -# Improved regex code (same algorithm) gets ~30%. - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.77u 0.01s 0.78r - gc regex-dna 6.80u 0.00s 6.81r - gc regex-dna-parallel 6.82u 0.01s 2.75r - gc_B regex-dna 6.69u 0.02s 6.70r - -Feb 15, 2011 - -# Improved GC, still single-threaded but more efficient - -fasta -n 25000000 - gcc -O2 fasta.c 3.40u 0.00s 3.40r - gccgo -O2 fasta.go 3.51u 0.00s 3.50r - gc fasta 3.66u 0.01s 3.66r - gc_B fasta 3.66u 0.00s 3.66r - -reverse-complement < output-of-fasta-25000000 - gcc -O2 reverse-complement.c 1.86u 1.29s 4.93r - gccgo -O2 reverse-complement.go 2.18u 0.41s 2.60r - gc reverse-complement 1.67u 0.48s 2.15r - gc_B reverse-complement 1.71u 0.45s 2.15r - -nbody -n 50000000 - gcc -O2 -lm nbody.c 21.64u 0.00s 21.64r - gccgo -O2 nbody.go 21.46u 0.00s 21.45r - gc nbody 29.07u 0.00s 29.06r - gc_B nbody 31.61u 0.00s 31.61r - -binary-tree 15 # too slow to use 20 - gcc -O2 binary-tree.c -lm 0.88u 0.00s 0.87r - gccgo -O2 binary-tree.go 2.74u 0.07s 2.81r - gccgo -O2 binary-tree-freelist.go 0.01u 0.00s 0.00r - gc binary-tree 4.22u 0.02s 4.24r - gc binary-tree-freelist 0.54u 0.02s 0.55r - -fannkuch 12 - gcc -O2 fannkuch.c 57.64u 0.00s 57.64r - gccgo -O2 fannkuch.go 65.79u 0.00s 65.82r - gccgo -O2 fannkuch-parallel.go 160.91u 0.02s 43.90r - gc fannkuch 126.36u 0.03s 126.53r - gc fannkuch-parallel 175.23u 0.04s 45.49r - gc_B fannkuch 89.23u 0.00s 89.24r - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.77u 0.01s 0.80r - gccgo -O2 regex-dna.go 12.38u 0.10s 12.52r - gccgo -O2 regex-dna-parallel.go 43.96u 4.64s 15.11r - gc regex-dna 7.03u 0.01s 7.05r - gc regex-dna-parallel 6.85u 0.05s 2.70r - gc_B regex-dna 6.87u 0.02s 6.89r - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 12.29u 0.00s 12.28r - gccgo -O2 spectral-norm.go 11.79u 0.00s 11.79r - gc spectral-norm 24.00u 0.02s 24.05r - gc_B spectral-norm 24.59u 0.01s 24.59r - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c 9.75u 0.07s 9.82r - gccgo -O2 k-nucleotide.go 8.92u 0.06s 8.98r - gccgo -O2 k-nucleotide-parallel.go 8.40u 0.04s 2.76r - gc k-nucleotide 17.01u 0.03s 17.04r - gc k-nucleotide-parallel 16.51u 0.08s 6.21r - gc_B k-nucleotide 16.94u 0.08s 17.02r - -mandelbrot 16000 - gcc -O2 mandelbrot.c 54.60u 0.00s 54.66r - gccgo -O2 mandelbrot.go 59.38u 0.00s 59.41r - gc mandelbrot 64.93u 0.04s 65.08r - gc_B mandelbrot 64.85u 0.03s 64.92r - -meteor 2098 - gcc -O2 meteor-contest.c 0.10u 0.01s 0.10r - gccgo -O2 meteor-contest.go 0.11u 0.00s 0.11r - gc meteor-contest 0.18u 0.00s 0.17r - gc_B meteor-contest 0.17u 0.00s 0.16r - -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.24u 0.00s 2.23r - gccgo -O2 pidigits.go 14.05u 0.00s 14.06r - gc pidigits 6.34u 0.05s 6.38r - gc_B pidigits 6.37u 0.02s 6.38r - -threadring 50000000 - gcc -O2 threadring.c 30.50u 258.05s 325.72r - gccgo -O2 threadring.go 92.87u 748.39s 728.46r - gc threadring 38.03u 0.01s 38.04r - -# Apr 15, 2011 -# Move to new machine, Intel Xeon E5520@2.27GHz. -# (Was Opteron(tm) Processor 8214 HE) - -fasta -n 25000000 -OLD: - gcc -O2 fasta.c 3.39u 0.04s 3.42r - gccgo -O2 fasta.go 3.52u 0.00s 3.52r - gc fasta 3.63u 0.04s 3.67r - gc_B fasta 3.66u 0.00s 3.66r -NEW: - gcc -O2 fasta.c 1.45u 0.02s 1.47r - gccgo -O2 fasta.go 1.51u 0.01s 1.51r - gc fasta 2.04u 0.00s 2.04r - gc_B fasta 2.05u 0.00s 2.04r - -reverse-complement < output-of-fasta-25000000 -OLD: - gcc -O2 reverse-complement.c 1.87u 1.51s 7.02r - gccgo -O2 reverse-complement.go 1.56u 0.54s 3.37r - gc reverse-complement 1.73u 0.36s 2.08r - gc_B reverse-complement 1.75u 0.37s 2.12r -NEW: - gcc -O2 reverse-complement.c 1.20u 0.47s 12.96r - gccgo -O2 reverse-complement.go 0.88u 0.14s 1.01r - gc reverse-complement 1.13u 0.17s 1.30r - gc_B reverse-complement 1.11u 0.09s 1.20r - -nbody -n 50000000 -OLD: - gcc -O2 -lm nbody.c 21.90u 0.00s 21.92r - gccgo -O2 nbody.go 23.12u 0.03s 23.19r - gc nbody 29.07u 0.00s 29.07r - gc_B nbody 31.84u 0.00s 31.85r -NEW: - gcc -O2 -lm nbody.c 13.01u 0.00s 13.03r - gccgo -O2 nbody.go 13.35u 0.00s 13.37r - gc nbody 21.78u 0.00s 21.82r - gc_B nbody 21.72u 0.00s 21.76r - -binary-tree 15 # too slow to use 20 -OLD: - gcc -O2 binary-tree.c -lm 0.83u 0.02s 0.84r - gccgo -O2 binary-tree.go 2.61u 0.02s 2.62r - gccgo -O2 binary-tree-freelist.go 0.32u 0.01s 0.32r - gc binary-tree 3.93u 0.04s 3.97r - gc binary-tree-freelist 0.47u 0.03s 0.50r -NEW: - gcc -O2 binary-tree.c -lm 0.60u 0.00s 0.59r - gccgo -O2 binary-tree.go 1.53u 0.00s 1.52r - gccgo -O2 binary-tree-freelist.go 0.01u 0.00s 0.00r - gc binary-tree 1.93u 0.02s 1.95r - gc binary-tree-freelist 0.32u 0.01s 0.32r - -fannkuch 12 -OLD: - gcc -O2 fannkuch.c 57.64u 0.00s 57.64r - gccgo -O2 fannkuch.go 65.56u 0.01s 65.65r - gccgo -O2 fannkuch-parallel.go 179.12u 0.00s 49.82r - gc fannkuch 126.39u 0.00s 126.39r - gc fannkuch-parallel 172.49u 0.02s 45.44r - gc_B fannkuch 89.30u 0.00s 89.28r -NEW: - gcc -O2 fannkuch.c 45.17u 0.00s 45.26r - gccgo -O2 fannkuch.go 53.63u 0.00s 53.73r - gccgo -O2 fannkuch-parallel.go 216.72u 0.00s 58.42r - gc fannkuch 108.21u 0.00s 108.44r - gc fannkuch-parallel 227.20u 0.00s 57.27r - gc_B fannkuch 56.14u 0.00s 56.26r - -regex-dna 100000 -OLD: - gcc -O2 regex-dna.c -lpcre 0.77u 0.01s 0.78r - gccgo -O2 regex-dna.go 10.15u 0.02s 10.23r - gccgo -O2 regex-dna-parallel.go 33.81u 3.22s 11.62r - gc regex-dna 6.52u 0.04s 6.56r - gc regex-dna-parallel 6.84u 0.03s 2.70r - gc_B regex-dna 6.83u 0.01s 6.84r -NEW: - gcc -O2 regex-dna.c -lpcre 0.47u 0.00s 0.47r - gccgo -O2 regex-dna.go 6.00u 0.00s 6.00r - gccgo -O2 regex-dna-parallel.go 44.54u 1.57s 6.51r - gc regex-dna 5.41u 0.01s 5.42r - gc regex-dna-parallel 5.62u 0.01s 2.20r - gc_B regex-dna 5.50u 0.00s 5.50r - -spectral-norm 5500 -OLD: - gcc -O2 spectral-norm.c -lm 12.29u 0.00s 12.28r - gccgo -O2 spectral-norm.go 11.56u 0.00s 11.55r - gc spectral-norm 23.98u 0.00s 24.00r - gc_B spectral-norm 24.62u 0.00s 24.65r -NEW: - gcc -O2 spectral-norm.c -lm 15.79u 0.00s 15.82r - gccgo -O2 spectral-norm.go 15.32u 0.00s 15.35r - gc spectral-norm 19.62u 0.01s 19.67r - gc_B spectral-norm 19.62u 0.00s 19.66r - -k-nucleotide 1000000 -OLD: - gcc -O2 k-nucleotide.c 9.82u 0.06s 9.87r - gccgo -O2 k-nucleotide.go 8.30u 0.02s 8.32r - gccgo -O2 k-nucleotide-parallel.go 8.84u 0.05s 3.02r - gc k-nucleotide 15.38u 0.07s 15.44r - gc k-nucleotide-parallel 16.40u 0.03s 5.93r - gc_B k-nucleotide 15.19u 0.05s 15.23r -NEW: - gcc -O2 -k-nucleotide.c 4.88u 0.03s 4.92r - gccgo -O2 k-nucleotide.go 5.94u 0.01s 5.96r - gccgo -O2 k-nucleotide-parallel.go 6.44u 0.03s 1.47r - gc k-nucleotide 9.61u 0.01s 9.63r - gc k-nucleotide-parallel 9.70u 0.00s 3.39r - gc_B k-nucleotide 9.19u 0.03s 9.23r - -mandelbrot 16000 -OLD: - gcc -O2 mandelbrot.c 54.54u 0.00s 54.56r - gccgo -O2 mandelbrot.go 59.63u 0.03s 59.67r - gc mandelbrot 64.82u 0.00s 64.83r - gc_B mandelbrot 64.84u 0.00s 64.91r -NEW: - gcc -O2 mandelbrot.c 36.07u 0.01s 36.15r - gccgo -O2 mandelbrot.go 43.57u 0.00s 43.66r - gc mandelbrot 60.66u 0.00s 60.79r - gc_B mandelbrot 60.90u 0.00s 61.03r - -meteor 2098 -OLD: - gcc -O2 meteor-contest.c 0.11u 0.00s 0.10r - gccgo -O2 meteor-contest.go 0.10u 0.01s 0.10r - gc meteor-contest 0.18u 0.00s 0.17r - gc_B meteor-contest 0.17u 0.00s 0.16r -NEW: - gcc -O2 meteor-contest.c 0.10u 0.00s 0.09r - gccgo -O2 meteor-contest.go 0.10u 0.00s 0.09r - gc meteor-contest 0.14u 0.00s 0.14r - gc_B meteor-contest 0.13u 0.00s 0.13r - -pidigits 10000 -OLD: - gcc -O2 pidigits.c -lgmp 2.22u 0.00s 2.21r - gccgo -O2 pidigits.go 13.39u 0.00s 13.40r - gc pidigits 6.42u 0.04s 6.45r - gc_B pidigits 6.45u 0.02s 6.47r -NEW: - gcc -O2 pidigits.c -lgmp 2.27u 0.00s 2.29r - gccgo -O2 pidigits.go 9.21u 0.00s 9.22r - gc pidigits 3.60u 0.00s 3.60r - gc_B pidigits 3.56u 0.02s 3.58r - -threadring 50000000 -OLD: - gcc -O2 threadring.c -lpthread 34.51u 267.95s 336.12r - gccgo -O2 threadring.go 103.51u 588.57s 627.16r - gc threadring 54.68u 0.00s 54.73r -NEW: - gcc -O2 threadring.c 32.00u 259.39s 369.74r - gccgo -O2 threadring.go 133.06u 546.02s 595.33r - gc threadring 16.75u 0.02s 16.80r - -chameneos 6000000 -OLD: - gcc -O2 chameneosredux.c -lpthread 12.65u 31.02s 13.33r - gccgo -O2 chameneosredux.go 47.04u 302.84s 252.29r - gc chameneosredux 14.14u 0.00s 14.14r -NEW: - gcc -O2 chameneosredux.c -lpthread 8.05u 63.43s 11.16r - gccgo -O2 chameneosredux.go 82.95u 304.37s 207.64r - gc chameneosredux 9.42u 0.00s 9.43r - -# May 13, 2011 -# after gc update to inline append when possible - 35% faster - -regex-dna 100000 - gc regex-dna 3.94u 0.00s 3.95r - gc regex-dna-parallel 4.15u 0.01s 1.63r - gc_B regex-dna 4.01u 0.01s 4.02r - -# Aug 4, 2011 -# After various updates to locking code and some runtime changes. -# Slowdowns believed due to slower (but more correct) memmove. - -fannkuch 12 - gccgo -O2 fannkuch.go 51.59u 0.00s 51.69r # -4% - gccgo -O2 fannkuch-parallel.go 253.17u 0.00s 64.67r # -11% - gc fannkuch 103.14u 0.00s 103.36r # -5% - gc fannkuch-parallel 189.63u 0.00s 49.37r # +9% - gc_B fannkuch 49.19u 0.00s 49.29r # -14% - -regex-dna 100000 - gc regex-dna 3.78u 0.00s 3.78r # -43% - gc regex-dna-parallel 3.84u 0.02s 1.48r # -49% - gc_B regex-dna 3.62u 0.00s 3.63r # -52% - -k-nucleotide 1000000 - gc k-nucleotide 12.23u 0.02s 12.27r # +27% - gc k-nucleotide-parallel 12.76u 0.02s 4.37r # +29% - gc_B k-nucleotide 12.18u 0.01s 12.21r # +33% - -threadring 50000000 - gc threadring 17.49u 0.00s 17.53r # +4% - -chameneos 6000000 - gc chameneosredux 7.61u 0.00s 7.63r # -24% - -Aug 9, 2011 -# After custom algorithms for 1- 2- 4- 8-byte scalars. - -fannkuch 12 - gc fannkuch-parallel 157.17u 0.00s 41.08r # -17% - -k-nucleotide 1000000 - gc k-nucleotide 8.72u 0.03s 8.76r # -39% - gc k-nucleotide-parallel 8.79u 0.01s 3.14r # -39% - gc_B k-nucleotide 8.65u 0.03s 8.69r # -39% - -pidigits 10000 - gc pidigits 3.71u 0.02s 3.73r # +4% - gc_B pidigits 3.73u 0.00s 3.73r # +4% - -threadring 50000000 - gc threadring 14.51u 0.00s 14.54r # -17% - -chameneos 6000000 - gc chameneosredux 7.41u 0.00s 7.42r # -3% - -# A complete run at the Go 1 release. -# Significant changes: -# - gccgo is now enabled for all tests (goroutines are cheap enough) -# - threadring and chameneos are 14% faster, probably due to runtime changes -# - regex-dna 36% faster -# - fannkuch-parallel (only) slowed down 40% -# - gccgo on binary-tree-freelist is still optimized to nothing -# Other changes are modest. - -fasta -n 25000000 - gcc -O2 fasta.c 1.45u 0.02s 1.48r - gccgo -O2 fasta.go 1.46u 0.00s 1.47r - gc fasta 1.99u 0.01s 2.00r - gc_B fasta 1.99u 0.01s 2.01r - -reverse-complement < output-of-fasta-25000000 - gcc -O2 reverse-complement.c 0.95u 0.48s 4.99r - gccgo -O2 reverse-complement.go 0.93u 0.16s 1.09r - gc reverse-complement 1.20u 0.19s 1.39r - gc_B reverse-complement 1.04u 0.16s 1.20r - -nbody -n 50000000 - gcc -O2 -lm nbody.c 13.02u 0.00s 13.05r - gccgo -O2 nbody.go 14.46u 0.00s 14.49r - gc nbody 21.79u 0.00s 21.84r - gc_B nbody 21.74u 0.00s 21.79r - -binary-tree 15 # too slow to use 20 - gcc -O2 binary-tree.c -lm 0.60u 0.01s 0.61r - gccgo -O2 binary-tree.go 1.30u 0.01s 1.32r - gccgo -O2 binary-tree-freelist.go 0.00u 0.00s 0.00r - gc binary-tree 1.84u 0.01s 1.86r - gc binary-tree-freelist 0.33u 0.00s 0.33r - -fannkuch 12 - gcc -O2 fannkuch.c 45.24u 0.00s 45.34r - gccgo -O2 fannkuch.go 59.76u 0.01s 59.90r - gccgo -O2 fannkuch-parallel.go 218.20u 0.01s 61.60r - gc fannkuch 103.92u 0.00s 104.16r - gc fannkuch-parallel 221.61u 0.00s 60.49r - gc_B fannkuch 53.17u 0.00s 53.30r - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.47u 0.00s 0.48r - gccgo -O2 regex-dna.go 6.52u 0.00s 6.54r - gccgo -O2 regex-dna-parallel.go 14.40u 0.73s 4.35r - gc regex-dna 2.63u 0.02s 2.66r # -36% - gc regex-dna-parallel 2.87u 0.01s 1.11r - gc_B regex-dna 2.65u 0.00s 2.66r - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 15.78u 0.00s 15.82r - gccgo -O2 spectral-norm.go 15.79u 0.00s 15.83r - gc spectral-norm 19.76u 0.00s 19.80r - gc_B spectral-norm 19.73u 0.01s 19.78r - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c 5.59u 0.03s 5.63r - gccgo -O2 k-nucleotide.go 4.09u 0.03s 4.13r - gccgo -O2 k-nucleotide-parallel.go 4.50u 0.06s 1.63r - gc k-nucleotide 9.23u 0.02s 9.27r - gc k-nucleotide-parallel 9.87u 0.03s 3.55r - gc_B k-nucleotide 9.20u 0.00s 9.22r - -mandelbrot 16000 - gcc -O2 mandelbrot.c 36.09u 0.00s 36.18r - gccgo -O2 mandelbrot.go 41.69u 0.01s 41.80r - gc mandelbrot 60.91u 0.02s 61.07r - gc_B mandelbrot 60.90u 0.00s 61.04r - -meteor 2098 - gcc -O2 meteor-contest.c 0.09u 0.00s 0.09r - gccgo -O2 meteor-contest.go 0.09u 0.00s 0.09r - gc meteor-contest 0.14u 0.00s 0.15r - gc_B meteor-contest 0.14u 0.00s 0.14r - -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.27u 0.00s 2.27r - gccgo -O2 pidigits.go 8.65u 0.00s 8.67r - gc pidigits 3.70u 0.04s 3.75r - gc_B pidigits 3.72u 0.02s 3.75r - -threadring 50000000 - gcc -O2 threadring.c 40.91u 369.85s 323.31r - gccgo -O2 threadring.go 26.97u 30.82s 57.93r - gc threadring 12.81u 0.01s 12.85r # -13% - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 9.44u 72.90s 12.65r - gccgo -O2 chameneosredux.go 7.73u 7.53s 15.30r - gc chameneosredux 6.51u 0.00s 6.53r # - 14% - -# After http://codereview.appspot.com/6248049, moving panicindex -# calls out of line (putting the likely code into a single path and shortening -# loops). Significant changes since the last run (note: some are slower for -# unrelated and as yet undiagnosed reasons): - -nbody -n 50000000 - gc nbody 19.10u 0.01s 19.19r # -12% - gc_B nbody 19.19u 0.00s 19.23r # -12% - -binary-tree 15 # too slow to use 20 - gc binary-tree 1.49u 0.01s 1.51r # -19% - -fannkuch 12 - gc fannkuch 60.79u 0.00s 60.92r # -41% - gc fannkuch-parallel 183.51u 0.01s 51.75r # -14% - gc_B fannkuch 51.68u 0.00s 51.79r # -3% - -k-nucleotide 1000000 - gc k-nucleotide 9.74u 0.04s 9.80r # +6% - gc k-nucleotide-parallel 9.89u 0.05s 3.59r # +1% - gc_B k-nucleotide 9.39u 0.02s 9.43r # +2% - -mandelbrot (much slower, due to unrelated http://codereview.appspot.com/6209077) - gc mandelbrot 100.98u 0.00s 101.20r # +65% - gc_B mandelbrot 100.90u 0.01s 101.17r # +65% - -meteor 2098 - gc meteor-contest 0.13u 0.00s 0.13r # -13% - gc_B meteor-contest 0.13u 0.00s 0.13r # -7% - -# May 30, 2012. -# After http://codereview.appspot.com/6261051, restoring old code generated -# for floating-point constants. Mandelbrot is back to its previous numbers. - -mandelbrot 16000 - gcc -O2 mandelbrot.c 36.07u 0.00s 36.16r - gccgo -O2 mandelbrot.go 41.72u 0.01s 41.90r - gc mandelbrot 60.62u 0.00s 60.76r - gc_B mandelbrot 60.68u 0.00s 60.82r - -# May 30, 2012. -# After http://codereview.appspot.com/6248068, better FP code -# by avoiding MOVSD between registers. -# Plus some other timing changes that have crept in from other speedups, -# from garbage collection to Printf. - -fasta -n 25000000 - gc fasta 1.76u 0.00s 1.76r # -12% - gc_B fasta 1.71u 0.00s 1.72r # -12% - -nbody -n 50000000 - gc nbody 17.56u 0.00s 17.60r # -8% - gc_B nbody 17.30u 0.00s 17.34r # -10% - -fannkuch 12 - gc fannkuch-parallel 155.92u 0.01s 44.05r # -15% - -k-nucleotide 1000000 - gc k-nucleotide 9.22u 0.01s 9.26r # -5% - gc k-nucleotide-parallel 9.23u 0.03s 3.26r # -9% - gc_B k-nucleotide 9.22u 0.03s 9.28r # -2% - -mandelbrot 16000 - gc mandelbrot 44.80u 0.00s 44.90r # -27% - gc_B mandelbrot 44.81u 0.00s 44.92r # -26% - -pidigits 10000 - gc pidigits 3.51u 0.00s 3.52r # -6% - gc_B pidigits 3.51u 0.00s 3.52r # -6% - -# Aug 28, 2012 -# After some assembler work in package big. -pidigits 10000 - gc pidigits 2.85u 0.02s 2.88r # -22% - gc_B pidigits 2.88u 0.01s 2.90r # -21% - -# Sep 26, 2012 -# 64-bit ints, plus significantly better floating-point code. -# Interesting details: -# Generally something in the 0-10% slower range, some (binary tree) more -# Floating-point noticeably faster: -# nbody -25% -# mandelbrot -37% relative to Go 1. -# Other: -# regex-dna +47% -fasta -n 25000000 - gcc -O2 fasta.c 1.43u 0.03s 1.46r - gccgo -O2 fasta.go 1.47u 0.00s 1.47r - gc fasta 1.78u 0.01s 1.80r - gc_B fasta 1.76u 0.00s 1.76r - -reverse-complement < output-of-fasta-25000000 - gcc -O2 reverse-complement.c 1.14u 0.39s 11.19r - gccgo -O2 reverse-complement.go 0.91u 0.17s 1.09r - gc reverse-complement 1.12u 0.18s 1.31r - gc_B reverse-complement 1.12u 0.15s 1.28r - -nbody -n 50000000 - gcc -O2 nbody.c -lm 13.02u 0.00s 13.05r - gccgo -O2 nbody.go 13.90u 0.00s 13.93r - gc nbody 17.05u 0.00s 17.09r - gc_B nbody 16.30u 0.00s 16.34r - -binary-tree 15 # too slow to use 20 - gcc -O2 binary-tree.c -lm 0.61u 0.00s 0.61r - gccgo -O2 binary-tree.go 1.24u 0.04s 1.29r - gccgo -O2 binary-tree-freelist.go 0.21u 0.01s 0.22r - gc binary-tree 1.93u 0.02s 1.96r - gc binary-tree-freelist 0.32u 0.00s 0.33r - -fannkuch 12 - gcc -O2 fannkuch.c 45.19u 0.00s 45.29r - gccgo -O2 fannkuch.go 60.32u 0.00s 60.45r - gccgo -O2 fannkuch-parallel.go 185.59u 0.00s 59.49r - gc fannkuch 72.14u 0.00s 72.30r - gc fannkuch-parallel 172.54u 0.00s 43.59r - gc_B fannkuch 53.55u 0.00s 53.67r - -regex-dna 100000 - gcc -O2 regex-dna.c -lpcre 0.47u 0.00s 0.47r - gccgo -O2 regex-dna.go 6.49u 0.05s 6.56r - gccgo -O2 regex-dna-parallel.go 14.60u 0.67s 4.42r - gc regex-dna 3.91u 0.00s 3.92r - gc regex-dna-parallel 4.01u 0.03s 1.56r - gc_B regex-dna 3.91u 0.00s 3.92r - -spectral-norm 5500 - gcc -O2 spectral-norm.c -lm 15.85u 0.00s 15.89r - gccgo -O2 spectral-norm.go 15.86u 0.00s 15.89r - gc spectral-norm 19.72u 0.00s 19.76r - gc_B spectral-norm 19.68u 0.01s 19.74r - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 4.90u 0.01s 4.93r - gccgo -O2 k-nucleotide.go 4.78u 0.01s 4.80r - gccgo -O2 k-nucleotide-parallel.go 6.49u 0.02s 2.18r - gc k-nucleotide 9.05u 0.02s 9.09r - gc k-nucleotide-parallel 9.27u 0.01s 3.29r - gc_B k-nucleotide 8.95u 0.03s 9.00r - -mandelbrot 16000 - gcc -O2 mandelbrot.c 36.11u 0.00s 36.19r - gccgo -O2 mandelbrot.go 43.67u 0.00s 43.77r - gc mandelbrot 38.57u 0.00s 38.66r - gc_B mandelbrot 38.59u 0.00s 38.68r - -meteor 2098 - gcc -O2 meteor-contest.c 0.09u 0.00s 0.09r - gccgo -O2 meteor-contest.go 0.09u 0.00s 0.09r - gc meteor-contest 0.13u 0.00s 0.14r - gc_B meteor-contest 0.12u 0.00s 0.13r - -pidigits 10000 - gcc -O2 pidigits.c -lgmp 2.26u 0.00s 2.27r - gccgo -O2 pidigits.go 9.05u 0.00s 9.07r - gc pidigits 2.88u 0.02s 2.90r - gc_B pidigits 2.89u 0.00s 2.90r - -threadring 50000000 - gcc -O2 threadring.c -lpthread 37.30u 327.81s 289.28r - gccgo -O2 threadring.go 42.83u 26.15s 69.14r - gc threadring 13.00u 0.00s 13.03r - -chameneos 6000000 - gcc -O2 chameneosredux.c -lpthread 8.80u 71.67s 12.19r - gccgo -O2 chameneosredux.go 11.28u 6.68s 18.00r - gc chameneosredux 6.94u 0.00s 6.96r - -# May 23, 2013 -# Go 1.1, which includes precise GC, new scheduler, faster maps. -# 20%-ish speedups across many benchmarks. -# gccgo showing significant improvement (even though it's not yet up to Go 1.1) -# -# Standouts: -# fannkuch, regex-dna, k-nucleotide, threadring, chameneos - -fasta -n 25000000 - gcc -m64 -O2 fasta.c 1.54u 0.01s 1.55r - gccgo -O2 fasta.go 1.42u 0.00s 1.43r - gc fasta 1.50u 0.01s 1.52r # -16% - gc_B fasta 1.46u 0.00s 1.46r # -17% - -reverse-complement < output-of-fasta-25000000 - gcc -m64 -O2 reverse-complement.c 0.87u 0.37s 4.36r - gccgo -O2 reverse-complement.go 0.77u 0.15s 0.93r # -15% - gc reverse-complement 0.99u 0.12s 1.12r # -15% - gc_B reverse-complement 0.85u 0.17s 1.02r # -21% - -nbody -n 50000000 - gcc -m64 -O2 nbody.c -lm 13.50u 0.00s 13.53r - gccgo -O2 nbody.go 13.98u 0.01s 14.02r - gc nbody 16.63u 0.01s 16.67r - gc_B nbody 15.74u 0.00s 15.76r - -binary-tree 15 # too slow to use 20 - gcc -m64 -O2 binary-tree.c -lm 0.61u 0.00s 0.61r - gccgo -O2 binary-tree.go 1.11u 0.01s 1.12r # -13% - gccgo -O2 binary-tree-freelist.go 0.22u 0.01s 0.23r - gc binary-tree 1.83u 0.02s 1.83r # -7% - gc binary-tree-freelist 0.32u 0.00s 0.32r - -fannkuch 12 - gcc -m64 -O2 fannkuch.c 45.56u 0.00s 45.67r - gccgo -O2 fannkuch.go 57.71u 0.00s 57.85r # -4% - gccgo -O2 fannkuch-parallel.go 146.31u 0.00s 37.50r #-37% - gc fannkuch 70.06u 0.03s 70.17r # -3% - gc fannkuch-parallel 131.88u 0.06s 33.59r # -23% - gc_B fannkuch 45.55u 0.02s 45.63r # -15% - -regex-dna 100000 - gcc -m64 -O2 regex-dna.c -lpcre 0.44u 0.01s 0.45r - gccgo -O2 regex-dna.go 5.59u 0.00s 5.61r # -14% - gccgo -O2 regex-dna-parallel.go 10.85u 0.30s 3.34r # -24% - gc regex-dna 2.23u 0.01s 2.25r # -43% - gc regex-dna-parallel 2.35u 0.00s 0.93r # -40% - gc_B regex-dna 2.24u 0.01s 2.25r # -43% - -spectral-norm 5500 - gcc -m64 -O2 spectral-norm.c -lm 14.84u 0.00s 14.88r - gccgo -O2 spectral-norm.go 15.33u 0.00s 15.37r - gc spectral-norm 16.75u 0.02s 16.79r # -15% - gc_B spectral-norm 16.77u 0.01s 16.79r # -15% - -k-nucleotide 1000000 - gcc -O2 k-nucleotide.c -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lglib-2.0 4.50u 0.00s 4.52r - gccgo -O2 k-nucleotide.go 3.72u 0.04s 3.77r # -21% - gccgo -O2 k-nucleotide-parallel.go 3.88u 0.03s 1.42r # -35% - gc k-nucleotide 6.32u 0.01s 6.33r # -31% - gc k-nucleotide-parallel 6.47u 0.05s 2.13r # -33% - gc_B k-nucleotide 6.45u 0.01s 6.47r # - 28% - -mandelbrot 16000 - gcc -m64 -O2 mandelbrot.c 36.03u 0.00s 36.11r - gccgo -O2 mandelbrot.go 37.61u 0.00s 37.74r # -14% - gc mandelbrot 38.19u 0.05s 38.29r - gc_B mandelbrot 38.19u 0.03s 38.26r - -meteor 2098 - gcc -m64 -O2 meteor-contest.c 0.08u 0.00s 0.08r - gccgo -O2 meteor-contest.go 0.09u 0.01s 0.10r - gc meteor-contest 0.12u 0.00s 0.12r # -15% although perhaps just noise - gc_B meteor-contest 0.11u 0.00s 0.12r # -8% although perhaps just noise - -pidigits 10000 - gcc -m64 -O2 pidigits.c -lgmp 2.27u 0.00s 2.28r - gccgo -O2 pidigits.go 8.95u 0.02s 8.99r - gc pidigits 2.88u 0.14s 2.91r - gc_B pidigits 2.92u 0.10s 2.91r - -threadring 50000000 - gcc -m64 -O2 threadring.c -lpthread 14.75u 167.88s 212.23r - gccgo -O2 threadring.go 36.72u 12.08s 48.91r # -29% - gc threadring 10.93u 0.01s 10.95r # -16% - -chameneos 6000000 - gcc -m64 -O2 chameneosredux.c -lpthread 8.89u 56.62s 9.75r - gccgo -O2 chameneosredux.go 9.48u 2.48s 11.99r # -33% - gc chameneosredux 5.80u 0.00s 5.81r # -16% - diff --git a/gcc/testsuite/go.test/test/bench/shootout/timing.sh b/gcc/testsuite/go.test/test/bench/shootout/timing.sh deleted file mode 100755 index 2db895c2630..00000000000 --- a/gcc/testsuite/go.test/test/bench/shootout/timing.sh +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2009 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. - -set -e - -eval $(go tool dist env) -O=$GOCHAR -GC="go tool ${O}g" -LD="go tool ${O}l" - -gccm="" -case "$O" in -8) - gccm=-m32;; -6) - gccm=-m64;; -esac - -PATH=.:$PATH - -havegccgo=false -if which gccgo >/dev/null 2>&1 -then - havegccgo=true -fi - -mode=run -case X"$1" in -X-test) - mode=test - shift -esac - -gc() { - $GC $1.go; $LD $1.$O -} - -gc_B() { - $GC -B $1.go; $LD $1.$O -} - -runonly() { - if [ $mode = run ] - then - "$@" - fi -} - -run() { - if [ $mode = test ] - then - if echo $1 | grep -q '^gc ' - then - $1 # compile the program - program=$(echo $1 | sed 's/gc //') - shift - echo $program - $1 /tmp/$$ - case $program in - chameneosredux) - # exact numbers may vary but non-numbers should match - grep -v '[0-9]' /tmp/$$ > /tmp/$$x - grep -v '[0-9]' chameneosredux.txt > /tmp/$$y - cmp /tmp/$$x /tmp/$$y - rm -f /tmp/$$ /tmp/$$x /tmp/$$y - ;; - *) - cmp /tmp/$$ $program.txt - rm -f /tmp/$$ - esac - fi - return - fi - if ! $havegccgo && echo $1 | grep -q '^gccgo ' - then - return - fi - echo -n ' '$1' ' - $1 - shift - - echo $((time -p $* >/dev/null) 2>&1) | awk '{print $4 "u " $6 "s " $2 "r"}' -} - -fasta() { - runonly echo 'fasta -n 25000000' - run "gcc $gccm -O2 fasta.c" a.out 25000000 - run 'gccgo -O2 fasta.go' a.out -n 25000000 #commented out until WriteString is in bufio - run 'gc fasta' $O.out -n 25000000 - run 'gc_B fasta' $O.out -n 25000000 -} - -revcomp() { - runonly gcc -O2 fasta.c - runonly a.out 25000000 > x - runonly echo 'reverse-complement < output-of-fasta-25000000' - run "gcc $gccm -O2 reverse-complement.c" a.out < x - run 'gccgo -O2 reverse-complement.go' a.out < x - run 'gc reverse-complement' $O.out < x - run 'gc_B reverse-complement' $O.out < x - rm x -} - -nbody() { - runonly echo 'nbody -n 50000000' - run "gcc $gccm -O2 nbody.c -lm" a.out 50000000 - run 'gccgo -O2 nbody.go' a.out -n 50000000 - run 'gc nbody' $O.out -n 50000000 - run 'gc_B nbody' $O.out -n 50000000 -} - -binarytree() { - runonly echo 'binary-tree 15 # too slow to use 20' - run "gcc $gccm -O2 binary-tree.c -lm" a.out 15 - run 'gccgo -O2 binary-tree.go' a.out -n 15 - run 'gccgo -O2 binary-tree-freelist.go' a.out -n 15 - run 'gc binary-tree' $O.out -n 15 - run 'gc binary-tree-freelist' $O.out -n 15 -} - -fannkuch() { - runonly echo 'fannkuch 12' - run "gcc $gccm -O2 fannkuch.c" a.out 12 - run 'gccgo -O2 fannkuch.go' a.out -n 12 - run 'gccgo -O2 fannkuch-parallel.go' a.out -n 12 - run 'gc fannkuch' $O.out -n 12 - run 'gc fannkuch-parallel' $O.out -n 12 - run 'gc_B fannkuch' $O.out -n 12 -} - -regexdna() { - runonly gcc -O2 fasta.c - runonly a.out 100000 > x - runonly echo 'regex-dna 100000' - run "gcc $gccm -O2 regex-dna.c -lpcre" a.out x # should be using 25000000 - runonly echo 'k-nucleotide 1000000' - if [ $mode = run ]; then - run "gcc -O2 k-nucleotide.c $(pkg-config glib-2.0 --cflags --libs)" a.out = 2⁸. use(s[ui8]) use(a1[ui8]) - use(a1k[ui8]) // ERROR "index bounds check elided" - use(a100k[ui8]) // ERROR "index bounds check elided" + use(a1k[ui8]) // ERROR "index bounds check elided" + use(a100k[ui8]) // ERROR "index bounds check elided" use(p1[ui8]) - use(p1k[ui8]) // ERROR "index bounds check elided" - use(p100k[ui8]) // ERROR "index bounds check elided" + use(p1k[ui8]) // ERROR "index bounds check elided" + use(p100k[ui8]) // ERROR "index bounds check elided" use(s[i16]) use(a1[i16]) @@ -79,10 +79,10 @@ func main() { use(s[ui16]) use(a1[ui16]) use(a1k[ui16]) - use(a100k[ui16]) // ERROR "index bounds check elided" + use(a100k[ui16]) // ERROR "index bounds check elided" use(p1[ui16]) use(p1k[ui16]) - use(p100k[ui16]) // ERROR "index bounds check elided" + use(p100k[ui16]) // ERROR "index bounds check elided" use(s[i32]) use(a1[i32]) @@ -128,11 +128,11 @@ func main() { use(s[ui%999]) use(a1[ui%999]) - use(a1k[ui%999]) // ERROR "index bounds check elided" - use(a100k[ui%999]) // ERROR "index bounds check elided" + use(a1k[ui%999]) // ERROR "index bounds check elided" + use(a100k[ui%999]) // ERROR "index bounds check elided" use(p1[ui%999]) - use(p1k[ui%999]) // ERROR "index bounds check elided" - use(p100k[ui%999]) // ERROR "index bounds check elided" + use(p1k[ui%999]) // ERROR "index bounds check elided" + use(p100k[ui%999]) // ERROR "index bounds check elided" use(s[i%1000]) use(a1[i%1000]) @@ -144,11 +144,11 @@ func main() { use(s[ui%1000]) use(a1[ui%1000]) - use(a1k[ui%1000]) // ERROR "index bounds check elided" - use(a100k[ui%1000]) // ERROR "index bounds check elided" + use(a1k[ui%1000]) // ERROR "index bounds check elided" + use(a100k[ui%1000]) // ERROR "index bounds check elided" use(p1[ui%1000]) - use(p1k[ui%1000]) // ERROR "index bounds check elided" - use(p100k[ui%1000]) // ERROR "index bounds check elided" + use(p1k[ui%1000]) // ERROR "index bounds check elided" + use(p100k[ui%1000]) // ERROR "index bounds check elided" use(s[i%1001]) use(a1[i%1001]) @@ -161,45 +161,59 @@ func main() { use(s[ui%1001]) use(a1[ui%1001]) use(a1k[ui%1001]) - use(a100k[ui%1001]) // ERROR "index bounds check elided" + use(a100k[ui%1001]) // ERROR "index bounds check elided" use(p1[ui%1001]) use(p1k[ui%1001]) - use(p100k[ui%1001]) // ERROR "index bounds check elided" + use(p100k[ui%1001]) // ERROR "index bounds check elided" // Bitwise and truncates the maximum value to the mask value. // The result (for a positive mask) cannot be negative, so elision // applies to both signed and unsigned indexes. use(s[i&999]) use(a1[i&999]) - use(a1k[i&999]) // ERROR "index bounds check elided" - use(a100k[i&999]) // ERROR "index bounds check elided" + use(a1k[i&999]) // ERROR "index bounds check elided" + use(a100k[i&999]) // ERROR "index bounds check elided" use(p1[i&999]) - use(p1k[i&999]) // ERROR "index bounds check elided" - use(p100k[i&999]) // ERROR "index bounds check elided" + use(p1k[i&999]) // ERROR "index bounds check elided" + use(p100k[i&999]) // ERROR "index bounds check elided" use(s[ui&999]) use(a1[ui&999]) - use(a1k[ui&999]) // ERROR "index bounds check elided" - use(a100k[ui&999]) // ERROR "index bounds check elided" + use(a1k[ui&999]) // ERROR "index bounds check elided" + use(a100k[ui&999]) // ERROR "index bounds check elided" use(p1[ui&999]) - use(p1k[ui&999]) // ERROR "index bounds check elided" - use(p100k[ui&999]) // ERROR "index bounds check elided" + use(p1k[ui&999]) // ERROR "index bounds check elided" + use(p100k[ui&999]) // ERROR "index bounds check elided" use(s[i&1000]) use(a1[i&1000]) use(a1k[i&1000]) - use(a100k[i&1000]) // ERROR "index bounds check elided" + use(a100k[i&1000]) // ERROR "index bounds check elided" use(p1[i&1000]) use(p1k[i&1000]) - use(p100k[i&1000]) // ERROR "index bounds check elided" + use(p100k[i&1000]) // ERROR "index bounds check elided" use(s[ui&1000]) use(a1[ui&1000]) use(a1k[ui&1000]) - use(a100k[ui&1000]) // ERROR "index bounds check elided" + use(a100k[ui&1000]) // ERROR "index bounds check elided" use(p1[ui&1000]) use(p1k[ui&1000]) - use(p100k[ui&1000]) // ERROR "index bounds check elided" + use(p100k[ui&1000]) // ERROR "index bounds check elided" + + use(a1[i&^-1]) // ERROR "index bounds check elided" + use(a1[i&^0]) + use(a1[i&^-2]) + use(a1[i&^1]) + use(a1k[i&^-1]) // ERROR "index bounds check elided" + use(a1k[i&^0]) + use(a1k[i&^-2]) // ERROR "index bounds check elided" + use(a1k[i&^1]) + use(a1k[i8&^0]) + use(a1k[i8&^-128]) // ERROR "index bounds check elided" + use(a1k[ui8&^1]) // ERROR "index bounds check elided" + use(a1k[ui16&^0xf000]) + use(a1k[ui16&^0xff00]) // ERROR "index bounds check elided" // Right shift cuts the effective number of bits in the index, // but only for unsigned (signed stays negative). @@ -214,10 +228,10 @@ func main() { use(s[ui32>>22]) use(a1[ui32>>22]) use(a1k[ui32>>22]) - use(a100k[ui32>>22]) // ERROR "index bounds check elided" + use(a100k[ui32>>22]) // ERROR "index bounds check elided" use(p1[ui32>>22]) use(p1k[ui32>>22]) - use(p100k[ui32>>22]) // ERROR "index bounds check elided" + use(p100k[ui32>>22]) // ERROR "index bounds check elided" use(s[i32>>23]) use(a1[i32>>23]) @@ -229,11 +243,11 @@ func main() { use(s[ui32>>23]) use(a1[ui32>>23]) - use(a1k[ui32>>23]) // ERROR "index bounds check elided" - use(a100k[ui32>>23]) // ERROR "index bounds check elided" + use(a1k[ui32>>23]) // ERROR "index bounds check elided" + use(a100k[ui32>>23]) // ERROR "index bounds check elided" use(p1[ui32>>23]) - use(p1k[ui32>>23]) // ERROR "index bounds check elided" - use(p100k[ui32>>23]) // ERROR "index bounds check elided" + use(p1k[ui32>>23]) // ERROR "index bounds check elided" + use(p100k[ui32>>23]) // ERROR "index bounds check elided" // Division cuts the range like right shift does. use(s[i/1e6]) @@ -263,7 +277,7 @@ func main() { use(p1[ui/1e7]) } -var sum int +var sum int func use(x int) { sum += x diff --git a/gcc/testsuite/go.test/test/bugs/bug395.go b/gcc/testsuite/go.test/test/bugs/bug395.go deleted file mode 100644 index 4632dcd0f79..00000000000 --- a/gcc/testsuite/go.test/test/bugs/bug395.go +++ /dev/null @@ -1,25 +0,0 @@ -// echo bug395 is broken # takes 90+ seconds to break -// # $G $D/$F.go || echo bug395 - -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// 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. - -// Issue 1909 -// Would OOM due to exponential recursion on Foo's expanded methodset in nodefmt -package test - -type Foo interface { - Bar() interface { - Foo - } - Baz() interface { - Foo - } - Bug() interface { - Foo - } -} diff --git a/gcc/testsuite/go.test/test/bugs/placeholder b/gcc/testsuite/go.test/test/bugs/placeholder deleted file mode 100644 index b816d34fc34..00000000000 --- a/gcc/testsuite/go.test/test/bugs/placeholder +++ /dev/null @@ -1,2 +0,0 @@ -This file keeps Mercurial from deleting the directory -when there are no known bugs. diff --git a/gcc/testsuite/go.test/test/chan/doubleselect.go b/gcc/testsuite/go.test/test/chan/doubleselect.go index 6be3faf55a9..ff69dbe5dbc 100644 --- a/gcc/testsuite/go.test/test/chan/doubleselect.go +++ b/gcc/testsuite/go.test/test/chan/doubleselect.go @@ -61,6 +61,7 @@ func recver(in <-chan int) { func main() { runtime.GOMAXPROCS(2) + flag.Parse() c1 := make(chan int) c2 := make(chan int) c3 := make(chan int) diff --git a/gcc/testsuite/go.test/test/chan/fifo.go b/gcc/testsuite/go.test/test/chan/fifo.go index 70d20b31f09..0001bcf8a29 100644 --- a/gcc/testsuite/go.test/test/chan/fifo.go +++ b/gcc/testsuite/go.test/test/chan/fifo.go @@ -54,4 +54,3 @@ func main() { AsynchFifo() SynchFifo() } - diff --git a/gcc/testsuite/go.test/test/chan/perm.go b/gcc/testsuite/go.test/test/chan/perm.go index 7e152c5eb5a..0c96d921d1e 100644 --- a/gcc/testsuite/go.test/test/chan/perm.go +++ b/gcc/testsuite/go.test/test/chan/perm.go @@ -24,19 +24,23 @@ func main() { cr = cs // ERROR "illegal types|incompatible|cannot" cs = cr // ERROR "illegal types|incompatible|cannot" - c <- 0 // ok - <-c // ok - x, ok := <-c // ok + var n int + <-n // ERROR "receive from non-chan|expected channel" + n <- 2 // ERROR "send to non-chan|must be channel" + + c <- 0 // ok + <-c // ok + x, ok := <-c // ok _, _ = x, ok - cr <- 0 // ERROR "send" - <-cr // ok - x, ok = <-cr // ok + cr <- 0 // ERROR "send" + <-cr // ok + x, ok = <-cr // ok _, _ = x, ok - cs <- 0 // ok - <-cs // ERROR "receive" - x, ok = <-cs // ERROR "receive" + cs <- 0 // ok + <-cs // ERROR "receive" + x, ok = <-cs // ERROR "receive" _, _ = x, ok select { @@ -53,10 +57,14 @@ func main() { _ = x } - for _ = range cs {// ERROR "receive" + for _ = range cs { // ERROR "receive" + } + + for range cs { // ERROR "receive" } close(c) close(cs) - close(cr) // ERROR "receive" + close(cr) // ERROR "receive" + close(n) // ERROR "invalid operation.*non-chan type|must be channel" } diff --git a/gcc/testsuite/go.test/test/chan/powser1.go b/gcc/testsuite/go.test/test/chan/powser1.go index 6bf2a911157..e999dde2bee 100644 --- a/gcc/testsuite/go.test/test/chan/powser1.go +++ b/gcc/testsuite/go.test/test/chan/powser1.go @@ -11,18 +11,18 @@ // coefficients. A denominator of zero signifies the end. // Original code in Newsqueak by Doug McIlroy. // See Squinting at Power Series by Doug McIlroy, -// http://www.cs.bell-labs.com/who/rsc/thread/squint.pdf +// https://swtch.com/~rsc/thread/squint.pdf package main import "os" -type rat struct { - num, den int64 // numerator, denominator +type rat struct { + num, den int64 // numerator, denominator } func (u rat) pr() { - if u.den==1 { + if u.den == 1 { print(u.num) } else { print(u.num, "/", u.den) @@ -35,12 +35,12 @@ func (u rat) eq(c rat) bool { } type dch struct { - req chan int - dat chan rat + req chan int + dat chan rat nam int } -type dch2 [2] *dch +type dch2 [2]*dch var chnames string var chnameserial int @@ -77,17 +77,17 @@ func mkdch2() *dch2 { // a signal on the release-wait channel tells the next newer // generation to begin servicing out[1]. -func dosplit(in *dch, out *dch2, wait chan int ) { - both := false // do not service both channels +func dosplit(in *dch, out *dch2, wait chan int) { + both := false // do not service both channels select { case <-out[0].req: - + case <-wait: both = true select { case <-out[0].req: - + case <-out[1].req: out[0], out[1] = out[1], out[0] } @@ -95,7 +95,7 @@ func dosplit(in *dch, out *dch2, wait chan int ) { seqno++ in.req <- seqno - release := make(chan int) + release := make(chan int) go dosplit(in, out, release) dat := <-in.dat out[0].dat <- dat @@ -128,17 +128,19 @@ func get(in *dch) rat { func getn(in []*dch) []rat { n := len(in) - if n != 2 { panic("bad n in getn") } - req := new([2] chan int) - dat := new([2] chan rat) + if n != 2 { + panic("bad n in getn") + } + req := new([2]chan int) + dat := new([2]chan rat) out := make([]rat, 2) var i int var it rat - for i=0; i0; n-- { + for n = 2 * n; n > 0; n-- { seqno++ select { @@ -178,8 +180,8 @@ func repeat(dat rat, out *dch) { } } -type PS *dch // power series -type PS2 *[2] PS // pair of power series +type PS *dch // power series +type PS2 *[2]PS // pair of power series var Ones PS var Twos PS @@ -200,23 +202,27 @@ func mkPS2() *dch2 { // Integer gcd; needed for rational arithmetic -func gcd (u, v int64) int64 { - if u < 0 { return gcd(-u, v) } - if u == 0 { return v } +func gcd(u, v int64) int64 { + if u < 0 { + return gcd(-u, v) + } + if u == 0 { + return v + } return gcd(v%u, u) } // Make a rational from two ints and from one int func i2tor(u, v int64) rat { - g := gcd(u,v) + g := gcd(u, v) var r rat if v > 0 { - r.num = u/g - r.den = v/g + r.num = u / g + r.den = v / g } else { - r.num = -u/g - r.den = -v/g + r.num = -u / g + r.den = -v / g } return r } @@ -228,29 +234,30 @@ func itor(u int64) rat { var zero rat var one rat - // End mark and end test var finis rat func end(u rat) int64 { - if u.den==0 { return 1 } + if u.den == 0 { + return 1 + } return 0 } // Operations on rationals func add(u, v rat) rat { - g := gcd(u.den,v.den) - return i2tor(u.num*(v.den/g)+v.num*(u.den/g),u.den*(v.den/g)) + g := gcd(u.den, v.den) + return i2tor(u.num*(v.den/g)+v.num*(u.den/g), u.den*(v.den/g)) } func mul(u, v rat) rat { - g1 := gcd(u.num,v.den) - g2 := gcd(u.den,v.num) + g1 := gcd(u.num, v.den) + g2 := gcd(u.den, v.num) var r rat - r.num = (u.num/g1)*(v.num/g2) - r.den = (u.den/g2)*(v.den/g1) + r.num = (u.num / g1) * (v.num / g2) + r.den = (u.den / g2) * (v.den / g1) return r } @@ -262,23 +269,25 @@ func sub(u, v rat) rat { return add(u, neg(v)) } -func inv(u rat) rat { // invert a rat - if u.num == 0 { panic("zero divide in inv") } +func inv(u rat) rat { // invert a rat + if u.num == 0 { + panic("zero divide in inv") + } return i2tor(u.den, u.num) } // print eval in floating point of PS at x=c to n terms func evaln(c rat, U PS, n int) { xn := float64(1) - x := float64(c.num)/float64(c.den) + x := float64(c.num) / float64(c.den) val := float64(0) - for i:=0; i0; n-- { + for ; !done && n > 0; n-- { u := get(U) if end(u) != 0 { done = true @@ -299,10 +308,14 @@ func printn(U PS, n int) { // Evaluate n terms of power series U at x=c func eval(c rat, U PS, n int) rat { - if n==0 { return zero } + if n == 0 { + return zero + } y := get(U) - if end(y) != 0 { return zero } - return add(y,mul(c,eval(c,U,n-1))) + if end(y) != 0 { + return zero + } + return add(y, mul(c, eval(c, U, n-1))) } // Power-series constructors return channels on which power @@ -313,7 +326,7 @@ func eval(c rat, U PS, n int) rat { func Split(U PS) *dch2 { UU := mkdch2() - go split(U,UU) + go split(U, UU) return UU } @@ -324,16 +337,16 @@ func Add(U, V PS) PS { var uv []rat for { <-Z.req - uv = get2(U,V) - switch end(uv[0])+2*end(uv[1]) { + uv = get2(U, V) + switch end(uv[0]) + 2*end(uv[1]) { case 0: Z.dat <- add(uv[0], uv[1]) case 1: Z.dat <- uv[1] - copy(V,Z) + copy(V, Z) case 2: Z.dat <- uv[0] - copy(U,Z) + copy(U, Z) case 3: Z.dat <- finis } @@ -343,7 +356,7 @@ func Add(U, V PS) PS { } // Multiply a power series by a constant -func Cmul(c rat,U PS) PS { +func Cmul(c rat, U PS) PS { Z := mkPS() go func() { done := false @@ -353,7 +366,7 @@ func Cmul(c rat,U PS) PS { if end(u) != 0 { done = true } else { - Z.dat <- mul(c,u) + Z.dat <- mul(c, u) } } Z.dat <- finis @@ -372,8 +385,10 @@ func Sub(U, V PS) PS { func Monmul(U PS, n int) PS { Z := mkPS() go func() { - for ; n>0; n-- { put(zero,Z) } - copy(U,Z) + for ; n > 0; n-- { + put(zero, Z) + } + copy(U, Z) }() return Z } @@ -381,25 +396,27 @@ func Monmul(U PS, n int) PS { // Multiply by x func Xmul(U PS) PS { - return Monmul(U,1) + return Monmul(U, 1) } func Rep(c rat) PS { Z := mkPS() - go repeat(c,Z) + go repeat(c, Z) return Z } // Monomial c*x^n func Mon(c rat, n int) PS { - Z:=mkPS() + Z := mkPS() go func() { - if(c.num!=0) { - for ; n>0; n=n-1 { put(zero,Z) } - put(c,Z) + if c.num != 0 { + for ; n > 0; n = n - 1 { + put(zero, Z) + } + put(c, Z) } - put(finis,Z) + put(finis, Z) }() return Z } @@ -407,8 +424,8 @@ func Mon(c rat, n int) PS { func Shift(c rat, U PS) PS { Z := mkPS() go func() { - put(c,Z) - copy(U,Z) + put(c, Z) + copy(U, Z) }() return Z } @@ -440,20 +457,20 @@ func Poly(a []rat) PS { // then UV = u*v + x*(u*VV+v*UU) + x*x*UU*VV func Mul(U, V PS) PS { - Z:=mkPS() + Z := mkPS() go func() { <-Z.req - uv := get2(U,V) - if end(uv[0])!=0 || end(uv[1]) != 0 { + uv := get2(U, V) + if end(uv[0]) != 0 || end(uv[1]) != 0 { Z.dat <- finis } else { - Z.dat <- mul(uv[0],uv[1]) + Z.dat <- mul(uv[0], uv[1]) UU := Split(U) VV := Split(V) - W := Add(Cmul(uv[0],VV[0]),Cmul(uv[1],UU[0])) + W := Add(Cmul(uv[0], VV[0]), Cmul(uv[1], UU[0])) <-Z.req Z.dat <- get(W) - copy(Add(W,Mul(UU[1],VV[1])),Z) + copy(Add(W, Mul(UU[1], VV[1])), Z) } }() return Z @@ -462,18 +479,18 @@ func Mul(U, V PS) PS { // Differentiate func Diff(U PS) PS { - Z:=mkPS() + Z := mkPS() go func() { <-Z.req u := get(U) if end(u) == 0 { - done:=false - for i:=1; !done; i++ { + done := false + for i := 1; !done; i++ { u = get(U) if end(u) != 0 { done = true } else { - Z.dat <- mul(itor(int64(i)),u) + Z.dat <- mul(itor(int64(i)), u) <-Z.req } } @@ -484,16 +501,18 @@ func Diff(U PS) PS { } // Integrate, with const of integration -func Integ(c rat,U PS) PS { - Z:=mkPS() +func Integ(c rat, U PS) PS { + Z := mkPS() go func() { - put(c,Z) - done:=false - for i:=1; !done; i++ { + put(c, Z) + done := false + for i := 1; !done; i++ { <-Z.req u := get(U) - if end(u) != 0 { done= true } - Z.dat <- mul(i2tor(1,int64(i)),u) + if end(u) != 0 { + done = true + } + Z.dat <- mul(i2tor(1, int64(i)), u) } Z.dat <- finis }() @@ -503,17 +522,17 @@ func Integ(c rat,U PS) PS { // Binomial theorem (1+x)^c func Binom(c rat) PS { - Z:=mkPS() + Z := mkPS() go func() { n := 1 t := itor(1) - for c.num!=0 { - put(t,Z) - t = mul(mul(t,c),i2tor(1,int64(n))) - c = sub(c,one) + for c.num != 0 { + put(t, Z) + t = mul(mul(t, c), i2tor(1, int64(n))) + c = sub(c, one) n++ } - put(finis,Z) + put(finis, Z) }() return Z } @@ -527,14 +546,14 @@ func Binom(c rat) PS { // ZZ = -UU*(z+x*ZZ)/u func Recip(U PS) PS { - Z:=mkPS() + Z := mkPS() go func() { - ZZ:=mkPS2() + ZZ := mkPS2() <-Z.req z := inv(get(U)) Z.dat <- z - split(Mul(Cmul(neg(z),U),Shift(z,ZZ[0])),ZZ) - copy(ZZ[1],Z) + split(Mul(Cmul(neg(z), U), Shift(z, ZZ[0])), ZZ) + copy(ZZ[1], Z) }() return Z } @@ -548,7 +567,7 @@ func Recip(U PS) PS { func Exp(U PS) PS { ZZ := mkPS2() - split(Integ(one,Mul(ZZ[0],Diff(U))),ZZ) + split(Integ(one, Mul(ZZ[0], Diff(U))), ZZ) return ZZ[1] } @@ -559,7 +578,7 @@ func Exp(U PS) PS { // bug: a nonzero constant term is ignored func Subst(U, V PS) PS { - Z:= mkPS() + Z := mkPS() go func() { VV := Split(V) <-Z.req @@ -567,20 +586,20 @@ func Subst(U, V PS) PS { Z.dat <- u if end(u) == 0 { if end(get(VV[0])) != 0 { - put(finis,Z) + put(finis, Z) } else { - copy(Mul(VV[0],Subst(U,VV[1])),Z) + copy(Mul(VV[0], Subst(U, VV[1])), Z) } } }() return Z } -// Monomial Substition: U(c x^n) +// Monomial Substitution: U(c x^n) // Each Ui is multiplied by c^i and followed by n-1 zeros func MonSubst(U PS, c0 rat, n int) PS { - Z:= mkPS() + Z := mkPS() go func() { c := one for { @@ -601,14 +620,13 @@ func MonSubst(U PS, c0 rat, n int) PS { return Z } - func Init() { chnameserial = -1 seqno = 0 chnames = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" zero = itor(0) one = itor(1) - finis = i2tor(1,0) + finis = i2tor(1, 0) Ones = Rep(one) Twos = Rep(itor(2)) } @@ -627,7 +645,8 @@ func check(U PS, c rat, count int, str string) { } } -const N=10 +const N = 10 + func checka(U PS, a []rat, str string) { for i := 0; i < N; i++ { check(U, a[i], 1, str) @@ -636,53 +655,64 @@ func checka(U PS, a []rat, str string) { func main() { Init() - if len(os.Args) > 1 { // print - print("Ones: "); printn(Ones, 10) - print("Twos: "); printn(Twos, 10) - print("Add: "); printn(Add(Ones, Twos), 10) - print("Diff: "); printn(Diff(Ones), 10) - print("Integ: "); printn(Integ(zero, Ones), 10) - print("CMul: "); printn(Cmul(neg(one), Ones), 10) - print("Sub: "); printn(Sub(Ones, Twos), 10) - print("Mul: "); printn(Mul(Ones, Ones), 10) - print("Exp: "); printn(Exp(Ones), 15) - print("MonSubst: "); printn(MonSubst(Ones, neg(one), 2), 10) - print("ATan: "); printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) - } else { // test + if len(os.Args) > 1 { // print + print("Ones: ") + printn(Ones, 10) + print("Twos: ") + printn(Twos, 10) + print("Add: ") + printn(Add(Ones, Twos), 10) + print("Diff: ") + printn(Diff(Ones), 10) + print("Integ: ") + printn(Integ(zero, Ones), 10) + print("CMul: ") + printn(Cmul(neg(one), Ones), 10) + print("Sub: ") + printn(Sub(Ones, Twos), 10) + print("Mul: ") + printn(Mul(Ones, Ones), 10) + print("Exp: ") + printn(Exp(Ones), 15) + print("MonSubst: ") + printn(MonSubst(Ones, neg(one), 2), 10) + print("ATan: ") + printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) + } else { // test check(Ones, one, 5, "Ones") - check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 + check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos") // 3 3 3 3 3 a := make([]rat, N) d := Diff(Ones) - for i:=0; i < N; i++ { - a[i] = itor(int64(i+1)) + for i := 0; i < N; i++ { + a[i] = itor(int64(i + 1)) } - checka(d, a, "Diff") // 1 2 3 4 5 + checka(d, a, "Diff") // 1 2 3 4 5 in := Integ(zero, Ones) - a[0] = zero // integration constant - for i:=1; i < N; i++ { + a[0] = zero // integration constant + for i := 1; i < N; i++ { a[i] = i2tor(1, int64(i)) } - checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 - check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 - check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 + checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 + check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 + check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 m := Mul(Ones, Ones) - for i:=0; i < N; i++ { - a[i] = itor(int64(i+1)) + for i := 0; i < N; i++ { + a[i] = itor(int64(i + 1)) } - checka(m, a, "Mul") // 1 2 3 4 5 + checka(m, a, "Mul") // 1 2 3 4 5 e := Exp(Ones) a[0] = itor(1) a[1] = itor(1) - a[2] = i2tor(3,2) - a[3] = i2tor(13,6) - a[4] = i2tor(73,24) - a[5] = i2tor(167,40) - a[6] = i2tor(4051,720) - a[7] = i2tor(37633,5040) - a[8] = i2tor(43817,4480) - a[9] = i2tor(4596553,362880) - checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 + a[2] = i2tor(3, 2) + a[3] = i2tor(13, 6) + a[4] = i2tor(73, 24) + a[5] = i2tor(167, 40) + a[6] = i2tor(4051, 720) + a[7] = i2tor(37633, 5040) + a[8] = i2tor(43817, 4480) + a[9] = i2tor(4596553, 362880) + checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 at := Integ(zero, MonSubst(Ones, neg(one), 2)) for c, i := 1, 0; i < N; i++ { if i%2 == 0 { @@ -692,20 +722,20 @@ func main() { c *= -1 } } - checka(at, a, "ATan") // 0 -1 0 -1/3 0 -1/5 -/* - t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) - a[0] = zero - a[1] = itor(1) - a[2] = zero - a[3] = i2tor(1,3) - a[4] = zero - a[5] = i2tor(2,15) - a[6] = zero - a[7] = i2tor(17,315) - a[8] = zero - a[9] = i2tor(62,2835) - checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 -*/ + checka(at, a, "ATan") // 0 -1 0 -1/3 0 -1/5 + /* + t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) + a[0] = zero + a[1] = itor(1) + a[2] = zero + a[3] = i2tor(1,3) + a[4] = zero + a[5] = i2tor(2,15) + a[6] = zero + a[7] = i2tor(17,315) + a[8] = zero + a[9] = i2tor(62,2835) + checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 + */ } } diff --git a/gcc/testsuite/go.test/test/chan/powser2.go b/gcc/testsuite/go.test/test/chan/powser2.go index 33abd5c53fe..72cbba8cf6c 100644 --- a/gcc/testsuite/go.test/test/chan/powser2.go +++ b/gcc/testsuite/go.test/test/chan/powser2.go @@ -15,14 +15,14 @@ // coefficients. A denominator of zero signifies the end. // Original code in Newsqueak by Doug McIlroy. // See Squinting at Power Series by Doug McIlroy, -// http://www.cs.bell-labs.com/who/rsc/thread/squint.pdf +// https://swtch.com/~rsc/thread/squint.pdf package main import "os" -type rat struct { - num, den int64 // numerator, denominator +type rat struct { + num, den int64 // numerator, denominator } type item interface { @@ -30,8 +30,8 @@ type item interface { eq(c item) bool } -func (u *rat) pr(){ - if u.den==1 { +func (u *rat) pr() { + if u.den == 1 { print(u.num) } else { print(u.num, "/", u.den) @@ -45,12 +45,12 @@ func (u *rat) eq(c item) bool { } type dch struct { - req chan int - dat chan item + req chan int + dat chan item nam int } -type dch2 [2] *dch +type dch2 [2]*dch var chnames string var chnameserial int @@ -87,25 +87,25 @@ func mkdch2() *dch2 { // a signal on the release-wait channel tells the next newer // generation to begin servicing out[1]. -func dosplit(in *dch, out *dch2, wait chan int ){ - both := false // do not service both channels +func dosplit(in *dch, out *dch2, wait chan int) { + both := false // do not service both channels select { case <-out[0].req: - + case <-wait: both = true select { case <-out[0].req: - + case <-out[1].req: - out[0],out[1] = out[1], out[0] + out[0], out[1] = out[1], out[0] } } seqno++ in.req <- seqno - release := make(chan int) + release := make(chan int) go dosplit(in, out, release) dat := <-in.dat out[0].dat <- dat @@ -117,13 +117,13 @@ func dosplit(in *dch, out *dch2, wait chan int ){ release <- 0 } -func split(in *dch, out *dch2){ +func split(in *dch, out *dch2) { release := make(chan int) go dosplit(in, out, release) release <- 0 } -func put(dat item, out *dch){ +func put(dat item, out *dch) { <-out.req out.dat <- dat } @@ -137,21 +137,23 @@ func get(in *dch) *rat { // Get one item from each of n demand channels func getn(in []*dch) []item { - n:=len(in) - if n != 2 { panic("bad n in getn") } - req := make([] chan int, 2) - dat := make([] chan item, 2) + n := len(in) + if n != 2 { + panic("bad n in getn") + } + req := make([]chan int, 2) + dat := make([]chan item, 2) out := make([]item, 2) var i int var it item - for i=0; i0; n-- { + for n = 2 * n; n > 0; n-- { seqno++ - select{ + select { case req[0] <- seqno: dat[0] = in[0].dat req[0] = nil @@ -171,25 +173,25 @@ func getn(in []*dch) []item { // Get one item from each of 2 demand channels -func get2(in0 *dch, in1 *dch) []item { +func get2(in0 *dch, in1 *dch) []item { return getn([]*dch{in0, in1}) } -func copy(in *dch, out *dch){ +func copy(in *dch, out *dch) { for { <-out.req out.dat <- get(in) } } -func repeat(dat item, out *dch){ +func repeat(dat item, out *dch) { for { put(dat, out) } } -type PS *dch // power series -type PS2 *[2] PS // pair of power series +type PS *dch // power series +type PS2 *[2]PS // pair of power series var Ones PS var Twos PS @@ -210,93 +212,100 @@ func mkPS2() *dch2 { // Integer gcd; needed for rational arithmetic -func gcd (u, v int64) int64{ - if u < 0 { return gcd(-u, v) } - if u == 0 { return v } +func gcd(u, v int64) int64 { + if u < 0 { + return gcd(-u, v) + } + if u == 0 { + return v + } return gcd(v%u, u) } // Make a rational from two ints and from one int -func i2tor(u, v int64) *rat{ - g := gcd(u,v) +func i2tor(u, v int64) *rat { + g := gcd(u, v) r := new(rat) if v > 0 { - r.num = u/g - r.den = v/g + r.num = u / g + r.den = v / g } else { - r.num = -u/g - r.den = -v/g + r.num = -u / g + r.den = -v / g } return r } -func itor(u int64) *rat{ +func itor(u int64) *rat { return i2tor(u, 1) } var zero *rat var one *rat - // End mark and end test var finis *rat func end(u *rat) int64 { - if u.den==0 { return 1 } + if u.den == 0 { + return 1 + } return 0 } // Operations on rationals func add(u, v *rat) *rat { - g := gcd(u.den,v.den) - return i2tor(u.num*(v.den/g)+v.num*(u.den/g),u.den*(v.den/g)) + g := gcd(u.den, v.den) + return i2tor(u.num*(v.den/g)+v.num*(u.den/g), u.den*(v.den/g)) } -func mul(u, v *rat) *rat{ - g1 := gcd(u.num,v.den) - g2 := gcd(u.den,v.num) +func mul(u, v *rat) *rat { + g1 := gcd(u.num, v.den) + g2 := gcd(u.den, v.num) r := new(rat) - r.num =(u.num/g1)*(v.num/g2) - r.den = (u.den/g2)*(v.den/g1) + r.num = (u.num / g1) * (v.num / g2) + r.den = (u.den / g2) * (v.den / g1) return r } -func neg(u *rat) *rat{ +func neg(u *rat) *rat { return i2tor(-u.num, u.den) } -func sub(u, v *rat) *rat{ +func sub(u, v *rat) *rat { return add(u, neg(v)) } -func inv(u *rat) *rat{ // invert a rat - if u.num == 0 { panic("zero divide in inv") } +func inv(u *rat) *rat { // invert a rat + if u.num == 0 { + panic("zero divide in inv") + } return i2tor(u.den, u.num) } // print eval in floating point of PS at x=c to n terms func Evaln(c *rat, U PS, n int) { xn := float64(1) - x := float64(c.num)/float64(c.den) + x := float64(c.num) / float64(c.den) val := float64(0) - for i:=0; i0; n-- { + for ; !done && n > 0; n-- { u := get(U) if end(u) != 0 { done = true @@ -307,16 +316,20 @@ func Printn(U PS, n int){ print(("\n")) } -func Print(U PS){ - Printn(U,1000000000) +func Print(U PS) { + Printn(U, 1000000000) } // Evaluate n terms of power series U at x=c -func eval(c *rat, U PS, n int) *rat{ - if n==0 { return zero } +func eval(c *rat, U PS, n int) *rat { + if n == 0 { + return zero + } y := get(U) - if end(y) != 0 { return zero } - return add(y,mul(c,eval(c,U,n-1))) + if end(y) != 0 { + return zero + } + return add(y, mul(c, eval(c, U, n-1))) } // Power-series constructors return channels on which power @@ -325,29 +338,29 @@ func eval(c *rat, U PS, n int) *rat{ // Make a pair of power series identical to a given power series -func Split(U PS) *dch2{ +func Split(U PS) *dch2 { UU := mkdch2() - go split(U,UU) + go split(U, UU) return UU } // Add two power series -func Add(U, V PS) PS{ +func Add(U, V PS) PS { Z := mkPS() - go func(U, V, Z PS){ - var uv [] item + go func(U, V, Z PS) { + var uv []item for { <-Z.req - uv = get2(U,V) - switch end(uv[0].(*rat))+2*end(uv[1].(*rat)) { + uv = get2(U, V) + switch end(uv[0].(*rat)) + 2*end(uv[1].(*rat)) { case 0: Z.dat <- add(uv[0].(*rat), uv[1].(*rat)) case 1: Z.dat <- uv[1] - copy(V,Z) + copy(V, Z) case 2: Z.dat <- uv[0] - copy(U,Z) + copy(U, Z) case 3: Z.dat <- finis } @@ -357,9 +370,9 @@ func Add(U, V PS) PS{ } // Multiply a power series by a constant -func Cmul(c *rat,U PS) PS{ +func Cmul(c *rat, U PS) PS { Z := mkPS() - go func(c *rat, U, Z PS){ + go func(c *rat, U, Z PS) { done := false for !done { <-Z.req @@ -367,7 +380,7 @@ func Cmul(c *rat,U PS) PS{ if end(u) != 0 { done = true } else { - Z.dat <- mul(c,u) + Z.dat <- mul(c, u) } } Z.dat <- finis @@ -377,52 +390,56 @@ func Cmul(c *rat,U PS) PS{ // Subtract -func Sub(U, V PS) PS{ +func Sub(U, V PS) PS { return Add(U, Cmul(neg(one), V)) } // Multiply a power series by the monomial x^n -func Monmul(U PS, n int) PS{ +func Monmul(U PS, n int) PS { Z := mkPS() - go func(n int, U PS, Z PS){ - for ; n>0; n-- { put(zero,Z) } - copy(U,Z) + go func(n int, U PS, Z PS) { + for ; n > 0; n-- { + put(zero, Z) + } + copy(U, Z) }(n, U, Z) return Z } // Multiply by x -func Xmul(U PS) PS{ - return Monmul(U,1) +func Xmul(U PS) PS { + return Monmul(U, 1) } -func Rep(c *rat) PS{ +func Rep(c *rat) PS { Z := mkPS() - go repeat(c,Z) + go repeat(c, Z) return Z } // Monomial c*x^n -func Mon(c *rat, n int) PS{ - Z:=mkPS() - go func(c *rat, n int, Z PS){ - if(c.num!=0) { - for ; n>0; n=n-1 { put(zero,Z) } - put(c,Z) +func Mon(c *rat, n int) PS { + Z := mkPS() + go func(c *rat, n int, Z PS) { + if c.num != 0 { + for ; n > 0; n = n - 1 { + put(zero, Z) + } + put(c, Z) } - put(finis,Z) + put(finis, Z) }(c, n, Z) return Z } -func Shift(c *rat, U PS) PS{ +func Shift(c *rat, U PS) PS { Z := mkPS() - go func(c *rat, U, Z PS){ - put(c,Z) - copy(U,Z) + go func(c *rat, U, Z PS) { + put(c, Z) + copy(U, Z) }(c, U, Z) return Z } @@ -453,21 +470,21 @@ func Poly(a [] *rat) PS{ // let V = v + x*VV // then UV = u*v + x*(u*VV+v*UU) + x*x*UU*VV -func Mul(U, V PS) PS{ - Z:=mkPS() - go func(U, V, Z PS){ +func Mul(U, V PS) PS { + Z := mkPS() + go func(U, V, Z PS) { <-Z.req - uv := get2(U,V) - if end(uv[0].(*rat))!=0 || end(uv[1].(*rat)) != 0 { + uv := get2(U, V) + if end(uv[0].(*rat)) != 0 || end(uv[1].(*rat)) != 0 { Z.dat <- finis } else { - Z.dat <- mul(uv[0].(*rat),uv[1].(*rat)) + Z.dat <- mul(uv[0].(*rat), uv[1].(*rat)) UU := Split(U) VV := Split(V) - W := Add(Cmul(uv[0].(*rat),VV[0]),Cmul(uv[1].(*rat),UU[0])) + W := Add(Cmul(uv[0].(*rat), VV[0]), Cmul(uv[1].(*rat), UU[0])) <-Z.req Z.dat <- get(W) - copy(Add(W,Mul(UU[1],VV[1])),Z) + copy(Add(W, Mul(UU[1], VV[1])), Z) } }(U, V, Z) return Z @@ -475,19 +492,19 @@ func Mul(U, V PS) PS{ // Differentiate -func Diff(U PS) PS{ - Z:=mkPS() - go func(U, Z PS){ +func Diff(U PS) PS { + Z := mkPS() + go func(U, Z PS) { <-Z.req u := get(U) if end(u) == 0 { - done:=false - for i:=1; !done; i++ { + done := false + for i := 1; !done; i++ { u = get(U) if end(u) != 0 { - done=true + done = true } else { - Z.dat <- mul(itor(int64(i)),u) + Z.dat <- mul(itor(int64(i)), u) <-Z.req } } @@ -498,16 +515,18 @@ func Diff(U PS) PS{ } // Integrate, with const of integration -func Integ(c *rat,U PS) PS{ - Z:=mkPS() - go func(c *rat, U, Z PS){ - put(c,Z) - done:=false - for i:=1; !done; i++ { +func Integ(c *rat, U PS) PS { + Z := mkPS() + go func(c *rat, U, Z PS) { + put(c, Z) + done := false + for i := 1; !done; i++ { <-Z.req u := get(U) - if end(u) != 0 { done= true } - Z.dat <- mul(i2tor(1,int64(i)),u) + if end(u) != 0 { + done = true + } + Z.dat <- mul(i2tor(1, int64(i)), u) } Z.dat <- finis }(c, U, Z) @@ -516,18 +535,18 @@ func Integ(c *rat,U PS) PS{ // Binomial theorem (1+x)^c -func Binom(c *rat) PS{ - Z:=mkPS() - go func(c *rat, Z PS){ +func Binom(c *rat) PS { + Z := mkPS() + go func(c *rat, Z PS) { n := 1 t := itor(1) - for c.num!=0 { - put(t,Z) - t = mul(mul(t,c),i2tor(1,int64(n))) - c = sub(c,one) + for c.num != 0 { + put(t, Z) + t = mul(mul(t, c), i2tor(1, int64(n))) + c = sub(c, one) n++ } - put(finis,Z) + put(finis, Z) }(c, Z) return Z } @@ -540,15 +559,15 @@ func Binom(c *rat) PS{ // u*ZZ + z*UU +x*UU*ZZ = 0 // ZZ = -UU*(z+x*ZZ)/u -func Recip(U PS) PS{ - Z:=mkPS() - go func(U, Z PS){ - ZZ:=mkPS2() +func Recip(U PS) PS { + Z := mkPS() + go func(U, Z PS) { + ZZ := mkPS2() <-Z.req z := inv(get(U)) Z.dat <- z - split(Mul(Cmul(neg(z),U),Shift(z,ZZ[0])),ZZ) - copy(ZZ[1],Z) + split(Mul(Cmul(neg(z), U), Shift(z, ZZ[0])), ZZ) + copy(ZZ[1], Z) }(U, Z) return Z } @@ -560,9 +579,9 @@ func Recip(U PS) PS{ // DZ = Z*DU // integrate to get Z -func Exp(U PS) PS{ +func Exp(U PS) PS { ZZ := mkPS2() - split(Integ(one,Mul(ZZ[0],Diff(U))),ZZ) + split(Integ(one, Mul(ZZ[0], Diff(U))), ZZ) return ZZ[1] } @@ -573,7 +592,7 @@ func Exp(U PS) PS{ // bug: a nonzero constant term is ignored func Subst(U, V PS) PS { - Z:= mkPS() + Z := mkPS() go func(U, V, Z PS) { VV := Split(V) <-Z.req @@ -581,20 +600,20 @@ func Subst(U, V PS) PS { Z.dat <- u if end(u) == 0 { if end(get(VV[0])) != 0 { - put(finis,Z) + put(finis, Z) } else { - copy(Mul(VV[0],Subst(U,VV[1])),Z) + copy(Mul(VV[0], Subst(U, VV[1])), Z) } } }(U, V, Z) return Z } -// Monomial Substition: U(c x^n) +// Monomial Substitution: U(c x^n) // Each Ui is multiplied by c^i and followed by n-1 zeros func MonSubst(U PS, c0 *rat, n int) PS { - Z:= mkPS() + Z := mkPS() go func(U, Z PS, c0 *rat, n int) { c := one for { @@ -615,14 +634,13 @@ func MonSubst(U PS, c0 *rat, n int) PS { return Z } - func Init() { chnameserial = -1 seqno = 0 chnames = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" zero = itor(0) one = itor(1) - finis = i2tor(1,0) + finis = i2tor(1, 0) Ones = Rep(one) Twos = Rep(itor(2)) } @@ -641,7 +659,8 @@ func check(U PS, c *rat, count int, str string) { } } -const N=10 +const N = 10 + func checka(U PS, a []*rat, str string) { for i := 0; i < N; i++ { check(U, a[i], 1, str) @@ -650,53 +669,64 @@ func checka(U PS, a []*rat, str string) { func main() { Init() - if len(os.Args) > 1 { // print - print("Ones: "); Printn(Ones, 10) - print("Twos: "); Printn(Twos, 10) - print("Add: "); Printn(Add(Ones, Twos), 10) - print("Diff: "); Printn(Diff(Ones), 10) - print("Integ: "); Printn(Integ(zero, Ones), 10) - print("CMul: "); Printn(Cmul(neg(one), Ones), 10) - print("Sub: "); Printn(Sub(Ones, Twos), 10) - print("Mul: "); Printn(Mul(Ones, Ones), 10) - print("Exp: "); Printn(Exp(Ones), 15) - print("MonSubst: "); Printn(MonSubst(Ones, neg(one), 2), 10) - print("ATan: "); Printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) - } else { // test + if len(os.Args) > 1 { // print + print("Ones: ") + Printn(Ones, 10) + print("Twos: ") + Printn(Twos, 10) + print("Add: ") + Printn(Add(Ones, Twos), 10) + print("Diff: ") + Printn(Diff(Ones), 10) + print("Integ: ") + Printn(Integ(zero, Ones), 10) + print("CMul: ") + Printn(Cmul(neg(one), Ones), 10) + print("Sub: ") + Printn(Sub(Ones, Twos), 10) + print("Mul: ") + Printn(Mul(Ones, Ones), 10) + print("Exp: ") + Printn(Exp(Ones), 15) + print("MonSubst: ") + Printn(MonSubst(Ones, neg(one), 2), 10) + print("ATan: ") + Printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) + } else { // test check(Ones, one, 5, "Ones") - check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 + check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos") // 3 3 3 3 3 a := make([]*rat, N) d := Diff(Ones) - for i:=0; i < N; i++ { - a[i] = itor(int64(i+1)) + for i := 0; i < N; i++ { + a[i] = itor(int64(i + 1)) } - checka(d, a, "Diff") // 1 2 3 4 5 + checka(d, a, "Diff") // 1 2 3 4 5 in := Integ(zero, Ones) - a[0] = zero // integration constant - for i:=1; i < N; i++ { + a[0] = zero // integration constant + for i := 1; i < N; i++ { a[i] = i2tor(1, int64(i)) } - checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 - check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 - check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 + checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 + check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 + check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 m := Mul(Ones, Ones) - for i:=0; i < N; i++ { - a[i] = itor(int64(i+1)) + for i := 0; i < N; i++ { + a[i] = itor(int64(i + 1)) } - checka(m, a, "Mul") // 1 2 3 4 5 + checka(m, a, "Mul") // 1 2 3 4 5 e := Exp(Ones) a[0] = itor(1) a[1] = itor(1) - a[2] = i2tor(3,2) - a[3] = i2tor(13,6) - a[4] = i2tor(73,24) - a[5] = i2tor(167,40) - a[6] = i2tor(4051,720) - a[7] = i2tor(37633,5040) - a[8] = i2tor(43817,4480) - a[9] = i2tor(4596553,362880) - checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 + a[2] = i2tor(3, 2) + a[3] = i2tor(13, 6) + a[4] = i2tor(73, 24) + a[5] = i2tor(167, 40) + a[6] = i2tor(4051, 720) + a[7] = i2tor(37633, 5040) + a[8] = i2tor(43817, 4480) + a[9] = i2tor(4596553, 362880) + checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 at := Integ(zero, MonSubst(Ones, neg(one), 2)) for c, i := 1, 0; i < N; i++ { if i%2 == 0 { @@ -706,20 +736,20 @@ func main() { c *= -1 } } - checka(at, a, "ATan"); // 0 -1 0 -1/3 0 -1/5 -/* - t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) - a[0] = zero - a[1] = itor(1) - a[2] = zero - a[3] = i2tor(1,3) - a[4] = zero - a[5] = i2tor(2,15) - a[6] = zero - a[7] = i2tor(17,315) - a[8] = zero - a[9] = i2tor(62,2835) - checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 -*/ + checka(at, a, "ATan") // 0 -1 0 -1/3 0 -1/5 + /* + t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) + a[0] = zero + a[1] = itor(1) + a[2] = zero + a[3] = i2tor(1,3) + a[4] = zero + a[5] = i2tor(2,15) + a[6] = zero + a[7] = i2tor(17,315) + a[8] = zero + a[9] = i2tor(62,2835) + checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 + */ } } diff --git a/gcc/testsuite/go.test/test/chan/select2.go b/gcc/testsuite/go.test/test/chan/select2.go index ccf9dab81bc..31e27d75737 100644 --- a/gcc/testsuite/go.test/test/chan/select2.go +++ b/gcc/testsuite/go.test/test/chan/select2.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/chan/select3.go b/gcc/testsuite/go.test/test/chan/select3.go index 847d8ed37ed..dd14c7381ea 100644 --- a/gcc/testsuite/go.test/test/chan/select3.go +++ b/gcc/testsuite/go.test/test/chan/select3.go @@ -14,12 +14,10 @@ import "time" const always = "function did not" const never = "function did" - func unreachable() { panic("control flow shouldn't reach here") } - // Calls f and verifies that f always/never panics depending on signal. func testPanic(signal string, f func()) { defer func() { @@ -34,7 +32,6 @@ func testPanic(signal string, f func()) { f() } - // Calls f and empirically verifies that f always/never blocks depending on signal. func testBlock(signal string, f func()) { c := make(chan string) @@ -43,15 +40,21 @@ func testBlock(signal string, f func()) { c <- never // f didn't block }() go func() { - time.Sleep(1e8) // 0.1s seems plenty long - c <- always // f blocked always + if signal == never { + // Wait a long time to make sure that we don't miss our window by accident on a slow machine. + time.Sleep(10 * time.Second) + } else { + // Wait as short a time as we can without false negatives. + // 10ms should be long enough to catch most failures. + time.Sleep(10 * time.Millisecond) + } + c <- always // f blocked always }() if <-c != signal { panic(signal + " block") } } - func main() { const async = 1 // asynchronous channels var nilch chan int @@ -114,8 +117,7 @@ func main() { // empty selects always block testBlock(always, func() { - select { - } + select {} }) // selects with only nil channels always block diff --git a/gcc/testsuite/go.test/test/chan/select5.go b/gcc/testsuite/go.test/test/chan/select5.go index f72cfe4b461..8b98c3aaa2e 100644 --- a/gcc/testsuite/go.test/test/chan/select5.go +++ b/gcc/testsuite/go.test/test/chan/select5.go @@ -1,6 +1,6 @@ // runoutput -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -27,16 +27,16 @@ func main() { fmt.Fprintln(out, header) a := new(arg) - // Generate each kind of test as a separate function to avoid - // hitting the 6g optimizer with one enormous function. + // Generate each test as a separate function to avoid + // hitting the gc optimizer with one enormous function. // If we name all the functions init we don't have to // maintain a list of which ones to run. do := func(t *template.Template) { - fmt.Fprintln(out, `func init() {`) for ; next(); a.reset() { + fmt.Fprintln(out, `func init() {`) run(t, a, out) + fmt.Fprintln(out, `}`) } - fmt.Fprintln(out, `}`) } do(recv) diff --git a/gcc/testsuite/go.test/test/chan/select6.go b/gcc/testsuite/go.test/test/chan/select6.go index af470a0d0d1..6e8129f9477 100644 --- a/gcc/testsuite/go.test/test/chan/select6.go +++ b/gcc/testsuite/go.test/test/chan/select6.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/chan/select7.go b/gcc/testsuite/go.test/test/chan/select7.go index 20456a9d62e..f7222ca35d5 100644 --- a/gcc/testsuite/go.test/test/chan/select7.go +++ b/gcc/testsuite/go.test/test/chan/select7.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/chan/sendstmt.go b/gcc/testsuite/go.test/test/chan/sendstmt.go index a92c4f63a7a..d296a55cda1 100644 --- a/gcc/testsuite/go.test/test/chan/sendstmt.go +++ b/gcc/testsuite/go.test/test/chan/sendstmt.go @@ -1,11 +1,11 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. // Test various parsing cases that are a little -// different now that send is a statement, not a expression. +// different now that send is a statement, not an expression. package main @@ -30,7 +30,7 @@ func chanchan() { func sendprec() { c := make(chan bool, 1) - c <- false || true // not a syntax error: same as c <- (false || true) + c <- false || true // not a syntax error: same as c <- (false || true) if !<-c { panic("sent false") } diff --git a/gcc/testsuite/go.test/test/chancap.go b/gcc/testsuite/go.test/test/chancap.go index b3e40233f5b..8dce9247cd4 100644 --- a/gcc/testsuite/go.test/test/chancap.go +++ b/gcc/testsuite/go.test/test/chancap.go @@ -8,8 +8,17 @@ package main +import ( + "strings" + "unsafe" +) + +type T chan int + +const ptrSize = unsafe.Sizeof((*byte)(nil)) + func main() { - c := make(chan int, 10) + c := make(T, 10) if len(c) != 0 || cap(c) != 10 { println("chan len/cap ", len(c), cap(c), " want 0 10") panic("fail") @@ -23,9 +32,40 @@ func main() { panic("fail") } - c = make(chan int) + c = make(T) if len(c) != 0 || cap(c) != 0 { println("chan len/cap ", len(c), cap(c), " want 0 0") panic("fail") } + + n := -1 + shouldPanic("makechan: size out of range", func() { _ = make(T, n) }) + shouldPanic("makechan: size out of range", func() { _ = make(T, int64(n)) }) + if ptrSize == 8 { + // Test mem > maxAlloc + var n2 int64 = 1 << 59 + shouldPanic("makechan: size out of range", func() { _ = make(T, int(n2)) }) + // Test elem.size*cap overflow + n2 = 1<<63 - 1 + shouldPanic("makechan: size out of range", func() { _ = make(T, int(n2)) }) + } else { + n = 1<<31 - 1 + shouldPanic("makechan: size out of range", func() { _ = make(T, n) }) + shouldPanic("makechan: size out of range", func() { _ = make(T, int64(n)) }) + } +} + +func shouldPanic(str string, f func()) { + defer func() { + err := recover() + if err == nil { + panic("did not panic") + } + s := err.(error).Error() + if !strings.Contains(s, str) { + panic("got panic " + s + ", want " + str) + } + }() + + f() } diff --git a/gcc/testsuite/go.test/test/cmp.go b/gcc/testsuite/go.test/test/cmp.go index 73de502f39f..6db9ce5cc85 100644 --- a/gcc/testsuite/go.test/test/cmp.go +++ b/gcc/testsuite/go.test/test/cmp.go @@ -35,6 +35,10 @@ func istrue(b bool) { type T *int +type X int + +func (X) x() {} + func main() { var a []int var b map[string]int @@ -111,7 +115,7 @@ func main() { isfalse(ic != d) isfalse(ie != e) - // 6g used to let this go through as true. + // gc used to let this go through as true. var g uint64 = 123 var h int64 = 123 var ig interface{} = g @@ -129,6 +133,44 @@ func main() { panic("bad m[c]") } + // interface comparisons (issue 7207) + { + type I1 interface { + x() + } + type I2 interface { + x() + } + a1 := I1(X(0)) + b1 := I1(X(1)) + a2 := I2(X(0)) + b2 := I2(X(1)) + a3 := I1(a2) + a4 := I2(a1) + var e interface{} = X(0) + a5 := e.(I1) + a6 := e.(I2) + isfalse(a1 == b1) + isfalse(a1 == b2) + isfalse(a2 == b1) + isfalse(a2 == b2) + istrue(a1 == a2) + istrue(a1 == a3) + istrue(a1 == a4) + istrue(a1 == a5) + istrue(a1 == a6) + istrue(a2 == a3) + istrue(a2 == a4) + istrue(a2 == a5) + istrue(a2 == a6) + istrue(a3 == a4) + istrue(a3 == a5) + istrue(a3 == a6) + istrue(a4 == a5) + istrue(a4 == a6) + istrue(a5 == a6) + } + // non-interface comparisons { c := make(chan int) @@ -387,6 +429,23 @@ func main() { isfalse(iz != x) } + // named booleans + { + type mybool bool + var b mybool + + type T struct{ data [20]byte } + var x, y T + b = x == y + istrue(x == y) + istrue(bool(b)) + + m := make(map[string][10]interface{}) + b = m["x"] == m["y"] + istrue(m["x"] == m["y"]) + istrue(bool(b)) + } + shouldPanic(p1) shouldPanic(p2) shouldPanic(p3) diff --git a/gcc/testsuite/go.test/test/cmp6.go b/gcc/testsuite/go.test/test/cmp6.go index 839c274bcca..7cf76044ef9 100644 --- a/gcc/testsuite/go.test/test/cmp6.go +++ b/gcc/testsuite/go.test/test/cmp6.go @@ -18,7 +18,10 @@ type T3 struct{ z []int } var t3 T3 -type T4 struct { _ []int; a float64 } +type T4 struct { + _ []int + a float64 +} var t4 T4 @@ -51,6 +54,14 @@ func main() { use(p3 == p1) use(p3 == p2) + // Arrays are comparable if and only if their element type is comparable. + var a1 [1]int + var a2 [1]func() + var a3 [0]func() + use(a1 == a1) + use(a2 == a2) // ERROR "invalid operation|invalid comparison" + use(a3 == a3) // ERROR "invalid operation|invalid comparison" + // Comparison of structs should have a good message use(t3 == t3) // ERROR "struct|expected" use(t4 == t4) // ERROR "cannot be compared|non-comparable" diff --git a/gcc/testsuite/go.test/test/cmplx.go b/gcc/testsuite/go.test/test/cmplx.go index 2d8a6229d62..d63c7ebc7e8 100644 --- a/gcc/testsuite/go.test/test/cmplx.go +++ b/gcc/testsuite/go.test/test/cmplx.go @@ -28,6 +28,14 @@ var ( C128 Complex128 ) +func F1() int { + return 1 +} + +func F3() (int, int, int) { + return 1, 2, 3 +} + func main() { // ok c64 = complex(f32, f32) @@ -41,6 +49,11 @@ func main() { _ = complex(f64, F64) // ERROR "complex" _ = complex(F64, f64) // ERROR "complex" + _ = complex(F1()) // ERROR "not enough arguments" + _ = complex(F3()) // ERROR "too many arguments" + + _ = complex() // ERROR "not enough arguments" + c128 = complex(f32, f32) // ERROR "cannot use" c64 = complex(f64, f64) // ERROR "cannot use" @@ -51,4 +64,5 @@ func main() { C64 = complex(f32, f32) // ERROR "cannot use" C128 = complex(f64, f64) // ERROR "cannot use" + } diff --git a/gcc/testsuite/go.test/test/complit1.go b/gcc/testsuite/go.test/test/complit1.go index 521401d7393..7c2a4e2996d 100644 --- a/gcc/testsuite/go.test/test/complit1.go +++ b/gcc/testsuite/go.test/test/complit1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -22,6 +22,10 @@ var ( _ = m[0][:] // ERROR "slice of unaddressable value" _ = f()[:] // ERROR "slice of unaddressable value" + _ = 301[:] // ERROR "cannot slice|attempt to slice object that is not" + _ = 3.1[:] // ERROR "cannot slice|attempt to slice object that is not" + _ = true[:] // ERROR "cannot slice|attempt to slice object that is not" + // these are okay because they are slicing a pointer to an array _ = (&[3]int{1, 2, 3})[:] _ = mp[0][:] @@ -35,8 +39,27 @@ type T struct { next *T } +type TP *T +type Ti int + var ( _ = &T{0, 0, "", nil} // ok _ = &T{i: 0, f: 0, s: "", next: {}} // ERROR "missing type in composite literal|omit types within composite literal" _ = &T{0, 0, "", {}} // ERROR "missing type in composite literal|omit types within composite literal" + _ = TP{i: 0, f: 0, s: "", next: {}} // ERROR "invalid composite literal type TP|omit types within composite literal" + _ = &Ti{} // ERROR "invalid composite literal type Ti|expected.*type for composite literal" +) + +type M map[T]T + +var ( + _ = M{{i:1}: {i:2}} + _ = M{T{i:1}: {i:2}} + _ = M{{i:1}: T{i:2}} + _ = M{T{i:1}: T{i:2}} ) + +type S struct { s [1]*M1 } +type M1 map[S]int +var _ = M1{{s:[1]*M1{&M1{{}:1}}}:2} + diff --git a/gcc/testsuite/go.test/test/compos.go b/gcc/testsuite/go.test/test/compos.go index de688b39bb6..e6375f2697b 100644 --- a/gcc/testsuite/go.test/test/compos.go +++ b/gcc/testsuite/go.test/test/compos.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/const.go b/gcc/testsuite/go.test/test/const.go index d583659c6c3..f8aa1dd9ab6 100644 --- a/gcc/testsuite/go.test/test/const.go +++ b/gcc/testsuite/go.test/test/const.go @@ -19,8 +19,15 @@ const ( c3div2 = 3 / 2 c1e3 = 1e3 + rsh1 = 1e100 >> 1000 + rsh2 = 1e302 >> 1000 + ctrue = true cfalse = !ctrue + + // Issue #34563 + _ = string(int(123)) + _ = string(rune(456)) ) const ( @@ -48,6 +55,8 @@ func ints() { assert(c3div2 == 1, "3/2") assert(c1e3 == 1000, "c1e3 int") assert(c1e3 == 1e3, "c1e3 float") + assert(rsh1 == 0, "rsh1") + assert(rsh2 == 9, "rsh2") // verify that all (in range) are assignable as ints var i int @@ -118,9 +127,83 @@ func floats() { assert(f == f1e3, "f == f1e3") } +func interfaces() { + var ( + nilN interface{} + nilI *int + five = 5 + + _ = nil == interface{}(nil) + _ = interface{}(nil) == nil + ) + ii := func(i1 interface{}, i2 interface{}) bool { return i1 == i2 } + ni := func(n interface{}, i int) bool { return n == i } + in := func(i int, n interface{}) bool { return i == n } + pi := func(p *int, i interface{}) bool { return p == i } + ip := func(i interface{}, p *int) bool { return i == p } + + assert((interface{}(nil) == interface{}(nil)) == ii(nilN, nilN), + "for interface{}==interface{} compiler == runtime") + + assert(((*int)(nil) == interface{}(nil)) == pi(nilI, nilN), + "for *int==interface{} compiler == runtime") + assert((interface{}(nil) == (*int)(nil)) == ip(nilN, nilI), + "for interface{}==*int compiler == runtime") + + assert((&five == interface{}(nil)) == pi(&five, nilN), + "for interface{}==*int compiler == runtime") + assert((interface{}(nil) == &five) == ip(nilN, &five), + "for interface{}==*int compiler == runtime") + + assert((5 == interface{}(5)) == ni(five, five), + "for int==interface{} compiler == runtime") + assert((interface{}(5) == 5) == in(five, five), + "for interface{}==int comipiler == runtime") +} + +// Test that typed floating-point and complex arithmetic +// is computed with correct precision. +func truncate() { + const ( + x30 = 1 << 30 + x60 = 1 << 60 + + staticF32 = float32(x30) + 1 - x30 + staticF64 = float64(x60) + 1 - x60 + staticC64 = complex64(x30) + 1 - x30 + staticC128 = complex128(x60) + 1 - x60 + ) + dynamicF32 := float32(x30) + dynamicF32 += 1 + dynamicF32 -= x30 + + dynamicF64 := float64(x60) + dynamicF64 += 1 + dynamicF64 -= x60 + + dynamicC64 := complex64(x30) + dynamicC64 += 1 + dynamicC64 -= x30 + + dynamicC128 := complex128(x60) + dynamicC128 += 1 + dynamicC128 -= x60 + + assert(staticF32 == 0, "staticF32 == 0") + assert(staticF64 == 0, "staticF64 == 0") + assert(dynamicF32 == 0, "dynamicF32 == 0") + assert(dynamicF64 == 0, "dynamicF64 == 0") + assert(staticC64 == 0, "staticC64 == 0") + assert(staticC128 == 0, "staticC128 == 0") + assert(dynamicC64 == 0, "dynamicC64 == 0") + assert(dynamicC128 == 0, "dynamicC128 == 0") +} + func main() { ints() floats() + interfaces() + truncate() assert(ctrue == true, "ctrue == true") assert(cfalse == false, "cfalse == false") diff --git a/gcc/testsuite/go.test/test/const1.go b/gcc/testsuite/go.test/test/const1.go index 58bddee7e07..3fd5b55522f 100644 --- a/gcc/testsuite/go.test/test/const1.go +++ b/gcc/testsuite/go.test/test/const1.go @@ -68,7 +68,7 @@ var ( c3 float64 = float64(Big) * Big // ERROR "overflow" c4 = Big * Big // ERROR "overflow" c5 = Big / 0 // ERROR "division by zero" - c6 = 1000 % 1e3 // ERROR "floating-point % operation|expected integer type" + c6 = 1000 % 1e3 // ERROR "invalid operation|expected integer type" ) func f(int) @@ -90,5 +90,5 @@ func main() { const ptr = nil // ERROR "const.*nil" const _ = string([]byte(nil)) // ERROR "is not a? ?constant" const _ = uintptr(unsafe.Pointer((*int)(nil))) // ERROR "is not a? ?constant" -const _ = unsafe.Pointer((*int)(nil)) // ERROR "cannot be nil|invalid constant type" -const _ = (*int)(nil) // ERROR "cannot be nil|invalid constant type" +const _ = unsafe.Pointer((*int)(nil)) // ERROR "cannot be nil|invalid constant type|is not a constant" +const _ = (*int)(nil) // ERROR "cannot be nil|invalid constant type|is not a constant" diff --git a/gcc/testsuite/go.test/test/const4.go b/gcc/testsuite/go.test/test/const4.go index 2fb2d0664e8..785e1ec04d2 100644 --- a/gcc/testsuite/go.test/test/const4.go +++ b/gcc/testsuite/go.test/test/const4.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Test len constants and non-constants, http://golang.org/issue/3244. +// Test len constants and non-constants, https://golang.org/issue/3244. package main diff --git a/gcc/testsuite/go.test/test/const5.go b/gcc/testsuite/go.test/test/const5.go index 87fe33a3855..51e46cbb2fd 100644 --- a/gcc/testsuite/go.test/test/const5.go +++ b/gcc/testsuite/go.test/test/const5.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Test that len non-constants are not constants, http://golang.org/issue/3244. +// Test that len non-constants are not constants, https://golang.org/issue/3244. package p @@ -18,6 +18,7 @@ var s [][30]int func f() *[40]int var c chan *[50]int +var z complex128 const ( n1 = len(b.a) @@ -29,5 +30,8 @@ const ( n6 = cap(f()) // ERROR "is not a constant|is not constant" n7 = cap(<-c) // ERROR "is not a constant|is not constant" + n8 = real(z) // ERROR "is not a constant|is not constant" + n9 = len([4]float64{real(z)}) // ERROR "is not a constant|is not constant" + ) diff --git a/gcc/testsuite/go.test/test/const6.go b/gcc/testsuite/go.test/test/const6.go index c005ac3696d..b340e589d5e 100644 --- a/gcc/testsuite/go.test/test/const6.go +++ b/gcc/testsuite/go.test/test/const6.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/convert1.go b/gcc/testsuite/go.test/test/convert1.go index 0f417a33804..afb63cd55a1 100644 --- a/gcc/testsuite/go.test/test/convert1.go +++ b/gcc/testsuite/go.test/test/convert1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/convlit.go b/gcc/testsuite/go.test/test/convlit.go index 8a6145d2a0b..1c66c89e880 100644 --- a/gcc/testsuite/go.test/test/convlit.go +++ b/gcc/testsuite/go.test/test/convlit.go @@ -9,6 +9,8 @@ package main +import "unsafe" + // explicit conversion of constants var x1 = string(1) var x2 string = string(1) @@ -18,11 +20,16 @@ var x5 = "a" + string(1) var x6 = int(1e100) // ERROR "overflow" var x7 = float32(1e1000) // ERROR "overflow" +// unsafe.Pointer can only convert to/from uintptr +var _ = string(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion" +var _ = float64(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion" +var _ = int(unsafe.Pointer(uintptr(65))) // ERROR "convert|conversion" + // implicit conversions merit scrutiny var s string var bad1 string = 1 // ERROR "conver|incompatible|invalid|cannot" -var bad2 = s + 1 // ERROR "conver|incompatible|invalid" -var bad3 = s + 'a' // ERROR "conver|incompatible|invalid" +var bad2 = s + 1 // ERROR "conver|incompatible|invalid|cannot" +var bad3 = s + 'a' // ERROR "conver|incompatible|invalid|cannot" var bad4 = "a" + 1 // ERROR "literals|incompatible|convert|invalid" var bad5 = "a" + 'a' // ERROR "literals|incompatible|convert|invalid" diff --git a/gcc/testsuite/go.test/test/ddd.go b/gcc/testsuite/go.test/test/ddd.go index 01768b89f3b..84503f7d5b1 100644 --- a/gcc/testsuite/go.test/test/ddd.go +++ b/gcc/testsuite/go.test/test/ddd.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/ddd1.go b/gcc/testsuite/go.test/test/ddd1.go index 07981af126a..01b9c0eadb2 100644 --- a/gcc/testsuite/go.test/test/ddd1.go +++ b/gcc/testsuite/go.test/test/ddd1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -18,8 +18,8 @@ var ( _ = sum() _ = sum(1.0, 2.0) _ = sum(1.5) // ERROR "integer" - _ = sum("hello") // ERROR ".hello. .type string. as type int|incompatible" - _ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible" + _ = sum("hello") // ERROR ".hello. .type untyped string. as type int|incompatible" + _ = sum([]int{1}) // ERROR "\[\]int{...}.*as type int|incompatible" ) func sum3(int, int, int) int { return 0 } @@ -27,9 +27,9 @@ func tuple() (int, int, int) { return 1, 2, 3 } var ( _ = sum(tuple()) - _ = sum(tuple()...) // ERROR "multiple-value|[.][.][.]" + _ = sum(tuple()...) // ERROR "multiple-value" _ = sum3(tuple()) - _ = sum3(tuple()...) // ERROR "multiple-value|[.][.][.]" "not enough" + _ = sum3(tuple()...) // ERROR "multiple-value" ) type T []T @@ -42,6 +42,8 @@ var ( _ = funny([]T{}) // ok because []T{} is a T; passes []T{[]T{}} ) +func Foo(n int) {} + func bad(args ...int) { print(1, 2, args...) // ERROR "[.][.][.]" println(args...) // ERROR "[.][.][.]" @@ -51,12 +53,12 @@ func bad(args ...int) { _ = new(int...) // ERROR "[.][.][.]" n := 10 _ = make([]byte, n...) // ERROR "[.][.][.]" - // TODO(rsc): enable after gofmt bug is fixed - // _ = make([]byte, 10 ...) // error "[.][.][.]" + _ = make([]byte, 10 ...) // ERROR "[.][.][.]" var x int _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]" _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]" _ = [...]byte("foo") // ERROR "[.][.][.]" _ = [...][...]int{{1,2,3},{4,5,6}} // ERROR "[.][.][.]" -} + Foo(x...) // ERROR "invalid use of .*[.][.][.]" +} diff --git a/gcc/testsuite/go.test/test/ddd2.dir/ddd2.go b/gcc/testsuite/go.test/test/ddd2.dir/ddd2.go index c9a26759260..f3f863c83f1 100644 --- a/gcc/testsuite/go.test/test/ddd2.dir/ddd2.go +++ b/gcc/testsuite/go.test/test/ddd2.dir/ddd2.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/ddd2.dir/ddd3.go b/gcc/testsuite/go.test/test/ddd2.dir/ddd3.go index 5486fe8a049..608091dd9b6 100644 --- a/gcc/testsuite/go.test/test/ddd2.dir/ddd3.go +++ b/gcc/testsuite/go.test/test/ddd2.dir/ddd3.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/ddd2.go b/gcc/testsuite/go.test/test/ddd2.go index 0d9f634ab60..612ba292c2e 100644 --- a/gcc/testsuite/go.test/test/ddd2.go +++ b/gcc/testsuite/go.test/test/ddd2.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/deferprint.go b/gcc/testsuite/go.test/test/deferprint.go index 72c98b19fc9..b74677ac59c 100644 --- a/gcc/testsuite/go.test/test/deferprint.go +++ b/gcc/testsuite/go.test/test/deferprint.go @@ -1,6 +1,6 @@ -// cmpout +// run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/divide.go b/gcc/testsuite/go.test/test/divide.go index b20f1062f62..b5570415c24 100644 --- a/gcc/testsuite/go.test/test/divide.go +++ b/gcc/testsuite/go.test/test/divide.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/divmod.go b/gcc/testsuite/go.test/test/divmod.go index 49fed0222c6..ab85b7f1492 100644 --- a/gcc/testsuite/go.test/test/divmod.go +++ b/gcc/testsuite/go.test/test/divmod.go @@ -1,12 +1,12 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. // Test division of variables. Generate many test cases, // compute correct answer using shift and subtract, -// and then compare against results from divison and +// and then compare against results from division and // modulus operators. // // Primarily useful for testing software div/mod. diff --git a/gcc/testsuite/go.test/test/eof.go b/gcc/testsuite/go.test/test/eof.go index 06c779046b6..d051f33bf79 100644 --- a/gcc/testsuite/go.test/test/eof.go +++ b/gcc/testsuite/go.test/test/eof.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/eof1.go b/gcc/testsuite/go.test/test/eof1.go index 2105b89080b..90792ca76e1 100644 --- a/gcc/testsuite/go.test/test/eof1.go +++ b/gcc/testsuite/go.test/test/eof1.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/errchk b/gcc/testsuite/go.test/test/errchk deleted file mode 100755 index de0c4fd2f87..00000000000 --- a/gcc/testsuite/go.test/test/errchk +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env perl -# Copyright 2009 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 script checks that the compilers emit the errors which we expect. -# Usage: errchk COMPILER [OPTS] SOURCEFILES. This will run the command -# COMPILER [OPTS] SOURCEFILES. The compilation is expected to fail; if -# it succeeds, this script will report an error. The stderr output of -# the compiler will be matched against comments in SOURCEFILES. For each -# line of the source files which should generate an error, there should -# be a comment of the form // ERROR "regexp". If the compiler generates -# an error for a line which has no such comment, this script will report -# an error. Likewise if the compiler does not generate an error for a -# line which has a comment, or if the error message does not match the -# . The syntax is Perl but its best to stick to egrep. - -use POSIX; - -my $exitcode = 1; - -if(@ARGV >= 1 && $ARGV[0] eq "-0") { - $exitcode = 0; - shift; -} - -if(@ARGV < 1) { - print STDERR "Usage: errchk COMPILER [OPTS] SOURCEFILES\n"; - exit 1; -} - -# Grab SOURCEFILES -foreach(reverse 0 .. @ARGV-1) { - unless($ARGV[$_] =~ /\.(go|s)$/) { - @file = @ARGV[$_+1 .. @ARGV-1]; - last; - } -} - -foreach $file (@file) { - open(SRC, $file) || die "BUG: errchk: open $file: $!"; - $src{$file} = []; - close(SRC); -} - -# Run command -$cmd = join(' ', @ARGV); -open(CMD, "exec $cmd &1 |") || die "BUG: errchk: run $cmd: $!"; - -# 6g error messages continue onto additional lines with leading tabs. -# Split the output at the beginning of each line that doesn't begin with a tab. -$out = join('', ); -@out = split(/^(?!\t)/m, $out); - -close CMD; - -if($exitcode != 0 && $? == 0) { - print STDERR "BUG: errchk: command succeeded unexpectedly\n"; - print STDERR @out; - exit 0; -} - -if($exitcode == 0 && $? != 0) { - print STDERR "BUG: errchk: command failed unexpectedly\n"; - print STDERR @out; - exit 0; -} - -if(!WIFEXITED($?)) { - print STDERR "BUG: errchk: compiler crashed\n"; - print STDERR @out, "\n"; - exit 0; -} - -sub bug() { - if(!$bug++) { - print STDERR "BUG: "; - } -} - -sub chk { - my $file = shift; - my $line = 0; - my $regexp; - my @errmsg; - my @match; - foreach my $src (@{$src{$file}}) { - $line++; - next if $src =~ m|////|; # double comment disables ERROR - next unless $src =~ m|// (GC_)?ERROR (.*)|; - my $all = $2; - if($all !~ /^"([^"]*)"/) { - print STDERR "$file:$line: malformed regexp\n"; - next; - } - @errmsg = grep { /$file:$line[:[]/ } @out; - @out = grep { !/$file:$line[:[]/ } @out; - if(@errmsg == 0) { - bug(); - print STDERR "errchk: $file:$line: missing expected error: '$all'\n"; - next; - } - foreach my $regexp ($all =~ /"([^"]*)"/g) { - # Turn relative line number in message into absolute line number. - if($regexp =~ /LINE(([+-])([0-9]+))?/) { - my $n = $line; - if(defined($1)) { - if($2 eq "+") { - $n += int($3); - } else { - $n -= int($3); - } - } - $regexp = "$`$file:$n$'"; - } - - @match = grep { /$regexp/ } @errmsg; - if(@match == 0) { - bug(); - print STDERR "errchk: $file:$line: error messages do not match '$regexp'\n"; - next; - } - @errmsg = grep { !/$regexp/ } @errmsg; - } - if(@errmsg != 0) { - bug(); - print STDERR "errchk: $file:$line: unmatched error messages:\n"; - foreach my $l (@errmsg) { - print STDERR "> $l"; - } - } - } -} - -foreach $file (@file) { - chk($file) -} - -if(@out != 0) { - bug(); - print STDERR "errchk: unmatched error messages:\n"; - print STDERR "==================================================\n"; - print STDERR @out; - print STDERR "==================================================\n"; -} - -exit 0; diff --git a/gcc/testsuite/go.test/test/escape2.go b/gcc/testsuite/go.test/test/escape2.go index be89c2d8408..5c6eb559faf 100644 --- a/gcc/testsuite/go.test/test/escape2.go +++ b/gcc/testsuite/go.test/test/escape2.go @@ -1,12 +1,14 @@ // errorcheck -0 -m -l -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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, using compiler diagnostic flags, that the escape analysis is working. // Compiles but does not run. Inlining is disabled. +// escape2n.go contains all the same tests but compiles with -N. + package foo import ( @@ -16,94 +18,94 @@ import ( var gxx *int -func foo1(x int) { // ERROR "moved to heap: x" - gxx = &x // ERROR "&x escapes to heap" +func foo1(x int) { // ERROR "moved to heap: x$" + gxx = &x } -func foo2(yy *int) { // ERROR "leaking param: yy" +func foo2(yy *int) { // ERROR "leaking param: yy$" gxx = yy } -func foo3(x int) *int { // ERROR "moved to heap: x" - return &x // ERROR "&x escapes to heap" +func foo3(x int) *int { // ERROR "moved to heap: x$" + return &x } type T *T -func foo3b(t T) { // ERROR "leaking param: t" +func foo3b(t T) { // ERROR "leaking param: t$" *t = t } // xx isn't going anywhere, so use of yy is ok -func foo4(xx, yy *int) { // ERROR "xx does not escape" "yy does not escape" +func foo4(xx, yy *int) { // ERROR "xx does not escape$" "yy does not escape$" xx = yy } // xx isn't going anywhere, so taking address of yy is ok -func foo5(xx **int, yy *int) { // ERROR "xx does not escape" "yy does not escape" - xx = &yy // ERROR "&yy does not escape" +func foo5(xx **int, yy *int) { // ERROR "xx does not escape$" "yy does not escape$" + xx = &yy } -func foo6(xx **int, yy *int) { // ERROR "xx does not escape" "leaking param: yy" +func foo6(xx **int, yy *int) { // ERROR "xx does not escape$" "leaking param: yy$" *xx = yy } -func foo7(xx **int, yy *int) { // ERROR "xx does not escape" "yy does not escape" +func foo7(xx **int, yy *int) { // ERROR "xx does not escape$" "yy does not escape$" **xx = *yy } -func foo8(xx, yy *int) int { // ERROR "xx does not escape" "yy does not escape" +func foo8(xx, yy *int) int { // ERROR "xx does not escape$" "yy does not escape$" xx = yy return *xx } -func foo9(xx, yy *int) *int { // ERROR "leaking param: xx" "leaking param: yy" +func foo9(xx, yy *int) *int { // ERROR "leaking param: xx to result ~r2 level=0$" "leaking param: yy to result ~r2 level=0$" xx = yy return xx } -func foo10(xx, yy *int) { // ERROR "xx does not escape" "yy does not escape" +func foo10(xx, yy *int) { // ERROR "xx does not escape$" "yy does not escape$" *xx = *yy } func foo11() int { x, y := 0, 42 - xx := &x // ERROR "&x does not escape" - yy := &y // ERROR "&y does not escape" + xx := &x + yy := &y *xx = *yy return x } var xxx **int -func foo12(yyy **int) { // ERROR "leaking param: yyy" +func foo12(yyy **int) { // ERROR "leaking param: yyy$" xxx = yyy } -// Must treat yyy as leaking because *yyy leaks, and the escape analysis +// Must treat yyy as leaking because *yyy leaks, and the escape analysis // summaries in exported metadata do not distinguish these two cases. -func foo13(yyy **int) { // ERROR "leaking param: yyy" +func foo13(yyy **int) { // ERROR "leaking param content: yyy$" *xxx = *yyy } -func foo14(yyy **int) { // ERROR "yyy does not escape" +func foo14(yyy **int) { // ERROR "yyy does not escape$" **xxx = **yyy } -func foo15(yy *int) { // ERROR "moved to heap: yy" - xxx = &yy // ERROR "&yy escapes to heap" +func foo15(yy *int) { // ERROR "moved to heap: yy$" + xxx = &yy } -func foo16(yy *int) { // ERROR "leaking param: yy" +func foo16(yy *int) { // ERROR "leaking param: yy$" *xxx = yy } -func foo17(yy *int) { // ERROR "yy does not escape" +func foo17(yy *int) { // ERROR "yy does not escape$" **xxx = *yy } -func foo18(y int) { // ERROR "moved to heap: "y" - *xxx = &y // ERROR "&y escapes to heap" +func foo18(y int) { // ERROR "moved to heap: y$" + *xxx = &y } func foo19(y int) { @@ -116,52 +118,52 @@ type Bar struct { } func NewBar() *Bar { - return &Bar{42, nil} // ERROR "&Bar literal escapes to heap" + return &Bar{42, nil} // ERROR "&Bar{...} escapes to heap$" } -func NewBarp(x *int) *Bar { // ERROR "leaking param: x" - return &Bar{42, x} // ERROR "&Bar literal escapes to heap" +func NewBarp(x *int) *Bar { // ERROR "leaking param: x$" + return &Bar{42, x} // ERROR "&Bar{...} escapes to heap$" } -func NewBarp2(x *int) *Bar { // ERROR "x does not escape" - return &Bar{*x, nil} // ERROR "&Bar literal escapes to heap" +func NewBarp2(x *int) *Bar { // ERROR "x does not escape$" + return &Bar{*x, nil} // ERROR "&Bar{...} escapes to heap$" } -func (b *Bar) NoLeak() int { // ERROR "b does not escape" +func (b *Bar) NoLeak() int { // ERROR "b does not escape$" return *(b.ii) } -func (b *Bar) Leak() *int { // ERROR "leaking param: b" - return &b.i // ERROR "&b.i escapes to heap" +func (b *Bar) Leak() *int { // ERROR "leaking param: b to result ~r0 level=0$" + return &b.i } -func (b *Bar) AlsoNoLeak() *int { // ERROR "b does not escape" +func (b *Bar) AlsoNoLeak() *int { // ERROR "leaking param: b to result ~r0 level=1$" return b.ii } -func (b Bar) AlsoLeak() *int { // ERROR "leaking param: b" +func (b Bar) AlsoLeak() *int { // ERROR "leaking param: b to result ~r0 level=0$" return b.ii } -func (b Bar) LeaksToo() *int { // ERROR "leaking param: b" - v := 0 // ERROR "moved to heap: v" - b.ii = &v // ERROR "&v escapes" +func (b Bar) LeaksToo() *int { // ERROR "leaking param: b to result ~r0 level=0$" + v := 0 // ERROR "moved to heap: v$" + b.ii = &v return b.ii } -func (b *Bar) LeaksABit() *int { // ERROR "b does not escape" - v := 0 // ERROR "moved to heap: v" - b.ii = &v // ERROR "&v escapes" +func (b *Bar) LeaksABit() *int { // ERROR "leaking param: b to result ~r0 level=1$" + v := 0 // ERROR "moved to heap: v$" + b.ii = &v return b.ii } -func (b Bar) StillNoLeak() int { // ERROR "b does not escape" +func (b Bar) StillNoLeak() int { // ERROR "b does not escape$" v := 0 - b.ii = &v // ERROR "&v does not escape" + b.ii = &v return b.i } -func goLeak(b *Bar) { // ERROR "leaking param: b" +func goLeak(b *Bar) { // ERROR "leaking param: b$" go b.NoLeak() } @@ -171,90 +173,105 @@ type Bar2 struct { } func NewBar2() *Bar2 { - return &Bar2{[12]int{42}, nil} // ERROR "&Bar2 literal escapes to heap" + return &Bar2{[12]int{42}, nil} // ERROR "&Bar2{...} escapes to heap$" } -func (b *Bar2) NoLeak() int { // ERROR "b does not escape" +func (b *Bar2) NoLeak() int { // ERROR "b does not escape$" return b.i[0] } -func (b *Bar2) Leak() []int { // ERROR "leaking param: b" - return b.i[:] // ERROR "b.i escapes to heap" +func (b *Bar2) Leak() []int { // ERROR "leaking param: b to result ~r0 level=0$" + return b.i[:] } -func (b *Bar2) AlsoNoLeak() []int { // ERROR "b does not escape" +func (b *Bar2) AlsoNoLeak() []int { // ERROR "leaking param: b to result ~r0 level=1$" return b.ii[0:1] } -func (b Bar2) AgainNoLeak() [12]int { // ERROR "b does not escape" +func (b Bar2) AgainNoLeak() [12]int { // ERROR "b does not escape$" return b.i } -func (b *Bar2) LeakSelf() { // ERROR "leaking param: b" - b.ii = b.i[0:4] // ERROR "b.i escapes to heap" +func (b *Bar2) LeakSelf() { // ERROR "leaking param: b$" + b.ii = b.i[0:4] } -func (b *Bar2) LeakSelf2() { // ERROR "leaking param: b" +func (b *Bar2) LeakSelf2() { // ERROR "leaking param: b$" var buf []int - buf = b.i[0:] // ERROR "b.i escapes to heap" + buf = b.i[0:] b.ii = buf } func foo21() func() int { - x := 42 // ERROR "moved to heap: x" - return func() int { // ERROR "func literal escapes to heap" - return x // ERROR "&x escapes to heap" + x := 42 + return func() int { // ERROR "func literal escapes to heap$" + return x + } +} + +func foo21a() func() int { + x := 42 // ERROR "moved to heap: x$" + return func() int { // ERROR "func literal escapes to heap$" + x++ + return x } } func foo22() int { x := 42 - return func() int { // ERROR "func literal does not escape" + return func() int { // ERROR "func literal does not escape$" return x }() } -func foo23(x int) func() int { // ERROR "moved to heap: x" - return func() int { // ERROR "func literal escapes to heap" - return x // ERROR "&x escapes to heap" +func foo23(x int) func() int { + return func() int { // ERROR "func literal escapes to heap$" + return x } } -func foo23a(x int) func() int { // ERROR "moved to heap: x" - f := func() int { // ERROR "func literal escapes to heap" - return x // ERROR "&x escapes to heap" +func foo23a(x int) func() int { + f := func() int { // ERROR "func literal escapes to heap$" + return x } return f } -func foo23b(x int) *(func() int) { // ERROR "moved to heap: x" - f := func() int { return x } // ERROR "moved to heap: f" "func literal escapes to heap" "&x escapes to heap" - return &f // ERROR "&f escapes to heap" +func foo23b(x int) *(func() int) { + f := func() int { return x } // ERROR "func literal escapes to heap$" "moved to heap: f$" + return &f +} + +func foo23c(x int) func() int { // ERROR "moved to heap: x$" + return func() int { // ERROR "func literal escapes to heap$" + x++ + return x + } } func foo24(x int) int { - return func() int { // ERROR "func literal does not escape" + return func() int { // ERROR "func literal does not escape$" return x }() } var x *int -func fooleak(xx *int) int { // ERROR "leaking param: xx" +func fooleak(xx *int) int { // ERROR "leaking param: xx$" x = xx return *x } -func foonoleak(xx *int) int { // ERROR "xx does not escape" +func foonoleak(xx *int) int { // ERROR "xx does not escape$" return *x + *xx } -func foo31(x int) int { // ERROR "moved to heap: x" - return fooleak(&x) // ERROR "&x escapes to heap" +func foo31(x int) int { // ERROR "moved to heap: x$" + return fooleak(&x) } func foo32(x int) int { - return foonoleak(&x) // ERROR "&x does not escape" + return foonoleak(&x) } type Foo struct { @@ -265,114 +282,114 @@ type Foo struct { var F Foo var pf *Foo -func (f *Foo) fooleak() { // ERROR "leaking param: f" +func (f *Foo) fooleak() { // ERROR "leaking param: f$" pf = f } -func (f *Foo) foonoleak() { // ERROR "f does not escape" +func (f *Foo) foonoleak() { // ERROR "f does not escape$" F.x = f.x } -func (f *Foo) Leak() { // ERROR "leaking param: f" +func (f *Foo) Leak() { // ERROR "leaking param: f$" f.fooleak() } -func (f *Foo) NoLeak() { // ERROR "f does not escape" +func (f *Foo) NoLeak() { // ERROR "f does not escape$" f.foonoleak() } -func foo41(x int) { // ERROR "moved to heap: x" - F.xx = &x // ERROR "&x escapes to heap" +func foo41(x int) { // ERROR "moved to heap: x$" + F.xx = &x } -func (f *Foo) foo42(x int) { // ERROR "f does not escape" "moved to heap: x" - f.xx = &x // ERROR "&x escapes to heap" +func (f *Foo) foo42(x int) { // ERROR "f does not escape$" "moved to heap: x$" + f.xx = &x } -func foo43(f *Foo, x int) { // ERROR "f does not escape" "moved to heap: x" - f.xx = &x // ERROR "&x escapes to heap" +func foo43(f *Foo, x int) { // ERROR "f does not escape$" "moved to heap: x$" + f.xx = &x } -func foo44(yy *int) { // ERROR "leaking param: yy" +func foo44(yy *int) { // ERROR "leaking param: yy$" F.xx = yy } -func (f *Foo) foo45() { // ERROR "f does not escape" +func (f *Foo) foo45() { // ERROR "f does not escape$" F.x = f.x } // See foo13 above for explanation of why f leaks. -func (f *Foo) foo46() { // ERROR "leaking param: f" +func (f *Foo) foo46() { // ERROR "leaking param content: f$" F.xx = f.xx } -func (f *Foo) foo47() { // ERROR "leaking param: f" - f.xx = &f.x // ERROR "&f.x escapes to heap" +func (f *Foo) foo47() { // ERROR "leaking param: f$" + f.xx = &f.x } var ptrSlice []*int -func foo50(i *int) { // ERROR "leaking param: i" +func foo50(i *int) { // ERROR "leaking param: i$" ptrSlice[0] = i } var ptrMap map[*int]*int -func foo51(i *int) { // ERROR "leaking param: i" +func foo51(i *int) { // ERROR "leaking param: i$" ptrMap[i] = i } -func indaddr1(x int) *int { // ERROR "moved to heap: x" - return &x // ERROR "&x escapes to heap" +func indaddr1(x int) *int { // ERROR "moved to heap: x$" + return &x } -func indaddr2(x *int) *int { // ERROR "leaking param: x" - return *&x // ERROR "&x does not escape" +func indaddr2(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$" + return *&x } -func indaddr3(x *int32) *int { // ERROR "leaking param: x" - return *(**int)(unsafe.Pointer(&x)) // ERROR "&x does not escape" +func indaddr3(x *int32) *int { // ERROR "leaking param: x to result ~r1 level=0$" + return *(**int)(unsafe.Pointer(&x)) } // From package math: func Float32bits(f float32) uint32 { - return *(*uint32)(unsafe.Pointer(&f)) // ERROR "&f does not escape" + return *(*uint32)(unsafe.Pointer(&f)) } func Float32frombits(b uint32) float32 { - return *(*float32)(unsafe.Pointer(&b)) // ERROR "&b does not escape" + return *(*float32)(unsafe.Pointer(&b)) } func Float64bits(f float64) uint64 { - return *(*uint64)(unsafe.Pointer(&f)) // ERROR "&f does not escape" + return *(*uint64)(unsafe.Pointer(&f)) } func Float64frombits(b uint64) float64 { - return *(*float64)(unsafe.Pointer(&b)) // ERROR "&b does not escape" + return *(*float64)(unsafe.Pointer(&b)) } // contrast with -func float64bitsptr(f float64) *uint64 { // ERROR "moved to heap: f" - return (*uint64)(unsafe.Pointer(&f)) // ERROR "&f escapes to heap" +func float64bitsptr(f float64) *uint64 { // ERROR "moved to heap: f$" + return (*uint64)(unsafe.Pointer(&f)) } -func float64ptrbitsptr(f *float64) *uint64 { // ERROR "leaking param: f" +func float64ptrbitsptr(f *float64) *uint64 { // ERROR "leaking param: f to result ~r1 level=0$" return (*uint64)(unsafe.Pointer(f)) } -func typesw(i interface{}) *int { // ERROR "leaking param: i" +func typesw(i interface{}) *int { // ERROR "leaking param: i to result ~r1 level=0$" switch val := i.(type) { case *int: return val case *int8: - v := int(*val) // ERROR "moved to heap: v" - return &v // ERROR "&v escapes to heap" + v := int(*val) // ERROR "moved to heap: v$" + return &v } return nil } -func exprsw(i *int) *int { // ERROR "leaking param: i" +func exprsw(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$" switch j := i; *j + 110 { case 12: return j @@ -384,20 +401,20 @@ func exprsw(i *int) *int { // ERROR "leaking param: i" } // assigning to an array element is like assigning to the array -func foo60(i *int) *int { // ERROR "leaking param: i" +func foo60(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$" var a [12]*int a[0] = i return a[1] } -func foo60a(i *int) *int { // ERROR "i does not escape" +func foo60a(i *int) *int { // ERROR "i does not escape$" var a [12]*int a[0] = i return nil } // assigning to a struct field is like assigning to the struct -func foo61(i *int) *int { // ERROR "leaking param: i" +func foo61(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$" type S struct { a, b *int } @@ -406,7 +423,7 @@ func foo61(i *int) *int { // ERROR "leaking param: i" return s.b } -func foo61a(i *int) *int { // ERROR "i does not escape" +func foo61a(i *int) *int { // ERROR "i does not escape$" type S struct { a, b *int } @@ -418,11 +435,11 @@ func foo61a(i *int) *int { // ERROR "i does not escape" // assigning to a struct field is like assigning to the struct but // here this subtlety is lost, since s.a counts as an assignment to a // track-losing dereference. -func foo62(i *int) *int { // ERROR "leaking param: i" +func foo62(i *int) *int { // ERROR "leaking param: i$" type S struct { a, b *int } - s := new(S) // ERROR "new[(]S[)] does not escape" + s := new(S) // ERROR "new\(S\) does not escape$" s.a = i return nil // s.b } @@ -431,14 +448,14 @@ type M interface { M() } -func foo63(m M) { // ERROR "m does not escape" +func foo63(m M) { // ERROR "m does not escape$" } -func foo64(m M) { // ERROR "leaking param: m" +func foo64(m M) { // ERROR "leaking param: m$" m.M() } -func foo64b(m M) { // ERROR "leaking param: m" +func foo64b(m M) { // ERROR "leaking param: m$" defer m.M() } @@ -448,55 +465,56 @@ func (MV) M() {} func foo65() { var mv MV - foo63(&mv) // ERROR "&mv does not escape" + foo63(&mv) } func foo66() { - var mv MV // ERROR "moved to heap: mv" - foo64(&mv) // ERROR "&mv escapes to heap" + var mv MV // ERROR "moved to heap: mv$" + foo64(&mv) } func foo67() { var mv MV - foo63(mv) + foo63(mv) // ERROR "mv does not escape$" } func foo68() { var mv MV - foo64(mv) // escapes but it's an int so irrelevant + // escapes but it's an int so irrelevant + foo64(mv) // ERROR "mv escapes to heap$" } -func foo69(m M) { // ERROR "leaking param: m" +func foo69(m M) { // ERROR "leaking param: m$" foo64(m) } -func foo70(mv1 *MV, m M) { // ERROR "leaking param: mv1" "leaking param: m" +func foo70(mv1 *MV, m M) { // ERROR "leaking param: m$" "leaking param: mv1$" m = mv1 foo64(m) } -func foo71(x *int) []*int { // ERROR "leaking param: x" +func foo71(x *int) []*int { // ERROR "leaking param: x$" var y []*int y = append(y, x) return y } -func foo71a(x int) []*int { // ERROR "moved to heap: x" +func foo71a(x int) []*int { // ERROR "moved to heap: x$" var y []*int - y = append(y, &x) // ERROR "&x escapes to heap" + y = append(y, &x) return y } func foo72() { var x int var y [1]*int - y[0] = &x // ERROR "&x does not escape" + y[0] = &x } func foo72aa() [10]*int { - var x int // ERROR "moved to heap: x" + var x int // ERROR "moved to heap: x$" var y [10]*int - y[0] = &x // ERROR "&x escapes to heap" + y[0] = &x return y } @@ -504,8 +522,8 @@ func foo72a() { var y [10]*int for i := 0; i < 10; i++ { // escapes its scope - x := i // ERROR "moved to heap: x" - y[i] = &x // ERROR "&x escapes to heap" + x := i // ERROR "moved to heap: x$" + y[i] = &x } return } @@ -513,31 +531,56 @@ func foo72a() { func foo72b() [10]*int { var y [10]*int for i := 0; i < 10; i++ { - x := i // ERROR "moved to heap: x" - y[i] = &x // ERROR "&x escapes to heap" + x := i // ERROR "moved to heap: x$" + y[i] = &x } return y } // issue 2145 func foo73() { - s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape" + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" for _, v := range s { - vv := v // ERROR "moved to heap: vv" + vv := v // actually just escapes its scope - defer func() { // ERROR "func literal escapes to heap" - println(vv) // ERROR "&vv escapes to heap" + defer func() { // ERROR "func literal escapes to heap$" + println(vv) + }() + } +} + +func foo731() { + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" + for _, v := range s { + vv := v // ERROR "moved to heap: vv$" + // actually just escapes its scope + defer func() { // ERROR "func literal escapes to heap$" + vv = 42 + println(vv) }() } } func foo74() { - s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape" + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" for _, v := range s { - vv := v // ERROR "moved to heap: vv" + vv := v // actually just escapes its scope - fn := func() { // ERROR "func literal escapes to heap" - println(vv) // ERROR "&vv escapes to heap" + fn := func() { // ERROR "func literal escapes to heap$" + println(vv) + } + defer fn() + } +} + +func foo74a() { + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" + for _, v := range s { + vv := v // ERROR "moved to heap: vv$" + // actually just escapes its scope + fn := func() { // ERROR "func literal escapes to heap$" + vv += 1 + println(vv) } defer fn() } @@ -546,110 +589,138 @@ func foo74() { // issue 3975 func foo74b() { var array [3]func() - s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape" + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" + for i, v := range s { + vv := v + // actually just escapes its scope + array[i] = func() { // ERROR "func literal escapes to heap$" + println(vv) + } + } +} + +func foo74c() { + var array [3]func() + s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$" for i, v := range s { - vv := v // ERROR "moved to heap: vv" + vv := v // ERROR "moved to heap: vv$" // actually just escapes its scope - array[i] = func() { // ERROR "func literal escapes to heap" - println(vv) // ERROR "&vv escapes to heap" + array[i] = func() { // ERROR "func literal escapes to heap$" + println(&vv) } } } -func myprint(y *int, x ...interface{}) *int { // ERROR "x does not escape" "leaking param: y" +func myprint(y *int, x ...interface{}) *int { // ERROR "leaking param: y to result ~r2 level=0$" "x does not escape$" return y } -func myprint1(y *int, x ...interface{}) *interface{} { // ERROR "y does not escape" "leaking param: x" - return &x[0] // ERROR "&x.0. escapes to heap" +func myprint1(y *int, x ...interface{}) *interface{} { // ERROR "leaking param: x to result ~r2 level=0$" "y does not escape$" + return &x[0] } -func foo75(z *int) { // ERROR "z does not escape" - myprint(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" +func foo75(z *int) { // ERROR "z does not escape$" + myprint(z, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } -func foo75a(z *int) { // ERROR "z does not escape" - myprint1(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" +func foo75a(z *int) { // ERROR "z does not escape$" + myprint1(z, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } -func foo75esc(z *int) { // ERROR "leaking param: z" - gxx = myprint(z, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" +func foo75esc(z *int) { // ERROR "leaking param: z$" + gxx = myprint(z, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } -func foo75aesc(z *int) { // ERROR "z does not escape" +func foo75aesc(z *int) { // ERROR "z does not escape$" var ppi **interface{} // assignments to pointer dereferences lose track - *ppi = myprint1(z, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap" + *ppi = myprint1(z, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$" +} + +func foo75aesc1(z *int) { // ERROR "z does not escape$" + sink = myprint1(z, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$" } -func foo76(z *int) { // ERROR "leaking param: z" - myprint(nil, z) // ERROR "[.][.][.] argument does not escape" +func foo76(z *int) { // ERROR "z does not escape" + myprint(nil, z) // ERROR "... argument does not escape$" } -func foo76a(z *int) { // ERROR "leaking param: z" - myprint1(nil, z) // ERROR "[.][.][.] argument does not escape" +func foo76a(z *int) { // ERROR "z does not escape" + myprint1(nil, z) // ERROR "... argument does not escape$" } func foo76b() { - myprint(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" + myprint(nil, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } func foo76c() { - myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" + myprint1(nil, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } func foo76d() { - defer myprint(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" + defer myprint(nil, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } func foo76e() { - defer myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument does not escape" + defer myprint1(nil, 1, 2, 3) // ERROR "1 does not escape" "2 does not escape" "3 does not escape" "... argument does not escape$" } func foo76f() { for { // TODO: This one really only escapes its scope, but we don't distinguish yet. - defer myprint(nil, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap" + defer myprint(nil, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$" } } func foo76g() { for { - defer myprint1(nil, 1, 2, 3) // ERROR "[.][.][.] argument escapes to heap" + defer myprint1(nil, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$" } } -func foo77(z []interface{}) { // ERROR "z does not escape" +func foo77(z []interface{}) { // ERROR "z does not escape$" myprint(nil, z...) // z does not escape } -func foo77a(z []interface{}) { // ERROR "z does not escape" +func foo77a(z []interface{}) { // ERROR "z does not escape$" myprint1(nil, z...) } -func foo77b(z []interface{}) { // ERROR "leaking param: z" +func foo77b(z []interface{}) { // ERROR "leaking param: z$" var ppi **interface{} *ppi = myprint1(nil, z...) } -func foo78(z int) *int { // ERROR "moved to heap: z" - return &z // ERROR "&z escapes to heap" +func foo77c(z []interface{}) { // ERROR "leaking param: z$" + sink = myprint1(nil, z...) +} + +func dotdotdot() { + i := 0 + myprint(nil, &i) // ERROR "... argument does not escape$" + + j := 0 + myprint1(nil, &j) // ERROR "... argument does not escape$" } -func foo78a(z int) *int { // ERROR "moved to heap: z" - y := &z // ERROR "&z escapes to heap" - x := &y // ERROR "&y does not escape" +func foo78(z int) *int { // ERROR "moved to heap: z$" + return &z +} + +func foo78a(z int) *int { // ERROR "moved to heap: z$" + y := &z + x := &y return *x // really return y } func foo79() *int { - return new(int) // ERROR "new[(]int[)] escapes to heap" + return new(int) // ERROR "new\(int\) escapes to heap$" } func foo80() *int { var z *int for { // Really just escapes its scope but we don't distinguish - z = new(int) // ERROR "new[(]int[)] escapes to heap" + z = new(int) // ERROR "new\(int\) escapes to heap$" } _ = z return nil @@ -657,24 +728,24 @@ func foo80() *int { func foo81() *int { for { - z := new(int) // ERROR "new[(]int[)] does not escape" + z := new(int) // ERROR "new\(int\) does not escape$" _ = z } return nil } -func tee(p *int) (x, y *int) { return p, p } // ERROR "leaking param" +func tee(p *int) (x, y *int) { return p, p } // ERROR "leaking param: p to result x level=0$" "leaking param: p to result y level=0$" -func noop(x, y *int) {} // ERROR "does not escape" +func noop(x, y *int) {} // ERROR "x does not escape$" "y does not escape$" func foo82() { - var x, y, z int // ERROR "moved to heap" - go noop(tee(&z)) // ERROR "&z escapes to heap" - go noop(&x, &y) // ERROR "escapes to heap" + var x, y, z int // ERROR "moved to heap: x$" "moved to heap: y$" "moved to heap: z$" + go noop(tee(&z)) + go noop(&x, &y) for { - var u, v, w int // ERROR "moved to heap" - defer noop(tee(&u)) // ERROR "&u escapes to heap" - defer noop(&v, &w) // ERROR "escapes to heap" + var u, v, w int // ERROR "moved to heap: u$" "moved to heap: v$" "moved to heap: w$" + defer noop(tee(&u)) + defer noop(&v, &w) } } @@ -687,24 +758,24 @@ type LimitedFooer struct { N int64 } -func LimitFooer(r Fooer, n int64) Fooer { // ERROR "leaking param: r" - return &LimitedFooer{r, n} // ERROR "&LimitedFooer literal escapes to heap" +func LimitFooer(r Fooer, n int64) Fooer { // ERROR "leaking param: r$" + return &LimitedFooer{r, n} // ERROR "&LimitedFooer{...} escapes to heap$" } -func foo90(x *int) map[*int]*int { // ERROR "leaking param: x" - return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int literal escapes to heap" +func foo90(x *int) map[*int]*int { // ERROR "leaking param: x$" + return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} escapes to heap$" } -func foo91(x *int) map[*int]*int { // ERROR "leaking param: x" - return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int literal escapes to heap" +func foo91(x *int) map[*int]*int { // ERROR "leaking param: x$" + return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} escapes to heap$" } -func foo92(x *int) [2]*int { // ERROR "leaking param: x" +func foo92(x *int) [2]*int { // ERROR "leaking param: x to result ~r1 level=0$" return [2]*int{x, nil} } // does not leak c -func foo93(c chan *int) *int { // ERROR "c does not escape" +func foo93(c chan *int) *int { // ERROR "c does not escape$" for v := range c { return v } @@ -712,7 +783,7 @@ func foo93(c chan *int) *int { // ERROR "c does not escape" } // does not leak m -func foo94(m map[*int]*int, b bool) *int { // ERROR "m does not escape" +func foo94(m map[*int]*int, b bool) *int { // ERROR "leaking param: m to result ~r2 level=1" for k, v := range m { if b { return k @@ -723,32 +794,32 @@ func foo94(m map[*int]*int, b bool) *int { // ERROR "m does not escape" } // does leak x -func foo95(m map[*int]*int, x *int) { // ERROR "m does not escape" "leaking param: x" +func foo95(m map[*int]*int, x *int) { // ERROR "m does not escape$" "leaking param: x$" m[x] = x } -// does not leak m -func foo96(m []*int) *int { // ERROR "m does not escape" +// does not leak m but does leak content +func foo96(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1" return m[0] } // does leak m -func foo97(m [1]*int) *int { // ERROR "leaking param: m" +func foo97(m [1]*int) *int { // ERROR "leaking param: m to result ~r1 level=0$" return m[0] } // does not leak m -func foo98(m map[int]*int) *int { // ERROR "m does not escape" +func foo98(m map[int]*int) *int { // ERROR "m does not escape$" return m[0] } // does leak m -func foo99(m *[1]*int) []*int { // ERROR "leaking param: m" +func foo99(m *[1]*int) []*int { // ERROR "leaking param: m to result ~r1 level=0$" return m[:] } // does not leak m -func foo100(m []*int) *int { // ERROR "m does not escape" +func foo100(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1" for _, v := range m { return v } @@ -756,7 +827,7 @@ func foo100(m []*int) *int { // ERROR "m does not escape" } // does leak m -func foo101(m [1]*int) *int { // ERROR "leaking param: m" +func foo101(m [1]*int) *int { // ERROR "leaking param: m to result ~r1 level=0$" for _, v := range m { return v } @@ -764,109 +835,109 @@ func foo101(m [1]*int) *int { // ERROR "leaking param: m" } // does not leak m -func foo101a(m [1]*int) *int { // ERROR "m does not escape" - for i := range m { // ERROR "moved to heap: i" - return &i // ERROR "&i escapes to heap" +func foo101a(m [1]*int) *int { // ERROR "m does not escape$" + for i := range m { // ERROR "moved to heap: i$" + return &i } return nil } // does leak x -func foo102(m []*int, x *int) { // ERROR "m does not escape" "leaking param: x" +func foo102(m []*int, x *int) { // ERROR "m does not escape$" "leaking param: x$" m[0] = x } // does not leak x -func foo103(m [1]*int, x *int) { // ERROR "m does not escape" "x does not escape" +func foo103(m [1]*int, x *int) { // ERROR "m does not escape$" "x does not escape$" m[0] = x } var y []*int -// does not leak x -func foo104(x []*int) { // ERROR "x does not escape" +// does not leak x but does leak content +func foo104(x []*int) { // ERROR "leaking param content: x" copy(y, x) } -// does not leak x -func foo105(x []*int) { // ERROR "x does not escape" +// does not leak x but does leak content +func foo105(x []*int) { // ERROR "leaking param content: x" _ = append(y, x...) } // does leak x -func foo106(x *int) { // ERROR "leaking param: x" +func foo106(x *int) { // ERROR "leaking param: x$" _ = append(y, x) } -func foo107(x *int) map[*int]*int { // ERROR "leaking param: x" - return map[*int]*int{x: nil} // ERROR "map.* literal escapes to heap" +func foo107(x *int) map[*int]*int { // ERROR "leaking param: x$" + return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} escapes to heap$" } -func foo108(x *int) map[*int]*int { // ERROR "leaking param: x" - return map[*int]*int{nil: x} // ERROR "map.* literal escapes to heap" +func foo108(x *int) map[*int]*int { // ERROR "leaking param: x$" + return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} escapes to heap$" } -func foo109(x *int) *int { // ERROR "leaking param: x" - m := map[*int]*int{x: nil} // ERROR "map.* literal does not escape" +func foo109(x *int) *int { // ERROR "leaking param: x$" + m := map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} does not escape$" for k, _ := range m { return k } return nil } -func foo110(x *int) *int { // ERROR "leaking param: x" - m := map[*int]*int{nil: x} // ERROR "map.* literal does not escape" +func foo110(x *int) *int { // ERROR "leaking param: x$" + m := map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} does not escape$" return m[nil] } -func foo111(x *int) *int { // ERROR "leaking param: x" - m := []*int{x} // ERROR "\[\]\*int literal does not escape" +func foo111(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0" + m := []*int{x} // ERROR "\[\]\*int{...} does not escape$" return m[0] } -func foo112(x *int) *int { // ERROR "leaking param: x" +func foo112(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$" m := [1]*int{x} return m[0] } -func foo113(x *int) *int { // ERROR "leaking param: x" +func foo113(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$" m := Bar{ii: x} return m.ii } -func foo114(x *int) *int { // ERROR "leaking param: x" - m := &Bar{ii: x} // ERROR "&Bar literal does not escape" +func foo114(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$" + m := &Bar{ii: x} // ERROR "&Bar{...} does not escape$" return m.ii } -func foo115(x *int) *int { // ERROR "leaking param: x" +func foo115(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$" return (*int)(unsafe.Pointer(uintptr(unsafe.Pointer(x)) + 1)) } func foo116(b bool) *int { if b { - x := 1 // ERROR "moved to heap: x" - return &x // ERROR "&x escapes to heap" + x := 1 // ERROR "moved to heap: x$" + return &x } else { - y := 1 // ERROR "moved to heap: y" - return &y // ERROR "&y escapes to heap" + y := 1 // ERROR "moved to heap: y$" + return &y } return nil } -func foo117(unknown func(interface{})) { // ERROR "unknown does not escape" - x := 1 // ERROR "moved to heap: x" - unknown(&x) // ERROR "&x escapes to heap" +func foo117(unknown func(interface{})) { // ERROR "unknown does not escape$" + x := 1 // ERROR "moved to heap: x$" + unknown(&x) } -func foo118(unknown func(*int)) { // ERROR "unknown does not escape" - x := 1 // ERROR "moved to heap: x" - unknown(&x) // ERROR "&x escapes to heap" +func foo118(unknown func(*int)) { // ERROR "unknown does not escape$" + x := 1 // ERROR "moved to heap: x$" + unknown(&x) } func external(*int) -func foo119(x *int) { // ERROR "leaking param: x" +func foo119(x *int) { // ERROR "leaking param: x$" external(x) } @@ -1077,16 +1148,16 @@ L100: func foo121() { for i := 0; i < 10; i++ { - defer myprint(nil, i) // ERROR "[.][.][.] argument escapes to heap" - go myprint(nil, i) // ERROR "[.][.][.] argument escapes to heap" + defer myprint(nil, i) // ERROR "... argument escapes to heap$" "i escapes to heap$" + go myprint(nil, i) // ERROR "... argument escapes to heap$" "i escapes to heap$" } } // same as foo121 but check across import func foo121b() { for i := 0; i < 10; i++ { - defer fmt.Printf("%d", i) // ERROR "[.][.][.] argument escapes to heap" - go fmt.Printf("%d", i) // ERROR "[.][.][.] argument escapes to heap" + defer fmt.Printf("%d", i) // ERROR "... argument escapes to heap$" "i escapes to heap$" + go fmt.Printf("%d", i) // ERROR "... argument escapes to heap$" "i escapes to heap$" } } @@ -1096,7 +1167,7 @@ func foo122() { goto L1 L1: - i = new(int) // ERROR "new.int. does not escape" + i = new(int) // ERROR "new\(int\) does not escape$" _ = i } @@ -1105,25 +1176,25 @@ func foo123() { var i *int L1: - i = new(int) // ERROR "new.int. escapes to heap" + i = new(int) // ERROR "new\(int\) escapes to heap$" goto L1 _ = i } -func foo124(x **int) { // ERROR "x does not escape" - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes" - func() { // ERROR "func literal does not escape" - *x = p // ERROR "leaking closure reference p" +func foo124(x **int) { // ERROR "x does not escape$" + var i int // ERROR "moved to heap: i$" + p := &i + func() { // ERROR "func literal does not escape$" + *x = p }() } -func foo125(ch chan *int) { // ERROR "does not escape" - var i int // ERROR "moved to heap" - p := &i // ERROR "&i escapes to heap" - func() { // ERROR "func literal does not escape" - ch <- p // ERROR "leaking closure reference p" +func foo125(ch chan *int) { // ERROR "ch does not escape$" + var i int // ERROR "moved to heap: i$" + p := &i + func() { // ERROR "func literal does not escape$" + ch <- p }() } @@ -1131,9 +1202,9 @@ func foo126() { var px *int // loopdepth 0 for { // loopdepth 1 - var i int // ERROR "moved to heap" - func() { // ERROR "func literal does not escape" - px = &i // ERROR "&i escapes" + var i int // ERROR "moved to heap: i$" + func() { // ERROR "func literal does not escape$" + px = &i }() } _ = px @@ -1142,26 +1213,26 @@ func foo126() { var px *int func foo127() { - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes to heap" + var i int // ERROR "moved to heap: i$" + p := &i q := p px = q } func foo128() { var i int - p := &i // ERROR "&i does not escape" + p := &i q := p _ = q } func foo129() { - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes to heap" - func() { // ERROR "func literal does not escape" - q := p // ERROR "leaking closure reference p" - func() { // ERROR "func literal does not escape" - r := q // ERROR "leaking closure reference q" + var i int // ERROR "moved to heap: i$" + p := &i + func() { // ERROR "func literal does not escape$" + q := p + func() { // ERROR "func literal does not escape$" + r := q px = r }() }() @@ -1169,40 +1240,40 @@ func foo129() { func foo130() { for { - var i int // ERROR "moved to heap" - func() { // ERROR "func literal does not escape" - px = &i // ERROR "&i escapes" "leaking closure reference i" + var i int // ERROR "moved to heap: i$" + func() { // ERROR "func literal does not escape$" + px = &i }() } } func foo131() { - var i int // ERROR "moved to heap" - func() { // ERROR "func literal does not escape" - px = &i // ERROR "&i escapes" "leaking closure reference i" + var i int // ERROR "moved to heap: i$" + func() { // ERROR "func literal does not escape$" + px = &i }() } func foo132() { - var i int // ERROR "moved to heap" - go func() { // ERROR "func literal escapes to heap" - px = &i // ERROR "&i escapes" "leaking closure reference i" + var i int // ERROR "moved to heap: i$" + go func() { // ERROR "func literal escapes to heap$" + px = &i }() } func foo133() { - var i int // ERROR "moved to heap" - defer func() { // ERROR "func literal does not escape" - px = &i // ERROR "&i escapes" "leaking closure reference i" + var i int // ERROR "moved to heap: i$" + defer func() { // ERROR "func literal does not escape$" + px = &i }() } func foo134() { var i int - p := &i // ERROR "&i does not escape" - func() { // ERROR "func literal does not escape" + p := &i + func() { // ERROR "func literal does not escape$" q := p - func() { // ERROR "func literal does not escape" + func() { // ERROR "func literal does not escape$" r := q _ = r }() @@ -1210,11 +1281,11 @@ func foo134() { } func foo135() { - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes to heap" "moved to heap: p" - go func() { // ERROR "func literal escapes to heap" - q := p // ERROR "&p escapes to heap" - func() { // ERROR "func literal does not escape" + var i int // ERROR "moved to heap: i$" + p := &i + go func() { // ERROR "func literal escapes to heap$" + q := p + func() { // ERROR "func literal does not escape$" r := q _ = r }() @@ -1222,24 +1293,24 @@ func foo135() { } func foo136() { - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes to heap" "moved to heap: p" - go func() { // ERROR "func literal escapes to heap" - q := p // ERROR "&p escapes to heap" "leaking closure reference p" - func() { // ERROR "func literal does not escape" - r := q // ERROR "leaking closure reference q" + var i int // ERROR "moved to heap: i$" + p := &i + go func() { // ERROR "func literal escapes to heap$" + q := p + func() { // ERROR "func literal does not escape$" + r := q px = r }() }() } func foo137() { - var i int // ERROR "moved to heap: i" - p := &i // ERROR "&i escapes to heap" - func() { // ERROR "func literal does not escape" - q := p // ERROR "leaking closure reference p" "moved to heap: q" - go func() { // ERROR "func literal escapes to heap" - r := q // ERROR "&q escapes to heap" + var i int // ERROR "moved to heap: i$" + p := &i + func() { // ERROR "func literal does not escape$" + q := p + go func() { // ERROR "func literal escapes to heap$" + r := q _ = r }() }() @@ -1249,8 +1320,8 @@ func foo138() *byte { type T struct { x [1]byte } - t := new(T) // ERROR "new.T. escapes to heap" - return &t.x[0] // ERROR "&t.x.0. escapes to heap" + t := new(T) // ERROR "new\(T\) escapes to heap$" + return &t.x[0] } func foo139() *byte { @@ -1259,8 +1330,8 @@ func foo139() *byte { y byte } } - t := new(T) // ERROR "new.T. escapes to heap" - return &t.x.y // ERROR "&t.x.y escapes to heap" + t := new(T) // ERROR "new\(T\) escapes to heap$" + return &t.x.y } // issue 4751 @@ -1272,8 +1343,8 @@ func foo140() interface{} { X string T *T } - t := &T{} // ERROR "&T literal escapes to heap" - return U{ + t := &T{} // ERROR "&T{} escapes to heap$" + return U{ // ERROR "U{...} escapes to heap$" X: t.X, T: t, } @@ -1287,53 +1358,53 @@ func F2([]byte) //go:noescape -func F3(x []byte) // ERROR "F3 x does not escape" +func F3(x []byte) // ERROR "x does not escape$" -func F4(x []byte) +func F4(x []byte) // ERROR "leaking param: x$" func G() { var buf1 [10]byte - F1(buf1[:]) // ERROR "buf1 does not escape" - - var buf2 [10]byte // ERROR "moved to heap: buf2" - F2(buf2[:]) // ERROR "buf2 escapes to heap" + F1(buf1[:]) + + var buf2 [10]byte // ERROR "moved to heap: buf2$" + F2(buf2[:]) var buf3 [10]byte - F3(buf3[:]) // ERROR "buf3 does not escape" - - var buf4 [10]byte // ERROR "moved to heap: buf4" - F4(buf4[:]) // ERROR "buf4 escapes to heap" + F3(buf3[:]) + + var buf4 [10]byte // ERROR "moved to heap: buf4$" + F4(buf4[:]) } type Tm struct { x int } -func (t *Tm) M() { // ERROR "t does not escape" +func (t *Tm) M() { // ERROR "t does not escape$" } func foo141() { var f func() - - t := new(Tm) // ERROR "escapes to heap" - f = t.M // ERROR "t.M does not escape" + + t := new(Tm) // ERROR "new\(Tm\) does not escape$" + f = t.M // ERROR "t.M does not escape$" _ = f } var gf func() func foo142() { - t := new(Tm) // ERROR "escapes to heap" - gf = t.M // ERROR "t.M escapes to heap" + t := new(Tm) // ERROR "new\(Tm\) escapes to heap$" + gf = t.M // ERROR "t.M escapes to heap$" } // issue 3888. func foo143() { for i := 0; i < 1000; i++ { - func() { // ERROR "func literal does not escape" + func() { // ERROR "func literal does not escape$" for i := 0; i < 1; i++ { var t Tm - t.M() // ERROR "t does not escape" + t.M() } }() } @@ -1349,11 +1420,427 @@ func foo144a(*int) func foo144() { var x int - foo144a(&x) // ERROR "&x does not escape" + foo144a(&x) var y int - foo144b(&y) // ERROR "&y does not escape" + foo144b(&y) } //go:noescape func foo144b(*int) + +// issue 7313: for loop init should not be treated as "in loop" + +type List struct { + Next *List +} + +func foo145(l List) { // ERROR "l does not escape$" + var p *List + for p = &l; p.Next != nil; p = p.Next { + } +} + +func foo146(l List) { // ERROR "l does not escape$" + var p *List + p = &l + for ; p.Next != nil; p = p.Next { + } +} + +func foo147(l List) { // ERROR "l does not escape$" + var p *List + p = &l + for p.Next != nil { + p = p.Next + } +} + +func foo148(l List) { // ERROR "l does not escape$" + for p := &l; p.Next != nil; p = p.Next { + } +} + +// related: address of variable should have depth of variable, not of loop + +func foo149(l List) { // ERROR "l does not escape$" + var p *List + for { + for p = &l; p.Next != nil; p = p.Next { + } + } +} + +// issue 7934: missed ... if element type had no pointers + +var save150 []byte + +func foo150(x ...byte) { // ERROR "leaking param: x$" + save150 = x +} + +func bar150() { + foo150(1, 2, 3) // ERROR "... argument escapes to heap$" +} + +// issue 7931: bad handling of slice of array + +var save151 *int + +func foo151(x *int) { // ERROR "leaking param: x$" + save151 = x +} + +func bar151() { + var a [64]int // ERROR "moved to heap: a$" + a[4] = 101 + foo151(&(&a)[4:8][0]) +} + +func bar151b() { + var a [10]int // ERROR "moved to heap: a$" + b := a[:] + foo151(&b[4:8][0]) +} + +func bar151c() { + var a [64]int // ERROR "moved to heap: a$" + a[4] = 101 + foo151(&(&a)[4:8:8][0]) +} + +func bar151d() { + var a [10]int // ERROR "moved to heap: a$" + b := a[:] + foo151(&b[4:8:8][0]) +} + +// issue 8120 + +type U struct { + s *string +} + +func (u *U) String() *string { // ERROR "leaking param: u to result ~r0 level=1$" + return u.s +} + +type V struct { + s *string +} + +func NewV(u U) *V { // ERROR "leaking param: u$" + return &V{u.String()} // ERROR "&V{...} escapes to heap$" +} + +func foo152() { + a := "a" // ERROR "moved to heap: a$" + u := U{&a} + v := NewV(u) + println(v) +} + +// issue 8176 - &x in type switch body not marked as escaping + +func foo153(v interface{}) *int { // ERROR "v does not escape" + switch x := v.(type) { + case int: // ERROR "moved to heap: x$" + return &x + } + panic(0) +} + +// issue 8185 - &result escaping into result + +func f() (x int, y *int) { // ERROR "moved to heap: x$" + y = &x + return +} + +func g() (x interface{}) { // ERROR "moved to heap: x$" + x = &x + return +} + +var sink interface{} + +type Lit struct { + p *int +} + +func ptrlitNoescape() { + // Both literal and element do not escape. + i := 0 + x := &Lit{&i} // ERROR "&Lit{...} does not escape$" + _ = x +} + +func ptrlitNoEscape2() { + // Literal does not escape, but element does. + i := 0 // ERROR "moved to heap: i$" + x := &Lit{&i} // ERROR "&Lit{...} does not escape$" + sink = *x +} + +func ptrlitEscape() { + // Both literal and element escape. + i := 0 // ERROR "moved to heap: i$" + x := &Lit{&i} // ERROR "&Lit{...} escapes to heap$" + sink = x +} + +// self-assignments + +type Buffer struct { + arr [64]byte + arrPtr *[64]byte + buf1 []byte + buf2 []byte + str1 string + str2 string +} + +func (b *Buffer) foo() { // ERROR "b does not escape$" + b.buf1 = b.buf1[1:2] // ERROR "\(\*Buffer\).foo ignoring self-assignment in b.buf1 = b.buf1\[1:2\]$" + b.buf1 = b.buf1[1:2:3] // ERROR "\(\*Buffer\).foo ignoring self-assignment in b.buf1 = b.buf1\[1:2:3\]$" + b.buf1 = b.buf2[1:2] // ERROR "\(\*Buffer\).foo ignoring self-assignment in b.buf1 = b.buf2\[1:2\]$" + b.buf1 = b.buf2[1:2:3] // ERROR "\(\*Buffer\).foo ignoring self-assignment in b.buf1 = b.buf2\[1:2:3\]$" +} + +func (b *Buffer) bar() { // ERROR "leaking param: b$" + b.buf1 = b.arr[1:2] +} + +func (b *Buffer) arrayPtr() { // ERROR "b does not escape" + b.buf1 = b.arrPtr[1:2] // ERROR "\(\*Buffer\).arrayPtr ignoring self-assignment in b.buf1 = b.arrPtr\[1:2\]$" + b.buf1 = b.arrPtr[1:2:3] // ERROR "\(\*Buffer\).arrayPtr ignoring self-assignment in b.buf1 = b.arrPtr\[1:2:3\]$" +} + +func (b *Buffer) baz() { // ERROR "b does not escape$" + b.str1 = b.str1[1:2] // ERROR "\(\*Buffer\).baz ignoring self-assignment in b.str1 = b.str1\[1:2\]$" + b.str1 = b.str2[1:2] // ERROR "\(\*Buffer\).baz ignoring self-assignment in b.str1 = b.str2\[1:2\]$" +} + +func (b *Buffer) bat() { // ERROR "leaking param content: b$" + o := new(Buffer) // ERROR "new\(Buffer\) escapes to heap$" + o.buf1 = b.buf1[1:2] + sink = o +} + +func quux(sp *string, bp *[]byte) { // ERROR "bp does not escape$" "sp does not escape$" + *sp = (*sp)[1:2] // ERROR "quux ignoring self-assignment in \*sp = \(\*sp\)\[1:2\]$" + *bp = (*bp)[1:2] // ERROR "quux ignoring self-assignment in \*bp = \(\*bp\)\[1:2\]$" +} + +type StructWithString struct { + p *int + s string +} + +// This is escape analysis false negative. +// We assign the pointer to x.p but leak x.s. Escape analysis coarsens flows +// to just x, and thus &i looks escaping. +func fieldFlowTracking() { + var x StructWithString + i := 0 // ERROR "moved to heap: i$" + x.p = &i + sink = x.s // ERROR "x.s escapes to heap$" +} + +// String operations. + +func slicebytetostring0() { + b := make([]byte, 20) // ERROR "make\(\[\]byte, 20\) does not escape$" + s := string(b) // ERROR "string\(b\) does not escape$" + _ = s +} + +func slicebytetostring1() { + b := make([]byte, 20) // ERROR "make\(\[\]byte, 20\) does not escape$" + s := string(b) // ERROR "string\(b\) does not escape$" + s1 := s[0:1] + _ = s1 +} + +func slicebytetostring2() { + b := make([]byte, 20) // ERROR "make\(\[\]byte, 20\) does not escape$" + s := string(b) // ERROR "string\(b\) escapes to heap$" + s1 := s[0:1] // ERROR "moved to heap: s1$" + sink = &s1 +} + +func slicebytetostring3() { + b := make([]byte, 20) // ERROR "make\(\[\]byte, 20\) does not escape$" + s := string(b) // ERROR "string\(b\) escapes to heap$" + s1 := s[0:1] + sink = s1 // ERROR "s1 escapes to heap$" +} + +func addstr0() { + s0 := "a" + s1 := "b" + s := s0 + s1 // ERROR "s0 \+ s1 does not escape$" + _ = s +} + +func addstr1() { + s0 := "a" + s1 := "b" + s := "c" + s += s0 + s1 // ERROR "s0 \+ s1 does not escape$" + _ = s +} + +func addstr2() { + b := make([]byte, 20) // ERROR "make\(\[\]byte, 20\) does not escape$" + s0 := "a" + s := string(b) + s0 // ERROR "string\(b\) \+ s0 does not escape$" "string\(b\) does not escape$" + _ = s +} + +func addstr3() { + s0 := "a" + s1 := "b" + s := s0 + s1 // ERROR "s0 \+ s1 escapes to heap$" + s2 := s[0:1] + sink = s2 // ERROR "s2 escapes to heap$" +} + +func intstring0() bool { + // string does not escape + x := '0' + s := string(x) // ERROR "string\(x\) does not escape$" + return s == "0" +} + +func intstring1() string { + // string does not escape, but the buffer does + x := '0' + s := string(x) // ERROR "string\(x\) escapes to heap$" + return s +} + +func intstring2() { + // string escapes to heap + x := '0' + s := string(x) // ERROR "moved to heap: s$" "string\(x\) escapes to heap$" + sink = &s +} + +func stringtoslicebyte0() { + s := "foo" + x := []byte(s) // ERROR "\(\[\]byte\)\(s\) does not escape$" + _ = x +} + +func stringtoslicebyte1() []byte { + s := "foo" + return []byte(s) // ERROR "\(\[\]byte\)\(s\) escapes to heap$" +} + +func stringtoslicebyte2() { + s := "foo" + sink = []byte(s) // ERROR "\(\[\]byte\)\(s\) escapes to heap$" +} + +func stringtoslicerune0() { + s := "foo" + x := []rune(s) // ERROR "\(\[\]rune\)\(s\) does not escape$" + _ = x +} + +func stringtoslicerune1() []rune { + s := "foo" + return []rune(s) // ERROR "\(\[\]rune\)\(s\) escapes to heap$" +} + +func stringtoslicerune2() { + s := "foo" + sink = []rune(s) // ERROR "\(\[\]rune\)\(s\) escapes to heap$" +} + +func slicerunetostring0() { + r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$" + s := string(r) // ERROR "string\(r\) does not escape$" + _ = s +} + +func slicerunetostring1() string { + r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$" + return string(r) // ERROR "string\(r\) escapes to heap$" +} + +func slicerunetostring2() { + r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$" + sink = string(r) // ERROR "string\(r\) escapes to heap$" +} + +func makemap0() { + m := make(map[int]int) // ERROR "make\(map\[int\]int\) does not escape$" + m[0] = 0 + m[1]++ + delete(m, 1) + sink = m[0] // ERROR "m\[0\] escapes to heap$" +} + +func makemap1() map[int]int { + return make(map[int]int) // ERROR "make\(map\[int\]int\) escapes to heap$" +} + +func makemap2() { + m := make(map[int]int) // ERROR "make\(map\[int\]int\) escapes to heap$" + sink = m +} + +func nonescapingEface(m map[interface{}]bool) bool { // ERROR "m does not escape$" + return m["foo"] // ERROR ".foo. does not escape$" +} + +func nonescapingIface(m map[M]bool) bool { // ERROR "m does not escape$" + return m[MV(0)] // ERROR "MV\(0\) does not escape$" +} + +func issue10353() { + x := new(int) // ERROR "new\(int\) escapes to heap$" + issue10353a(x)() +} + +func issue10353a(x *int) func() { // ERROR "leaking param: x$" + return func() { // ERROR "func literal escapes to heap$" + println(*x) + } +} + +func issue10353b() { + var f func() + for { + x := new(int) // ERROR "new\(int\) escapes to heap$" + f = func() { // ERROR "func literal escapes to heap$" + println(*x) + } + } + _ = f +} + +func issue11387(x int) func() int { + f := func() int { return x } // ERROR "func literal escapes to heap" + slice1 := []func() int{f} // ERROR "\[\].* does not escape" + slice2 := make([]func() int, 1) // ERROR "make\(.*\) does not escape" + copy(slice2, slice1) + return slice2[0] +} + +func issue12397(x, y int) { // ERROR "moved to heap: y$" + // x does not escape below, because all relevant code is dead. + if false { + gxx = &x + } else { + gxx = &y + } + + if true { + gxx = &y + } else { + gxx = &x + } +} diff --git a/gcc/testsuite/go.test/test/escape3.go b/gcc/testsuite/go.test/test/escape3.go index 4c198915146..f1131a26884 100644 --- a/gcc/testsuite/go.test/test/escape3.go +++ b/gcc/testsuite/go.test/test/escape3.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/escape4.go b/gcc/testsuite/go.test/test/escape4.go index 83bc8eb123d..a4a9c14a3e0 100644 --- a/gcc/testsuite/go.test/test/escape4.go +++ b/gcc/testsuite/go.test/test/escape4.go @@ -1,6 +1,6 @@ // errorcheck -0 -m -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -12,38 +12,38 @@ package foo var p *int func alloc(x int) *int { // ERROR "can inline alloc" "moved to heap: x" - return &x // ERROR "&x escapes to heap" + return &x } var f func() func f1() { - p = alloc(2) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x" + p = alloc(2) // ERROR "inlining call to alloc" "moved to heap: x" // Escape analysis used to miss inlined code in closures. - func() { // ERROR "func literal does not escape" - p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x" - }() + func() { // ERROR "can inline f1.func1" + p = alloc(3) // ERROR "inlining call to alloc" + }() // ERROR "inlining call to f1.func1" "inlining call to alloc" "moved to heap: x" - f = func() { // ERROR "func literal escapes to heap" - p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x" + f = func() { // ERROR "func literal escapes to heap" "can inline f1.func2" + p = alloc(3) // ERROR "inlining call to alloc" "moved to heap: x" } f() } func f2() {} // ERROR "can inline f2" -// No inline for panic, recover. -func f3() { panic(1) } +// No inline for recover; panic now allowed to inline. +func f3() { panic(1) } // ERROR "can inline f3" func f4() { recover() } func f5() *byte { type T struct { x [1]byte } - t := new(T) // ERROR "new.T. escapes to heap" - return &t.x[0] // ERROR "&t.x.0. escapes to heap" + t := new(T) // ERROR "new.T. escapes to heap" + return &t.x[0] } func f6() *byte { @@ -52,6 +52,6 @@ func f6() *byte { y byte } } - t := new(T) // ERROR "new.T. escapes to heap" - return &t.x.y // ERROR "&t.x.y escapes to heap" + t := new(T) // ERROR "new.T. escapes to heap" + return &t.x.y } diff --git a/gcc/testsuite/go.test/test/escape5.go b/gcc/testsuite/go.test/test/escape5.go index c9646872d51..2ed2023cd26 100644 --- a/gcc/testsuite/go.test/test/escape5.go +++ b/gcc/testsuite/go.test/test/escape5.go @@ -1,6 +1,6 @@ // errorcheck -0 -m -l -// Copyright 2012 The Go Authors. All rights reserved. +// 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. @@ -9,6 +9,11 @@ package foo +import ( + "runtime" + "unsafe" +) + func noleak(p *int) int { // ERROR "p does not escape" return *p } @@ -17,19 +22,19 @@ func leaktoret(p *int) *int { // ERROR "leaking param: p to result" return p } -func leaktoret2(p *int) (*int, *int) { // ERROR "leaking param: p to result .anon1" "leaking param: p to result .anon2" +func leaktoret2(p *int) (*int, *int) { // ERROR "leaking param: p to result ~r1" "leaking param: p to result ~r2" return p, p } -func leaktoret22(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon2" "leaking param: q to result .anon3" +func leaktoret22(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r2" "leaking param: q to result ~r3" return p, q } -func leaktoret22b(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon3" "leaking param: q to result .anon2" +func leaktoret22b(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r3" "leaking param: q to result ~r2" return leaktoret22(q, p) } -func leaktoret22c(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon3" "leaking param: q to result .anon2" +func leaktoret22c(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r3" "leaking param: q to result ~r2" r, s := leaktoret22(q, p) return r, s } @@ -58,37 +63,37 @@ func leaktosink(p *int) *int { // ERROR "leaking param: p" func f1() { var x int - p := noleak(&x) // ERROR "&x does not escape" + p := noleak(&x) _ = p } func f2() { var x int - p := leaktoret(&x) // ERROR "&x does not escape" + p := leaktoret(&x) _ = p } func f3() { - var x int // ERROR "moved to heap: x" - p := leaktoret(&x) // ERROR "&x escapes to heap" + var x int // ERROR "moved to heap: x" + p := leaktoret(&x) gp = p } func f4() { - var x int // ERROR "moved to heap: x" - p, q := leaktoret2(&x) // ERROR "&x escapes to heap" + var x int // ERROR "moved to heap: x" + p, q := leaktoret2(&x) gp = p gp = q } func f5() { var x int - leaktoret22(leaktoret2(&x)) // ERROR "&x does not escape" + leaktoret22(leaktoret2(&x)) } func f6() { - var x int // ERROR "moved to heap: x" - px1, px2 := leaktoret22(leaktoret2(&x)) // ERROR "&x escapes to heap" + var x int // ERROR "moved to heap: x" + px1, px2 := leaktoret22(leaktoret2(&x)) gp = px1 _ = px2 } @@ -117,7 +122,6 @@ func leakrecursive2(p, q *int) (*int, *int) { // ERROR "leaking param: p" "leaki return p, q } - var global interface{} type T1 struct { @@ -128,24 +132,140 @@ type T2 struct { Y *T1 } -func f8(p *T1) (k T2) { // ERROR "leaking param: p to result k" "leaking param: p" +func f8(p *T1) (k T2) { // ERROR "leaking param: p$" if p == nil { k = T2{} return } - global = p // should make p leak always + // should make p leak always + global = p return T2{p} } func f9() { var j T1 // ERROR "moved to heap: j" - f8(&j) // ERROR "&j escapes to heap" + f8(&j) } func f10() { // These don't escape but are too big for the stack - var x [1<<30]byte // ERROR "moved to heap: x" - var y = make([]byte, 1<<30) // ERROR "does not escape" + var x [1 << 30]byte // ERROR "moved to heap: x" + var y = make([]byte, 1<<30) // ERROR "make\(\[\]byte, 1 << 30\) escapes to heap" _ = x[0] + y[0] } + +// Test for issue 19687 (passing to unnamed parameters does not escape). +func f11(**int) { +} +func f12(_ **int) { +} +func f13() { + var x *int + f11(&x) + f12(&x) + runtime.KeepAlive(&x) +} + +// Test for issue 24305 (passing to unnamed receivers does not escape). +type U int + +func (*U) M() {} +func (_ *U) N() {} + +func _() { + var u U + u.M() + u.N() +} + +func fbad24305() { + // BAD u should not be heap allocated + var u U // ERROR "moved to heap: u" + (*U).M(&u) + (*U).N(&u) +} + +// Issue 24730: taking address in a loop causes unnecessary escape +type T24730 struct { + x [64]byte +} + +func (t *T24730) g() { // ERROR "t does not escape" + y := t.x[:] + for i := range t.x[:] { + y = t.x[:] + y[i] = 1 + } + + var z *byte + for i := range t.x[:] { + z = &t.x[i] + *z = 2 + } +} + +// Issue 15730: copy causes unnecessary escape + +var sink []byte +var sink2 []int +var sink3 []*int + +func f15730a(args ...interface{}) { // ERROR "args does not escape" + for _, arg := range args { + switch a := arg.(type) { + case string: + copy(sink, a) + } + } +} + +func f15730b(args ...interface{}) { // ERROR "args does not escape" + for _, arg := range args { + switch a := arg.(type) { + case []int: + copy(sink2, a) + } + } +} + +func f15730c(args ...interface{}) { // ERROR "leaking param content: args" + for _, arg := range args { + switch a := arg.(type) { + case []*int: + // copy pointerful data should cause escape + copy(sink3, a) + } + } +} + +// Issue 29000: unnamed parameter is not handled correctly + +var sink4 interface{} +var alwaysFalse = false + +func f29000(_ int, x interface{}) { // ERROR "leaking param: x" + sink4 = x + if alwaysFalse { + g29000() + } +} + +func g29000() { + x := 1 + f29000(2, x) // ERROR "x escapes to heap" +} + +// Issue 28369: taking an address of a parameter and converting it into a uintptr causes an +// unnecessary escape. + +var sink28369 uintptr + +func f28369(n int) int { + if n == 0 { + sink28369 = uintptr(unsafe.Pointer(&n)) + return n + } + + return 1 + f28369(n-1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug0.go b/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug0.go index e312256c461..2f59d81a614 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug0.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug0.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug1.go b/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug1.go index 486fe760734..ea5bcfe205a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug083.dir/bug1.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug0.go b/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug0.go index af9d991e607..7a6e34747f6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug0.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug0.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug1.go b/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug1.go index cadf0e698a5..2568e37d020 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug088.dir/bug1.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug0.go b/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug0.go index d9c26a00bd1..7494c580b77 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug0.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug0.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug1.go b/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug1.go index 0f1d20e47d9..eff0d36ed29 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug106.dir/bug1.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug108.go b/gcc/testsuite/go.test/test/fixedbugs/bug108.go index 9f2a27ebd97..cfec4c9f1f4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug108.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug108.go @@ -6,6 +6,6 @@ package main func f() { - v := 1 << 1025; // ERROR "overflow|stupid shift" + v := 1 << 1025; // ERROR "overflow|shift count too large" _ = v } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug121.go b/gcc/testsuite/go.test/test/fixedbugs/bug121.go index 5adf9827fa1..22c71817526 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug121.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug121.go @@ -15,4 +15,3 @@ type I interface { type J interface { h T; // ERROR "syntax|signature" } - diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug0.go b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug0.go index 48cd104c497..19a2bfbd4b5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug0.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug0.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug1.go b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug1.go index 75621478851..dd59b2f2ec1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug1.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug2.go b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug2.go index e5310011206..b6184c2e75b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug133.dir/bug2.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug1515.go b/gcc/testsuite/go.test/test/fixedbugs/bug1515.go index a4baccda779..5fef5ad38ac 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug1515.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug1515.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/x.go b/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/x.go index bd52c6cc3c2..2673552d80b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/x.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/x.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/y.go b/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/y.go index 27e2f352a41..428808dd198 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/y.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug160.dir/y.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug169.go b/gcc/testsuite/go.test/test/fixedbugs/bug169.go index f63c2f3e1af..62ab7c2fa1c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug169.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug169.go @@ -5,6 +5,6 @@ // license that can be found in the LICENSE file. package main -var x = '''; // ERROR "char" +var x = '''; // ERROR "char|rune" diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug173.go b/gcc/testsuite/go.test/test/fixedbugs/bug173.go index 6479bb2531b..3515c649bbe 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug173.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug173.go @@ -18,4 +18,6 @@ func main() { } for _ = range t { } + for range t { + } } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug176.go b/gcc/testsuite/go.test/test/fixedbugs/bug176.go index 82f8dba0ad0..7001dd081e9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug176.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug176.go @@ -9,6 +9,6 @@ package main var x int var a = []int{ x: 1} // ERROR "constant" -var b = [...]int{ x : 1} // ERROR "constant" +var b = [...]int{x: 1} // GCCGO_ERROR "constant" var c = map[int]int{ x: 1} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug195.go b/gcc/testsuite/go.test/test/fixedbugs/bug195.go index 85367cb8882..aef7bd2d894 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug195.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug195.go @@ -6,22 +6,22 @@ package main -type I1 interface { I2 } // ERROR "interface" +type I1 interface{ I2 } // ERROR "interface" type I2 int -type I3 interface { int } // ERROR "interface" +type I3 interface{ int } // ERROR "interface" type S struct { - x interface{ S } // ERROR "interface" + x interface{ S } // ERROR "interface" } -type I4 interface { - I4 // ERROR "interface" +type I4 interface { // GC_ERROR "invalid recursive type I4\n\tLINE: I4 refers to\n\tLINE: I4$" + I4 // GCCGO_ERROR "interface" } -type I5 interface { - I6 // GCCGO_ERROR "interface" +type I5 interface { // GC_ERROR "invalid recursive type I5\n\tLINE: I5 refers to\n\tLINE+4: I6 refers to\n\tLINE: I5$" + I6 // GCCGO_ERROR "interface" } type I6 interface { - I5 // ERROR "interface" + I5 // GCCGO_ERROR "interface" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug203.go b/gcc/testsuite/go.test/test/fixedbugs/bug203.go index 2fb084bd658..68647ec372b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug203.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug203.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug206.go b/gcc/testsuite/go.test/test/fixedbugs/bug206.go index c2382acf13f..91efa3ff790 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug206.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug206.go @@ -1,4 +1,4 @@ -// cmpout +// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug214.go b/gcc/testsuite/go.test/test/fixedbugs/bug214.go index 5420058c46d..f3c25e727f0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug214.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug214.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Used to crash the compiler. -// http://code.google.com/p/go/issues/detail?id=88 +// https://golang.org/issue/88 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug215.go b/gcc/testsuite/go.test/test/fixedbugs/bug215.go index 08ed662c65d..b27cc7db1a9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug215.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug215.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Used to crash the compiler. -// http://code.google.com/p/go/issues/detail?id=158 +// https://golang.org/issue/158 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug216.go b/gcc/testsuite/go.test/test/fixedbugs/bug216.go index c83a522bf91..470369a6a80 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug216.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug216.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Used to be rejected -// http://code.google.com/p/go/issues/detail?id=188 +// https://golang.org/issue/188 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug217.go b/gcc/testsuite/go.test/test/fixedbugs/bug217.go index ec93c25d917..ea836b9b6d5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug217.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug217.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Used to crash -// http://code.google.com/p/go/issues/detail?id=204 +// https://golang.org/issue/204 package main @@ -13,3 +13,5 @@ func () x() // ERROR "no receiver" func (a b, c d) x() // ERROR "multiple receiver" +type b int + diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug218.go b/gcc/testsuite/go.test/test/fixedbugs/bug218.go index 0e008db17f2..f159f05fa8d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug218.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug218.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Crashes 6g, 8g -// http://code.google.com/p/go/issues/detail?id=238 +// https://golang.org/issue/238 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug221.go b/gcc/testsuite/go.test/test/fixedbugs/bug221.go index 86fda203516..4275474a972 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug221.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug221.go @@ -7,7 +7,7 @@ // function call arg reordering was picking out 1 call that // didn't need to be in a temporary, but it was picking // out the first call instead of the last call. -// http://code.google.com/p/go/issues/detail?id=370 +// https://golang.org/issue/370 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug227.go b/gcc/testsuite/go.test/test/fixedbugs/bug227.go index ea8d02d10c6..afbdd977d17 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug227.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug227.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug228.go b/gcc/testsuite/go.test/test/fixedbugs/bug228.go index 3fccd172888..f7ac670689b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug228.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug228.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug229.go b/gcc/testsuite/go.test/test/fixedbugs/bug229.go index 19776881d17..a30202fa2c7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug229.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug229.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. @@ -10,11 +10,11 @@ import "testing" func main() { var t testing.T - + // make sure error mentions that // name is unexported, not just "name not found". - t.name = nil // ERROR "unexported" - - println(testing.anyLowercaseName("asdf")) // ERROR "unexported" "undefined: testing.anyLowercaseName" + t.common.name = nil // ERROR "unexported" + + println(testing.anyLowercaseName("asdf")) // ERROR "unexported" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug230.go b/gcc/testsuite/go.test/test/fixedbugs/bug230.go index 210acc43075..e5eead52e20 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug230.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug230.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug231.go b/gcc/testsuite/go.test/test/fixedbugs/bug231.go index a9d409b7d5a..f64ddc3e757 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug231.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug231.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug232.go b/gcc/testsuite/go.test/test/fixedbugs/bug232.go index d18727e9071..10b0c521a40 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug232.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug232.go @@ -1,6 +1,6 @@ // compile -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug233.go b/gcc/testsuite/go.test/test/fixedbugs/bug233.go index 63f8ee2e9e6..d4e1e078169 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug233.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug233.go @@ -1,6 +1,6 @@ // compile -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug234.go b/gcc/testsuite/go.test/test/fixedbugs/bug234.go index 9f503f04a0b..0d37ce22f5b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug234.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug234.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug235.go b/gcc/testsuite/go.test/test/fixedbugs/bug235.go index d12d9e7368a..a33092bdb64 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug235.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug235.go @@ -1,6 +1,6 @@ // compile -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug236.go b/gcc/testsuite/go.test/test/fixedbugs/bug236.go index 6c245565f29..de7e8e3d8a2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug236.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug236.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug237.go b/gcc/testsuite/go.test/test/fixedbugs/bug237.go index 58996cadc0b..75d6132df96 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug237.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug237.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug243.go b/gcc/testsuite/go.test/test/fixedbugs/bug243.go index 4870c3614cb..5b6bb7517d2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug243.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug243.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug245.go b/gcc/testsuite/go.test/test/fixedbugs/bug245.go index c607a6dc33c..adf62f98b54 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug245.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug245.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug247.go b/gcc/testsuite/go.test/test/fixedbugs/bug247.go index b6851e1bca0..6550bd87c0d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug247.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug247.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug1.go b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug1.go index 78433f504d3..f1db77d2f5d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug1.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file -package p +package q type T struct { X, Y int diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug2.go b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug2.go index ba547d64a10..c0fdecfdb7b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug2.go @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file -package main +package s import ( p0 "./bug0" p1 "./bug1" - - "reflect" - "strings" ) +// both p0.T and p1.T are struct { X, Y int }. + var v0 p0.T var v1 p1.T +// interfaces involving the two + type I0 interface { M(p0.T) } @@ -23,83 +24,50 @@ type I1 interface { M(p1.T) } +// t0 satisfies I0 and p0.I type t0 int func (t0) M(p0.T) {} +// t1 satisfies I1 and p1.I type t1 float64 func (t1) M(p1.T) {} +// check static interface assignments var i0 I0 = t0(0) // ok var i1 I1 = t1(0) // ok +var i2 I0 = t1(0) // ERROR "does not implement|incompatible" +var i3 I1 = t0(0) // ERROR "does not implement|incompatible" + var p0i p0.I = t0(0) // ok var p1i p1.I = t1(0) // ok -func main() { - // check that reflect paths are correct, - // meaning that reflect data for v0, v1 didn't get confused. - - // path is full (rooted) path name. check suffix for gc, prefix for gccgo - if s := reflect.TypeOf(v0).PkgPath(); !strings.HasSuffix(s, "/bug0") && !strings.HasPrefix(s, "bug0") { - println("bad v0 path", len(s), s) - panic("fail") - } - if s := reflect.TypeOf(v1).PkgPath(); !strings.HasSuffix(s, "/bug1") && !strings.HasPrefix(s, "bug1") { - println("bad v1 path", s) - panic("fail") - } - - // check that dynamic interface check doesn't get confused - var i interface{} = t0(0) - if _, ok := i.(I1); ok { - println("used t0 as i1") - panic("fail") - } - if _, ok := i.(p1.I); ok { - println("used t0 as p1.I") - panic("fail") - } - - i = t1(1) - if _, ok := i.(I0); ok { - println("used t1 as i0") - panic("fail") - } - if _, ok := i.(p0.I); ok { - println("used t1 as p0.I") - panic("fail") - } - - // check that type switch works. - // the worry is that if p0.T and p1.T have the same hash, - // the binary search will handle one of them incorrectly. - for j := 0; j < 3; j++ { - switch j { - case 0: - i = p0.T{} - case 1: - i = p1.T{} - case 2: - i = 3.14 - } - switch i.(type) { - case p0.T: - if j != 0 { - println("type switch p0.T") - panic("fail") - } - case p1.T: - if j != 1 { - println("type switch p1.T") - panic("fail") - } - default: - if j != 2 { - println("type switch default", j) - panic("fail") - } - } - } +var p0i1 p0.I = t1(0) // ERROR "does not implement|incompatible" +var p0i2 p1.I = t0(0) // ERROR "does not implement|incompatible" + +func foobar() { + // check that cannot assign one to the other, + // but can convert. + v0 = v1 // ERROR "assign" + v1 = v0 // ERROR "assign" + + v0 = p0.T(v1) + v1 = p1.T(v0) + + i0 = i1 // ERROR "cannot use|incompatible" + i1 = i0 // ERROR "cannot use|incompatible" + p0i = i1 // ERROR "cannot use|incompatible" + p1i = i0 // ERROR "cannot use|incompatible" + i0 = p1i // ERROR "cannot use|incompatible" + i1 = p0i // ERROR "cannot use|incompatible" + p0i = p1i // ERROR "cannot use|incompatible" + p1i = p0i // ERROR "cannot use|incompatible" + + i0 = p0i + p0i = i0 + + i1 = p1i + p1i = i1 } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug3.go b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug3.go index 4a56c5cc81c..ba547d64a10 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug3.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug248.dir/bug3.go @@ -7,15 +7,14 @@ package main import ( p0 "./bug0" p1 "./bug1" -) -// both p0.T and p1.T are struct { X, Y int }. + "reflect" + "strings" +) var v0 p0.T var v1 p1.T -// interfaces involving the two - type I0 interface { M(p0.T) } @@ -24,50 +23,83 @@ type I1 interface { M(p1.T) } -// t0 satisfies I0 and p0.I type t0 int func (t0) M(p0.T) {} -// t1 satisfies I1 and p1.I type t1 float64 func (t1) M(p1.T) {} -// check static interface assignments var i0 I0 = t0(0) // ok var i1 I1 = t1(0) // ok -var i2 I0 = t1(0) // ERROR "does not implement|incompatible" -var i3 I1 = t0(0) // ERROR "does not implement|incompatible" - var p0i p0.I = t0(0) // ok var p1i p1.I = t1(0) // ok -var p0i1 p0.I = t1(0) // ERROR "does not implement|incompatible" -var p0i2 p1.I = t0(0) // ERROR "does not implement|incompatible" - func main() { - // check that cannot assign one to the other, - // but can convert. - v0 = v1 // ERROR "assign" - v1 = v0 // ERROR "assign" - - v0 = p0.T(v1) - v1 = p1.T(v0) - - i0 = i1 // ERROR "cannot use|incompatible" - i1 = i0 // ERROR "cannot use|incompatible" - p0i = i1 // ERROR "cannot use|incompatible" - p1i = i0 // ERROR "cannot use|incompatible" - i0 = p1i // ERROR "cannot use|incompatible" - i1 = p0i // ERROR "cannot use|incompatible" - p0i = p1i // ERROR "cannot use|incompatible" - p1i = p0i // ERROR "cannot use|incompatible" - - i0 = p0i - p0i = i0 - - i1 = p1i - p1i = i1 + // check that reflect paths are correct, + // meaning that reflect data for v0, v1 didn't get confused. + + // path is full (rooted) path name. check suffix for gc, prefix for gccgo + if s := reflect.TypeOf(v0).PkgPath(); !strings.HasSuffix(s, "/bug0") && !strings.HasPrefix(s, "bug0") { + println("bad v0 path", len(s), s) + panic("fail") + } + if s := reflect.TypeOf(v1).PkgPath(); !strings.HasSuffix(s, "/bug1") && !strings.HasPrefix(s, "bug1") { + println("bad v1 path", s) + panic("fail") + } + + // check that dynamic interface check doesn't get confused + var i interface{} = t0(0) + if _, ok := i.(I1); ok { + println("used t0 as i1") + panic("fail") + } + if _, ok := i.(p1.I); ok { + println("used t0 as p1.I") + panic("fail") + } + + i = t1(1) + if _, ok := i.(I0); ok { + println("used t1 as i0") + panic("fail") + } + if _, ok := i.(p0.I); ok { + println("used t1 as p0.I") + panic("fail") + } + + // check that type switch works. + // the worry is that if p0.T and p1.T have the same hash, + // the binary search will handle one of them incorrectly. + for j := 0; j < 3; j++ { + switch j { + case 0: + i = p0.T{} + case 1: + i = p1.T{} + case 2: + i = 3.14 + } + switch i.(type) { + case p0.T: + if j != 0 { + println("type switch p0.T") + panic("fail") + } + case p1.T: + if j != 1 { + println("type switch p1.T") + panic("fail") + } + default: + if j != 2 { + println("type switch default", j) + panic("fail") + } + } + } } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug248.go b/gcc/testsuite/go.test/test/fixedbugs/bug248.go index 98cda35c491..93d2fdb6711 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug248.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug248.go @@ -1,15 +1,12 @@ -// $G $D/$F.dir/bug0.go && -// $G $D/$F.dir/bug1.go && -// $G $D/$F.dir/bug2.go && -// errchk $G -e $D/$F.dir/bug3.go && -// $L bug2.$A && -// ./$A.out || echo BUG: failed to compile - -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. +// +build !nacl,!js,!plan9 +// errorcheckandrundir -1 // Copyright 2009 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. -ignored +package ignored + +// Compile: bug0.go, bug1.go +// Compile and errorCheck: bug2.go +// Link and run: bug3.go diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug249.go b/gcc/testsuite/go.test/test/fixedbugs/bug249.go index dc922455e3f..ec9699a894e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug249.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug249.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug250.go b/gcc/testsuite/go.test/test/fixedbugs/bug250.go index 5140f3e29da..9fb34c33d5e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug250.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug250.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug252.go b/gcc/testsuite/go.test/test/fixedbugs/bug252.go index 6f007fb7714..f678925fbb6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug252.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug252.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug253.go b/gcc/testsuite/go.test/test/fixedbugs/bug253.go index f6ab712ef21..933f3f1ccc2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug253.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug253.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug254.go b/gcc/testsuite/go.test/test/fixedbugs/bug254.go index 9b1c81911b2..3902cd5e899 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug254.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug254.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug256.go b/gcc/testsuite/go.test/test/fixedbugs/bug256.go index 0498a40d548..705a0321b4e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug256.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug256.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug257.go b/gcc/testsuite/go.test/test/fixedbugs/bug257.go index 003f3ff94d4..b05c37a3312 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug257.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug257.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug258.go b/gcc/testsuite/go.test/test/fixedbugs/bug258.go index d362e5a6973..075da87577c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug258.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug258.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug259.go b/gcc/testsuite/go.test/test/fixedbugs/bug259.go index e4dcaeb2fea..857b4420100 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug259.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug259.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug261.go b/gcc/testsuite/go.test/test/fixedbugs/bug261.go index f7879b04c10..abe6431b515 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug261.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug261.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug264.go b/gcc/testsuite/go.test/test/fixedbugs/bug264.go index fcf373cce98..2f320def263 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug264.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug264.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Test case for http://code.google.com/p/go/issues/detail?id=692 +// Test case for https://golang.org/issue/692 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug265.go b/gcc/testsuite/go.test/test/fixedbugs/bug265.go index 7f06fced604..5e0516691a0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug265.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug265.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Test case for http://code.google.com/p/go/issues/detail?id=700 +// Test case for https://golang.org/issue/700 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug266.go b/gcc/testsuite/go.test/test/fixedbugs/bug266.go index d4da891d31e..5d2334c05a8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug266.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug266.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug269.go b/gcc/testsuite/go.test/test/fixedbugs/bug269.go index c13eb26ce4a..ec0dbc6c34b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug269.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug269.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=749 +// https://golang.org/issue/749 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug271.go b/gcc/testsuite/go.test/test/fixedbugs/bug271.go index 88add7040ac..a6abbfef7e8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug271.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug271.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=662 +// https://golang.org/issue/662 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug272.go b/gcc/testsuite/go.test/test/fixedbugs/bug272.go index c27f7ee446e..6b8862f6974 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug272.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug272.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=589 +// https://golang.org/issue/589 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug273.go b/gcc/testsuite/go.test/test/fixedbugs/bug273.go index 7305c6063cc..2af8800171e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug273.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug273.go @@ -14,7 +14,7 @@ var bug = false var minus1 = -1 var five = 5 -var big int64 = 10 | 1<<40 +var big int64 = 10 | 1<<46 type block [1 << 19]byte diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug274.go b/gcc/testsuite/go.test/test/fixedbugs/bug274.go index beb2d61acc8..e93f30ee969 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug274.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug274.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -13,7 +13,7 @@ // Both gccgo and gofmt correctly refuse this program as is and accept it // when the semicolons are present. -// This is a test case for issue 777 ( http://code.google.com/p/go/issues/detail?id=777 ). +// This is a test case for issue 777 ( https://golang.org/issue/777 ). package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug275.go b/gcc/testsuite/go.test/test/fixedbugs/bug275.go index f5f6b14f010..d3be7548aae 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug275.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug275.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug278.go b/gcc/testsuite/go.test/test/fixedbugs/bug278.go index 68a3d811c74..4817ebfee4e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug278.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug278.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug279.go b/gcc/testsuite/go.test/test/fixedbugs/bug279.go index e5ec5943c0d..3b1df3b8feb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug279.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug279.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=799 +// https://golang.org/issue/799 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug280.go b/gcc/testsuite/go.test/test/fixedbugs/bug280.go index ba594a2c482..afec57f037a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug280.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug280.go @@ -1,10 +1,10 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=808 +// https://golang.org/issue/808 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug281.go b/gcc/testsuite/go.test/test/fixedbugs/bug281.go index 24d6fdce8ce..c65530f7ddb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug281.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug281.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=807 +// https://golang.org/issue/807 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p1.go index b562755e5b1..0f7422c0ba0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p2.go index 3f8bd9d49b5..f6145079466 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug282.dir/p2.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug283.go b/gcc/testsuite/go.test/test/fixedbugs/bug283.go index eefed0334b0..ef1953b2feb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug283.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug283.go @@ -1,10 +1,10 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=806 +// https://golang.org/issue/806 // triggered out of registers on 8g package bug283 diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug285.go b/gcc/testsuite/go.test/test/fixedbugs/bug285.go index 0a8a0f09e60..0632ab4ba79 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug285.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug285.go @@ -1,12 +1,12 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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 for issue 778: Map key values that are assignment // compatible with the map key type must be accepted according -// to the spec: http://golang.org/doc/go_spec.html#Indexes . +// to the spec: https://golang.org/doc/go_spec.html#Indexes . package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug286.go b/gcc/testsuite/go.test/test/fixedbugs/bug286.go index 44f05153f48..b1271f465d2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug286.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug286.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug287.go b/gcc/testsuite/go.test/test/fixedbugs/bug287.go index 2ed81c593df..94582a86955 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug287.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug287.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug288.go b/gcc/testsuite/go.test/test/fixedbugs/bug288.go index d2461e6a9f3..0a53d32e9ff 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug288.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug288.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug289.go b/gcc/testsuite/go.test/test/fixedbugs/bug289.go index 3c6b68767a6..3fc7fb2eeff 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug289.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug289.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -9,14 +9,14 @@ package main func f1() { - a, b := f() // ERROR "mismatch|does not match" + a, b := f() // ERROR "assignment mismatch|does not match" _ = a _ = b } func f2() { var a, b int - a, b = f() // ERROR "mismatch|does not match" + a, b = f() // ERROR "assignment mismatch|does not match" _ = a _ = b } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug290.go b/gcc/testsuite/go.test/test/fixedbugs/bug290.go index c8ff0bc45d0..4eee285a355 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug290.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug290.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=920 +// https://golang.org/issue/920 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug291.go b/gcc/testsuite/go.test/test/fixedbugs/bug291.go index 17a5483ef54..ac84a7e5ef3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug291.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug291.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=915 +// https://golang.org/issue/915 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug292.go b/gcc/testsuite/go.test/test/fixedbugs/bug292.go index 07051dd3fbe..1130a287d86 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug292.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug292.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=843 +// https://golang.org/issue/843 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug293.go b/gcc/testsuite/go.test/test/fixedbugs/bug293.go index bf926f5a4dd..ae7cc1fd1cb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug293.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug293.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=846 +// https://golang.org/issue/846 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug294.go b/gcc/testsuite/go.test/test/fixedbugs/bug294.go index 0f3e38098c5..b35b7719162 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug294.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug294.go @@ -1,10 +1,10 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=800 +// https://golang.org/issue/800 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug295.go b/gcc/testsuite/go.test/test/fixedbugs/bug295.go index 63a12a3a741..d1c961ce1d8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug295.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug295.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug296.go b/gcc/testsuite/go.test/test/fixedbugs/bug296.go index a7c4e0c464e..2ef4e662203 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug296.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug296.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug297.go b/gcc/testsuite/go.test/test/fixedbugs/bug297.go index ee2ff92437d..c2bd253d056 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug297.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug297.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -11,5 +11,5 @@ package main type ByteSize float64 const ( _ = iota; // ignore first value by assigning to blank identifier - KB ByteSize = 1<<(10*X) // ERROR "undefined" "is not a constant|as type ByteSize" + KB ByteSize = 1<<(10*X) // ERROR "undefined" ) diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug298.go b/gcc/testsuite/go.test/test/fixedbugs/bug298.go index bd362ace2d0..0aed03216d5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug298.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug298.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug299.go b/gcc/testsuite/go.test/test/fixedbugs/bug299.go index 1067fd1478d..cf11bcc1e0e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug299.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug299.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug300.go b/gcc/testsuite/go.test/test/fixedbugs/bug300.go index 1ef43a0ad0b..1695a9640e7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug300.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug300.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug301.go b/gcc/testsuite/go.test/test/fixedbugs/bug301.go index 572668f1911..2be62b8bc80 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug301.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug301.go @@ -1,10 +1,10 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. -// http://code.google.com/p/go/issues/detail?id=990 +// https://golang.org/issue/990 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/main.go index 9f874d08f52..52c054fb4c6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/main.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/main.go @@ -1,12 +1,12 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // Check that the export information is correct in p.6. -import _ "./p" +import _ "p" // Check that it's still correct in pp.a (which contains p.6). -import _ "./pp" +import _ "pp" diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/p.go b/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/p.go index 7c54b906c23..0be521b4f88 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/p.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug302.dir/p.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug302.go b/gcc/testsuite/go.test/test/fixedbugs/bug302.go index dc7637fe52e..87f9d4ef70c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug302.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug302.go @@ -1,9 +1,45 @@ -// $G $D/bug302.dir/p.go && pack grc pp.a p.$A && $G $D/bug302.dir/main.go +// +build !nacl,!js +// run -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +package main + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" +) + +var tmpDir string + +func main() { + fb, err := filepath.Abs("fixedbugs") + if err == nil { + tmpDir, err = ioutil.TempDir("", "bug302") + } + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer os.RemoveAll(tmpDir) + + run("go", "tool", "compile", filepath.Join(fb, "bug302.dir", "p.go")) + run("go", "tool", "pack", "grc", "pp.a", "p.o") + run("go", "tool", "compile", "-I", ".", filepath.Join(fb, "bug302.dir", "main.go")) +} + +func run(cmd string, args ...string) { + c := exec.Command(cmd, args...) + c.Dir = tmpDir + out, err := c.CombinedOutput() + if err != nil { + fmt.Println(string(out)) + fmt.Println(err) + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug303.go b/gcc/testsuite/go.test/test/fixedbugs/bug303.go index 94ca07e702f..aef8b22ba78 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug303.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug303.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug304.go b/gcc/testsuite/go.test/test/fixedbugs/bug304.go index ad71b20f385..4073073eec6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug304.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug304.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug305.go b/gcc/testsuite/go.test/test/fixedbugs/bug305.go index d0a4b24b877..0c34b1a9e71 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug305.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug305.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go index bf87ea1491d..b28551807d6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go index 3f8bd9d49b5..f6145079466 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug308.go b/gcc/testsuite/go.test/test/fixedbugs/bug308.go index 5bea5175b17..a23903c49bc 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug308.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug308.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug309.go b/gcc/testsuite/go.test/test/fixedbugs/bug309.go index 948ca5c796d..d707aa3c934 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug309.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug309.go @@ -1,6 +1,6 @@ // compile -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug311.go b/gcc/testsuite/go.test/test/fixedbugs/bug311.go index edcd9759635..f5cab44c7e2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug311.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug311.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug312.go b/gcc/testsuite/go.test/test/fixedbugs/bug312.go index c7c17e10118..af423e5b293 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug312.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug312.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go index cb4ca7256b9..335f84d4ba1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go index 7eda72b4f8b..26e6413702f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.go index a7c1d3627bf..f7e023848b6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug313.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.go @@ -1,6 +1,6 @@ // errorcheckdir -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug317.go b/gcc/testsuite/go.test/test/fixedbugs/bug317.go index 3ff4dc4657e..4cd9ec28130 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug317.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug317.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug319.go b/gcc/testsuite/go.test/test/fixedbugs/bug319.go index f8e959a3185..b93106d4bdb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug319.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug319.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug320.go b/gcc/testsuite/go.test/test/fixedbugs/bug320.go index c2dd31b8131..0406b965616 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug320.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug320.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug321.go b/gcc/testsuite/go.test/test/fixedbugs/bug321.go index 7d018271fc3..19970af34c2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug321.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug321.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug323.go b/gcc/testsuite/go.test/test/fixedbugs/bug323.go index 9730ae5c8c6..3cb8eaab43f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug323.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug323.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug325.go b/gcc/testsuite/go.test/test/fixedbugs/bug325.go index 6ccd0e3c820..e6528ae46a2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug325.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug325.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug326.go b/gcc/testsuite/go.test/test/fixedbugs/bug326.go index 57f6471dc8e..75d620cde53 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug326.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug326.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug327.go b/gcc/testsuite/go.test/test/fixedbugs/bug327.go index 0598d95d682..ecb5d226842 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug327.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug327.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug328.go b/gcc/testsuite/go.test/test/fixedbugs/bug328.go index 73ab46d4591..57043f30af7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug328.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug328.go @@ -1,6 +1,6 @@ -// cmpout +// run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug329.go b/gcc/testsuite/go.test/test/fixedbugs/bug329.go index 74fc78198b3..37c93d0f6e6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug329.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug329.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug330.go b/gcc/testsuite/go.test/test/fixedbugs/bug330.go index ef6a0777fee..2f33feb4b6a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug330.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug330.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug331.go b/gcc/testsuite/go.test/test/fixedbugs/bug331.go index fac0e362894..9eb57cd3edb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug331.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug331.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug332.go b/gcc/testsuite/go.test/test/fixedbugs/bug332.go index 702779ba675..159c8b4e68b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug332.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug332.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -13,5 +13,5 @@ func main() {} // issue 1474 // important: no newline on end of next line. -// 6g used to print instead of bug332.go:111 -func (t *T) F() {} // ERROR "bug332" \ No newline at end of file +// 6g used to print instead of bug332.go:111 +func (t *T) F() {} // ERROR "undefined.*T" \ No newline at end of file diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug333.go b/gcc/testsuite/go.test/test/fixedbugs/bug333.go index bb690f0e5b6..149843a3b04 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug333.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug333.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug334.go b/gcc/testsuite/go.test/test/fixedbugs/bug334.go index bd671696ba6..9558c06ca46 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug334.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug334.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/a.go index 256c110d703..6ecc5c45ef8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/b.go index 1474470d4ce..a7735a82e41 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug335.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug335.go b/gcc/testsuite/go.test/test/fixedbugs/bug335.go index 37c97d7b5e2..fda9eb8f0a7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug335.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug335.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug336.go b/gcc/testsuite/go.test/test/fixedbugs/bug336.go index fbf23207c2e..fbcd3a51514 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug336.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug336.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug337.go b/gcc/testsuite/go.test/test/fixedbugs/bug337.go index 38dc665fa68..1a0616f70ad 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug337.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug337.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug338.go b/gcc/testsuite/go.test/test/fixedbugs/bug338.go index c2193fcc253..a4537a42329 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug338.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug338.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug339.go b/gcc/testsuite/go.test/test/fixedbugs/bug339.go index 59921d41cab..36be76170fa 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug339.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug339.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug341.go b/gcc/testsuite/go.test/test/fixedbugs/bug341.go index db1af3eaa38..baab28216f6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug341.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug341.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug342.go b/gcc/testsuite/go.test/test/fixedbugs/bug342.go index ffcb6681160..f90f6f32cc7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug342.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug342.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug343.go b/gcc/testsuite/go.test/test/fixedbugs/bug343.go index 82201088b28..fd8bd76bbfc 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug343.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug343.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug344.go b/gcc/testsuite/go.test/test/fixedbugs/bug344.go index 4a92624c769..b53abd26e3f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug344.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug344.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/io.go b/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/io.go index 1d695c30458..ca7a5092e9f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/io.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/io.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/main.go index ddba8dad40a..b77a2fad5fb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/main.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug345.dir/main.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -6,8 +6,9 @@ package main import ( "bufio" - "./io" goio "io" + + "./io" ) func main() { @@ -22,7 +23,7 @@ func main() { // main.go:27: cannot use &x (type *"io".SectionReader) as type *"/Users/rsc/g/go/test/fixedbugs/bug345.dir/io".SectionReader in function argument var w io.Writer - bufio.NewWriter(w) // ERROR "test/io|has incompatible type" + bufio.NewWriter(w) // ERROR "[\w.]+[^.]/io|has incompatible type" var x goio.SectionReader - io.SR(&x) // ERROR "test/io|has incompatible type" + io.SR(&x) // ERROR "[\w.]+[^.]/io|has incompatible type" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug345.go b/gcc/testsuite/go.test/test/fixedbugs/bug345.go index e3705f6c183..b974a61ffb2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug345.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug345.go @@ -1,10 +1,10 @@ -// $G $D/$F.dir/io.go && errchk $G -e $D/$F.dir/main.go +// +build !windows +// errorcheckdir -n -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2011 The Go Authors. All rights reserved. +// 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. package ignored + +// TODO(ysmolsky): Fix golang.org/issue/25693 to enable on Windows. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug346.go b/gcc/testsuite/go.test/test/fixedbugs/bug346.go index d9203aa4353..f69b58d1832 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug346.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug346.go @@ -9,11 +9,28 @@ package main import "os" func main() { - x := 4 - a, b, c, d := func(i int) (p int, q int, r int, s int) { return 1, i, 3, x }(2) + // Test unclosed closure. + { + x := 4 + a, b, c, d := func(i int) (p int, q int, r int, s int) { return 1, i, 3, x }(2) - if a != 1 || b != 2 || c != 3 || d != 4 { - println("abcd: expected 1 2 3 4 got", a, b, c, d) - os.Exit(1) + if a != 1 || b != 2 || c != 3 || d != 4 { + println("1# abcd: expected 1 2 3 4 got", a, b, c, d) + os.Exit(1) + } + } + // Test real closure. + { + x := 4 + gf = func(i int) (p int, q int, r int, s int) { return 1, i, 3, x } + + a, b, c, d := gf(2) + + if a != 1 || b != 2 || c != 3 || d != 4 { + println("2# abcd: expected 1 2 3 4 got", a, b, c, d) + os.Exit(1) + } } } + +var gf func(int) (int, int, int, int) diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug347.go b/gcc/testsuite/go.test/test/fixedbugs/bug347.go index 08edf0f4ffb..92afb2e7044 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug347.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug347.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug348.go b/gcc/testsuite/go.test/test/fixedbugs/bug348.go index 54a289a8de6..c7f13461593 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug348.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug348.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug349.go b/gcc/testsuite/go.test/test/fixedbugs/bug349.go index a3e6bd1619a..a6e83869a44 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug349.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug349.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug350.go b/gcc/testsuite/go.test/test/fixedbugs/bug350.go index 5ce8996ffaa..cdce1cfbe2c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug350.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug350.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug351.go b/gcc/testsuite/go.test/test/fixedbugs/bug351.go index 4c5c7c32782..8fd63e3e95f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug351.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug351.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug352.go b/gcc/testsuite/go.test/test/fixedbugs/bug352.go index 1ae2d6139b7..464ad7b8bf4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug352.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug352.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug353.go b/gcc/testsuite/go.test/test/fixedbugs/bug353.go index 2a532c49115..4a65f7774a7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug353.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug353.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug354.go b/gcc/testsuite/go.test/test/fixedbugs/bug354.go index 1245d91f5fd..293180faee5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug354.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug354.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug355.go b/gcc/testsuite/go.test/test/fixedbugs/bug355.go index fcf859b7fcc..880353a9028 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug355.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug355.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug356.go b/gcc/testsuite/go.test/test/fixedbugs/bug356.go index 273c5b8efc9..6d93860be95 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug356.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug356.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug357.go b/gcc/testsuite/go.test/test/fixedbugs/bug357.go index ceb2009be51..e9db50e88e9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug357.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug357.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug358.go b/gcc/testsuite/go.test/test/fixedbugs/bug358.go index 063c2e0bf8d..5ca0be1f6e2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug358.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug358.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -10,13 +10,14 @@ package main import ( - "io/ioutil" // GCCGO_ERROR "imported and not used" + // avoid imported and not used errors + // "io/ioutil" "net/http" - "os" // GCCGO_ERROR "imported and not used" + // "os" ) func makeHandler(fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) // ERROR "syntax error|invalid use of type" + return func(w http.ResponseWriter, r *http.Request) // ERROR "syntax error|not an expression|invalid use of type" } type Page struct { diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug361.go b/gcc/testsuite/go.test/test/fixedbugs/bug361.go index 3e3b7c18187..8e282431eb3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug361.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug361.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug362.go b/gcc/testsuite/go.test/test/fixedbugs/bug362.go index b888ccb4487..771d13d4353 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug362.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug362.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug363.go b/gcc/testsuite/go.test/test/fixedbugs/bug363.go index 615c66865cb..1bd1400987d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug363.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug363.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug365.go b/gcc/testsuite/go.test/test/fixedbugs/bug365.go index 795323bb3d2..985b6de0927 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug365.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug365.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug366.go b/gcc/testsuite/go.test/test/fixedbugs/bug366.go index 33a1a5a7ebf..3af5beaaf07 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug366.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug366.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug368.go b/gcc/testsuite/go.test/test/fixedbugs/bug368.go index c38cc7fad79..353ea5a0b1a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug368.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug368.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug369.dir/pkg.go b/gcc/testsuite/go.test/test/fixedbugs/bug369.dir/pkg.go index cf57041928a..99643472509 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug369.dir/pkg.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug369.dir/pkg.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug369.go b/gcc/testsuite/go.test/test/fixedbugs/bug369.go index 7c9583a5888..9316f7aad0b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug369.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug369.go @@ -1,11 +1,7 @@ -// $G -N -o slow.$A $D/bug369.dir/pkg.go && -// $G -o fast.$A $D/bug369.dir/pkg.go && +// +build !nacl,!js,!windows // run -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -14,50 +10,45 @@ package main import ( - "flag" + "fmt" + "io/ioutil" "os" - "runtime" - "testing" - - fast "./fast" - slow "./slow" + "os/exec" + "path/filepath" ) -var buf = make([]byte, 1048576) +func main() { + err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir")) + check(err) + + tmpDir, err := ioutil.TempDir("", "bug369") + check(err) + defer os.RemoveAll(tmpDir) -func BenchmarkFastNonASCII(b *testing.B) { - for i := 0; i < b.N; i++ { - fast.NonASCII(buf, 0) + tmp := func(name string) string { + return filepath.Join(tmpDir, name) } + + run("go", "tool", "compile", "-N", "-o", tmp("slow.o"), "pkg.go") + run("go", "tool", "compile", "-o", tmp("fast.o"), "pkg.go") + run("go", "tool", "compile", "-D", tmpDir, "-o", tmp("main.o"), "main.go") + run("go", "tool", "link", "-o", tmp("a.exe"), tmp("main.o")) + run(tmp("a.exe")) } -func BenchmarkSlowNonASCII(b *testing.B) { - for i := 0; i < b.N; i++ { - slow.NonASCII(buf, 0) +func run(name string, args ...string) { + cmd := exec.Command(name, args...) + out, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(string(out)) + fmt.Println(err) + os.Exit(1) } } -func main() { - testing.Init() - os.Args = []string{os.Args[0], "-test.benchtime=100ms"} - flag.Parse() - - rslow := testing.Benchmark(BenchmarkSlowNonASCII) - rfast := testing.Benchmark(BenchmarkFastNonASCII) - tslow := rslow.NsPerOp() - tfast := rfast.NsPerOp() - - // Optimization should be good for at least 2x, but be forgiving. - // On the ARM simulator we see closer to 1.5x. - speedup := float64(tslow)/float64(tfast) - want := 1.8 - if runtime.GOARCH == "arm" { - want = 1.3 - } - if speedup < want { - // TODO(rsc): doesn't work on linux-amd64 or darwin-amd64 builders, nor on - // a Lenovo x200 (linux-amd64) laptop. - //println("fast:", tfast, "slow:", tslow, "speedup:", speedup, "want:", want) - //println("not fast enough") +func check(err error) { + if err != nil { + fmt.Println(err) + os.Exit(1) } } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug370.go b/gcc/testsuite/go.test/test/fixedbugs/bug370.go index 246bc7c4e5b..c5165c52ccf 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug370.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug370.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug371.go b/gcc/testsuite/go.test/test/fixedbugs/bug371.go index 86c73bf4a8f..3a626e523ce 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug371.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug371.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug372.go b/gcc/testsuite/go.test/test/fixedbugs/bug372.go index 34578565afa..5fba131d7a2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug372.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug372.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug374.go b/gcc/testsuite/go.test/test/fixedbugs/bug374.go index 4f0b721f24b..2d604cbd3c6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug374.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug374.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug375.go b/gcc/testsuite/go.test/test/fixedbugs/bug375.go index cb159b0d6be..08d5afc894d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug375.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug375.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug376.go b/gcc/testsuite/go.test/test/fixedbugs/bug376.go index 5fbbc9cd444..cd700124fe5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug376.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug376.go @@ -1,11 +1,10 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. // issue 1951 package foo import "unsafe" -var v = unsafe.Sizeof // ERROR "must be called" - +var v = unsafe.Sizeof // ERROR "not in function call|must be called" diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug378.go b/gcc/testsuite/go.test/test/fixedbugs/bug378.go index f3346c648dc..c7b0dac3132 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug378.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug378.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug379.go b/gcc/testsuite/go.test/test/fixedbugs/bug379.go index 14abe469bec..5638123d502 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug379.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug379.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug380.go b/gcc/testsuite/go.test/test/fixedbugs/bug380.go index 96e1edecac8..0cb34873272 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug380.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug380.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug381.go b/gcc/testsuite/go.test/test/fixedbugs/bug381.go index 0253e1446bc..a0a1c8aaa44 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug381.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug381.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug382.dir/pkg.go b/gcc/testsuite/go.test/test/fixedbugs/bug382.dir/pkg.go index f8d75d45419..92fe4e335a1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug382.dir/pkg.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug382.dir/pkg.go @@ -1,4 +1,4 @@ -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug383.go b/gcc/testsuite/go.test/test/fixedbugs/bug383.go index 503779c3772..dc2ecd61fbd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug383.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug383.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug384.go b/gcc/testsuite/go.test/test/fixedbugs/bug384.go index 0233c197c4e..d02352b4784 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug384.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug384.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug385_32.go b/gcc/testsuite/go.test/test/fixedbugs/bug385_32.go index 4c3cad7798e..73a1311f322 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug385_32.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug385_32.go @@ -1,7 +1,7 @@ -// +build 386 arm +// +build 386 amd64p32 arm // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug385_64.go b/gcc/testsuite/go.test/test/fixedbugs/bug385_64.go index 6789c0abf0f..0f941ca2f4d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug385_64.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug385_64.go @@ -1,7 +1,7 @@ // +build amd64 // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug386.go b/gcc/testsuite/go.test/test/fixedbugs/bug386.go index ec358bd36e4..889c8b0c125 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug386.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug386.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug387.go b/gcc/testsuite/go.test/test/fixedbugs/bug387.go index 59d5ef90384..d8854457446 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug387.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug387.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug389.go b/gcc/testsuite/go.test/test/fixedbugs/bug389.go index 55a02e05c07..14804c84715 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug389.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug389.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug391.go b/gcc/testsuite/go.test/test/fixedbugs/bug391.go index 07d129ddc48..9211b1c2cf4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug391.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug391.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/one.go index 8242f284620..aba8649b5b1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg2.go b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg2.go index 8320b2fffa2..2ee41f02510 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg3.go b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg3.go index 402c3b083fd..1403798bd30 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg3.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug392.dir/pkg3.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug393.go b/gcc/testsuite/go.test/test/fixedbugs/bug393.go index f8a9c657819..61af578c531 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug393.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug393.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug394.go b/gcc/testsuite/go.test/test/fixedbugs/bug394.go index 2d77156c1ae..08bac182f70 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug394.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug394.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/one.go index 96a1dd7dc26..66eba63f5c1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/two.go b/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/two.go index 9b32508fd4f..9152bec2545 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/two.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug396.dir/two.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug397.go b/gcc/testsuite/go.test/test/fixedbugs/bug397.go index 56cc7cdd4d4..6188e3ee0cc 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug397.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug397.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug398.go b/gcc/testsuite/go.test/test/fixedbugs/bug398.go index 1dd3fa4213a..a1583bd7746 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug398.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug398.go @@ -1,23 +1,43 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Used to crash compiler in interface type equality check. +// (This test used to have problems - see #15596.) package p +// exported interfaces + type I1 interface { F() interface{I1} } type I2 interface { F() interface{I2} -} +} + +var V1 I1 +var V2 I2 + +func F() bool { + return V1 == V2 +} + +// non-exported interfaces + +type i1 interface { + F() interface{i1} +} + +type i2 interface { + F() interface{i2} +} -var v1 I1 -var v2 I2 +var v1 i1 +var v2 i2 func f() bool { return v1 == v2 diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug399.go b/gcc/testsuite/go.test/test/fixedbugs/bug399.go index 94852c9ee58..e460d812277 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug399.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug399.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug401.go b/gcc/testsuite/go.test/test/fixedbugs/bug401.go index 5589b5b1bb0..215498e0857 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug401.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug401.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -9,9 +9,8 @@ package main type T struct{} +//go:noinline func (T) cplx() complex128 { - for false { - } // avoid inlining return complex(1, 0) } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug402.go b/gcc/testsuite/go.test/test/fixedbugs/bug402.go index db3f3da448e..f9f554d817d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug402.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug402.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug403.go b/gcc/testsuite/go.test/test/fixedbugs/bug403.go index ed7b49aea2f..aa3c1ea61fa 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug403.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug403.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/one.go index 2024eb007cd..9fc47707891 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/two.go b/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/two.go index 162eae7124a..0c70a23a9e4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/two.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug404.dir/two.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug406.go b/gcc/testsuite/go.test/test/fixedbugs/bug406.go index c6f8534c9ba..32cf3e35d27 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug406.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug406.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. @@ -14,6 +14,8 @@ type matrix struct { func (a matrix) equal() bool { for _ = range a.e { } + for range a.e { + } return true } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/one.go index a91d904333b..c85b077b66c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/two.go b/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/two.go index 67e1852ea0e..640305c6541 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/two.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug407.dir/two.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug409.go b/gcc/testsuite/go.test/test/fixedbugs/bug409.go index 1dca43b7ae4..e8546361ab4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug409.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug409.go @@ -1,6 +1,6 @@ -// cmpout +// run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug410.go b/gcc/testsuite/go.test/test/fixedbugs/bug410.go index 430ddcbb523..a4eef64d8e9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug410.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug410.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug411.go b/gcc/testsuite/go.test/test/fixedbugs/bug411.go index 3b90db88d61..a1c36f617c7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug411.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug411.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug412.go b/gcc/testsuite/go.test/test/fixedbugs/bug412.go index c7ddc0cac83..183fb7e4af0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug412.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug412.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug413.go b/gcc/testsuite/go.test/test/fixedbugs/bug413.go index ba80464907b..819bd1a984e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug413.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug413.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/p1.go index 24638348433..143e600073f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/prog.go b/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/prog.go index f55d9469689..8945d6543d6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/prog.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug414.dir/prog.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug414.go b/gcc/testsuite/go.test/test/fixedbugs/bug414.go index 35e19be38e2..5b435b4aeb9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug414.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug414.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/p.go b/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/p.go index b4152d63a73..e86a697643b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/p.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/p.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/prog.go b/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/prog.go index b894453fc37..1ffde188b78 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/prog.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug415.dir/prog.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug415.go b/gcc/testsuite/go.test/test/fixedbugs/bug415.go index 8cd4c49f24e..daf4f0c8ce4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug415.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug415.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug416.go b/gcc/testsuite/go.test/test/fixedbugs/bug416.go index 1d24fa935da..9fc3532f1d6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug416.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug416.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/lib.go b/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/lib.go index 97054da3a31..31df8c600f3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/lib.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/lib.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/main.go index c2fe1463cd6..28b41e68a73 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/main.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug424.dir/main.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug424.go b/gcc/testsuite/go.test/test/fixedbugs/bug424.go index 59c2cd35c4c..9c59abe8026 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug424.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug424.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug425.go b/gcc/testsuite/go.test/test/fixedbugs/bug425.go index 5546bd96ba5..c3035f6a915 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug425.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug425.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// http://code.google.com/p/go/issues/detail?id=3119 +// https://golang.org/issue/3119 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug427.go b/gcc/testsuite/go.test/test/fixedbugs/bug427.go index 1239e7a3324..c13bb815ca4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug427.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug427.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// http://code.google.com/p/go/issues/detail?id=3351 +// https://golang.org/issue/3351 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug428.go b/gcc/testsuite/go.test/test/fixedbugs/bug428.go index 298c4551834..d9ad276a311 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug428.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug428.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug429.go b/gcc/testsuite/go.test/test/fixedbugs/bug429.go index 794d293db2f..2c31f32da7b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug429.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug429.go @@ -1,13 +1,11 @@ -// $G $D/$F.go && $L $F.$A && ! ./$A.out || echo BUG: bug429 +// skip -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Should print deadlock message, not hang. +// This test is run by bug429_run.go. package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug435.go b/gcc/testsuite/go.test/test/fixedbugs/bug435.go index 45323d8eed6..692a4920165 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug435.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug435.go @@ -1,13 +1,13 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Test that a syntax error caused by an unexpected EOF // gives an error message with the correct line number. // -// https://code.google.com/p/go/issues/detail?id=3392 +// https://golang.org/issue/3392 package main diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/one.go index 8d3caadae13..633573e51d1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/two.go b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/two.go index 406dd5903e3..61da121d513 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/two.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/two.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/x.go b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/x.go index 364d017afa7..585b480c0a9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/x.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug437.dir/x.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug437.go b/gcc/testsuite/go.test/test/fixedbugs/bug437.go index 5c4a2ad0dcf..98adce7cb4c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug437.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug437.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug441.go b/gcc/testsuite/go.test/test/fixedbugs/bug441.go index 8562bfeef85..b67125b1e88 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug441.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug441.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug442.go b/gcc/testsuite/go.test/test/fixedbugs/bug442.go index 1d1a948161a..684d54ffbbd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug442.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug442.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug443.go b/gcc/testsuite/go.test/test/fixedbugs/bug443.go index b67bd8cb875..9abd2548a58 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug443.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug443.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug444.go b/gcc/testsuite/go.test/test/fixedbugs/bug444.go index b54fb4f5817..29a60f590f0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug444.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug444.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug445.go b/gcc/testsuite/go.test/test/fixedbugs/bug445.go index 497ecd3abae..45c32902e58 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug445.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug445.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug447.go b/gcc/testsuite/go.test/test/fixedbugs/bug447.go index a4c871bdbf6..8358f0034f9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug447.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug447.go @@ -1,6 +1,6 @@ // runoutput -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg1.go b/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg1.go index 032e5d9de3b..291903ca459 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg2.go b/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg2.go index 5c78c7d2f3c..20d850915dd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug448.dir/pkg2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug448.go b/gcc/testsuite/go.test/test/fixedbugs/bug448.go index 242f5999e84..481acda3284 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug448.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug448.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug450.go b/gcc/testsuite/go.test/test/fixedbugs/bug450.go index 3f13de16ceb..af27b723659 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug450.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug450.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug452.go b/gcc/testsuite/go.test/test/fixedbugs/bug452.go index d2e4a0b44a6..f1f8b08e63b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug452.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug452.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug453.go b/gcc/testsuite/go.test/test/fixedbugs/bug453.go index 136abefb7d2..1f4f3ea9bd8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug453.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug453.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug454.go b/gcc/testsuite/go.test/test/fixedbugs/bug454.go index a10abba8b28..9e3344d5124 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug454.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug454.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug455.go b/gcc/testsuite/go.test/test/fixedbugs/bug455.go index 8e3c7701be0..9f6974d0643 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug455.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug455.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug456.go b/gcc/testsuite/go.test/test/fixedbugs/bug456.go index 064e1aa0281..c77a76d057a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug456.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug456.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug457.go b/gcc/testsuite/go.test/test/fixedbugs/bug457.go index ee7048972af..84f8db45662 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug457.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug457.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug458.go b/gcc/testsuite/go.test/test/fixedbugs/bug458.go index ddc97bdb0cc..6332697bd23 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug458.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug458.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug459.go b/gcc/testsuite/go.test/test/fixedbugs/bug459.go index 014f2ef01f7..c71cb1bd082 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug459.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug459.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/a.go index 29049d9aae5..51c6836be7e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/b.go index 5c0a0c47e3c..ef646946cf1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug460.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug460.go b/gcc/testsuite/go.test/test/fixedbugs/bug460.go index 79234a3b963..a1b6f477ffd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug460.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug460.go @@ -1,6 +1,6 @@ // errorcheckdir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug461.go b/gcc/testsuite/go.test/test/fixedbugs/bug461.go index f0f7b0e69b6..d7fe8026e8d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug461.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug461.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug462.go b/gcc/testsuite/go.test/test/fixedbugs/bug462.go index 1a23ad064dc..3df63b091dd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug462.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug462.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug463.go b/gcc/testsuite/go.test/test/fixedbugs/bug463.go index 3e7a1848270..c7f92379c84 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug463.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug463.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug464.go b/gcc/testsuite/go.test/test/fixedbugs/bug464.go index 582193997a1..3e2c18a822c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug464.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug464.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/a.go index a9a8614bb33..3e5d012e6a1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/b.go index c84c6836d62..db7f7315e6a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug465.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug465.go b/gcc/testsuite/go.test/test/fixedbugs/bug465.go index a6ef5876ab6..84ff07b9487 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug465.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug465.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/a.go index b9de63edabe..e27699c2ef5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/b.go index 82d66eacef9..04e3626c752 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug466.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug466.go b/gcc/testsuite/go.test/test/fixedbugs/bug466.go index 6b65b33b0a8..dc909d483cd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug466.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug466.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug467.go b/gcc/testsuite/go.test/test/fixedbugs/bug467.go index d73adbadffc..4126f92eae5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug467.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug467.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p1.go index ca175770fc1..cdda735e965 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p2.go index 1793c0e534e..dbb46931b82 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug468.dir/p2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug468.go b/gcc/testsuite/go.test/test/fixedbugs/bug468.go index 12e4997d36b..77941ce55ce 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug468.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug468.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug470.go b/gcc/testsuite/go.test/test/fixedbugs/bug470.go index 0a359184c60..c21663f3f31 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug470.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug470.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug471.go b/gcc/testsuite/go.test/test/fixedbugs/bug471.go index e4542596e9a..343661f08d5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug471.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug471.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p1.go index 9d47fd84a72..cda1aa7aa8c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p2.go index 34a3f0487a4..581ec400200 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/p2.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/z.go b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/z.go index 6c29dd08c61..eb791bf443a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/z.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug472.dir/z.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug472.go b/gcc/testsuite/go.test/test/fixedbugs/bug472.go index c79c64ca1ff..6939e641ceb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug472.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug472.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug473.go b/gcc/testsuite/go.test/test/fixedbugs/bug473.go index 49ce7d73791..7649b6b5e00 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug473.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug473.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug474.go b/gcc/testsuite/go.test/test/fixedbugs/bug474.go index b8264872a98..1efabe460a6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug474.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug474.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug475.go b/gcc/testsuite/go.test/test/fixedbugs/bug475.go index 1bd6fa35ce7..0145aabf411 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug475.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug475.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug476.go b/gcc/testsuite/go.test/test/fixedbugs/bug476.go index 4ea21740484..8695f95c42f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug476.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug476.go @@ -1,11 +1,11 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. // Logical operation on named boolean type returns the same type, -// supporting an implicit convertion to an interface type. This used +// supporting an implicit conversion to an interface type. This used // to crash gccgo. package p diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug477.go b/gcc/testsuite/go.test/test/fixedbugs/bug477.go index 86289afa6db..f1fbffa2118 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug477.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug477.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/a.go index a40e454f9b1..b5a2dbcdb88 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/b.go index c0fdf1127b4..cfd1d273d8e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug478.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug478.go b/gcc/testsuite/go.test/test/fixedbugs/bug478.go index 5e339e801d5..8757f461532 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug478.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug478.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/a.go index 5ff3bef1d16..eddb4cf0781 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/b.go index a1b27b33264..9f3f5e8f523 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug479.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug479.go b/gcc/testsuite/go.test/test/fixedbugs/bug479.go index f8a0f93c736..80012ba8e46 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug479.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug479.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/a.go index 6dff51586b7..26a8d116697 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/b.go index 620736540ae..5bd40f6205e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug480.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug480.go b/gcc/testsuite/go.test/test/fixedbugs/bug480.go index 5b44af43083..ad2f73c16b9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug480.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug480.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug481.go b/gcc/testsuite/go.test/test/fixedbugs/bug481.go index d0922a5a4ff..13a53392da5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug481.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug481.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug482.go b/gcc/testsuite/go.test/test/fixedbugs/bug482.go index 10c48287d3a..0e5417dee75 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug482.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug482.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue2615.go b/gcc/testsuite/go.test/test/fixedbugs/issue2615.go index 686e1e1ada3..831110e08b1 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue2615.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue2615.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/one.go b/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/one.go index 491ada1d9c4..e594db7478b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/one.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/one.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/two.go b/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/two.go index 1366d244d3e..2f330bfdf3b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/two.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue3552.dir/two.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3705.go b/gcc/testsuite/go.test/test/fixedbugs/issue3705.go index 64ef38b10d5..ed0a193dcfb 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3705.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue3705.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3783.go b/gcc/testsuite/go.test/test/fixedbugs/issue3783.go index d7a4a2e8f3c..7db06d1881d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3783.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue3783.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3924.go b/gcc/testsuite/go.test/test/fixedbugs/issue3924.go deleted file mode 100644 index eb7a665bdc1..00000000000 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3924.go +++ /dev/null @@ -1,13 +0,0 @@ -// compile - -// 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 foo - -type mybool bool - -var x, y = 1, 2 -var _ mybool = x < y && x < y -var _ mybool = x < y || x < y diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue3925.go b/gcc/testsuite/go.test/test/fixedbugs/issue3925.go index a62d4392e6f..628c222685e 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue3925.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue3925.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go index 089637d86b8..200290a081d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4085a.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go b/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go index 6304ce073aa..cf27512da0b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4085b.go @@ -19,29 +19,36 @@ func main() { shouldPanic("cap out of range", func() { _ = make(T, 0, n) }) shouldPanic("len out of range", func() { _ = make(T, int64(n)) }) shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) }) + testMakeInAppend(n) + var t *byte if unsafe.Sizeof(t) == 8 { // Test mem > maxAlloc var n2 int64 = 1 << 59 shouldPanic("len out of range", func() { _ = make(T, int(n2)) }) shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) }) + testMakeInAppend(int(n2)) // Test elem.size*cap overflow n2 = 1<<63 - 1 shouldPanic("len out of range", func() { _ = make(T, int(n2)) }) shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) }) + testMakeInAppend(int(n2)) + var x uint64 = 1<<64 - 1 + shouldPanic("len out of range", func() { _ = make([]byte, x) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, x) }) + testMakeInAppend(int(x)) } else { n = 1<<31 - 1 shouldPanic("len out of range", func() { _ = make(T, n) }) shouldPanic("cap out of range", func() { _ = make(T, 0, n) }) shouldPanic("len out of range", func() { _ = make(T, int64(n)) }) shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) }) + testMakeInAppend(n) + var x uint64 = 1<<32 - 1 + shouldPanic("len out of range", func() { _ = make([]byte, x) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, x) }) + testMakeInAppend(int(x)) } - - // Test make in append panics since the gc compiler optimizes makes in appends. - shouldPanic("len out of range", func() { _ = append(T{}, make(T, n)...) }) - shouldPanic("cap out of range", func() { _ = append(T{}, make(T, 0, n)...) }) - shouldPanic("len out of range", func() { _ = append(T{}, make(T, int64(n))...) }) - shouldPanic("cap out of range", func() { _ = append(T{}, make(T, 0, int64(n))...) }) } func shouldPanic(str string, f func()) { @@ -58,3 +65,21 @@ func shouldPanic(str string, f func()) { f() } + +// Test make in append panics since the gc compiler optimizes makes in appends. +func testMakeInAppend(n int) { + lengths := []int{0, 1} + for _, length := range lengths { + t := make(T, length) + shouldPanic("len out of range", func() { _ = append(t, make(T, n)...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, n)...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, int64(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, int64(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, uint64(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, uint64(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, int(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, int(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, uint(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, uint(n))...) }) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4097.go b/gcc/testsuite/go.test/test/fixedbugs/issue4097.go index c2b7d9b4fbf..30b65bce833 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4097.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4097.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4099.go b/gcc/testsuite/go.test/test/fixedbugs/issue4099.go index 89392bfff1d..5a4ea7c9988 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4099.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4099.go @@ -1,6 +1,6 @@ // errorcheck -0 -m -// Copyright 2013 The Go Authors. All rights reserved. +// 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. @@ -19,8 +19,8 @@ func F2([]byte) func G() { var buf1 [10]byte - F1(buf1[:]) // ERROR "buf1 does not escape" + F1(buf1[:]) var buf2 [10]byte // ERROR "moved to heap: buf2" - F2(buf2[:]) // ERROR "buf2 escapes to heap" + F2(buf2[:]) } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4162.go b/gcc/testsuite/go.test/test/fixedbugs/issue4162.go index c2a8338c705..f236bd0f6a8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4162.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4162.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4167.go b/gcc/testsuite/go.test/test/fixedbugs/issue4167.go index 4e353312b87..86a636f66bd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4167.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4167.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4232.go b/gcc/testsuite/go.test/test/fixedbugs/issue4232.go index e5daa656235..30d132683a9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4232.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4232.go @@ -1,9 +1,12 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// issue 4232 +// issue 7200 + package p func f() { @@ -12,22 +15,42 @@ func f() { _ = a[-1:] // ERROR "invalid slice index -1|index out of bounds" _ = a[:-1] // ERROR "invalid slice index -1|index out of bounds" _ = a[10] // ERROR "invalid array index 10|index out of bounds" + _ = a[9:10] + _ = a[10:10] + _ = a[9:12] // ERROR "invalid slice index 12|index out of bounds" + _ = a[11:12] // ERROR "invalid slice index 11|index out of bounds" + _ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds" var s []int _ = s[-1] // ERROR "invalid slice index -1|index out of bounds" _ = s[-1:] // ERROR "invalid slice index -1|index out of bounds" _ = s[:-1] // ERROR "invalid slice index -1|index out of bounds" _ = s[10] + _ = s[9:10] + _ = s[10:10] + _ = s[9:12] + _ = s[11:12] + _ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds" - const c = "foo" + const c = "foofoofoof" _ = c[-1] // ERROR "invalid string index -1|index out of bounds" _ = c[-1:] // ERROR "invalid slice index -1|index out of bounds" _ = c[:-1] // ERROR "invalid slice index -1|index out of bounds" - _ = c[3] // ERROR "invalid string index 3|index out of bounds" + _ = c[10] // ERROR "invalid string index 10|index out of bounds" + _ = c[9:10] + _ = c[10:10] + _ = c[9:12] // ERROR "invalid slice index 12|index out of bounds" + _ = c[11:12] // ERROR "invalid slice index 11|index out of bounds" + _ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds" var t string _ = t[-1] // ERROR "invalid string index -1|index out of bounds" _ = t[-1:] // ERROR "invalid slice index -1|index out of bounds" _ = t[:-1] // ERROR "invalid slice index -1|index out of bounds" - _ = t[3] + _ = t[10] + _ = t[9:10] + _ = t[10:10] + _ = t[9:12] + _ = t[11:12] + _ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow" "invalid slice index 1 << 100|index out of bounds" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4251.go b/gcc/testsuite/go.test/test/fixedbugs/issue4251.go index 3668d4c89a8..d11ce51b971 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4251.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4251.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/a.go index 089b6f20f42..a587e28da79 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/main.go index 28e43422478..02d9836e98d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/main.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4252.dir/main.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4252.go b/gcc/testsuite/go.test/test/fixedbugs/issue4252.go index 1b0e5b20289..01bcbc43319 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4252.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4252.go @@ -1,6 +1,6 @@ // rundir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4283.go b/gcc/testsuite/go.test/test/fixedbugs/issue4283.go index 128c87231ab..fa5629b20a9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4283.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4283.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4313.go b/gcc/testsuite/go.test/test/fixedbugs/issue4313.go index b2f69dbfa41..2494b83b03b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4313.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4313.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4316.go b/gcc/testsuite/go.test/test/fixedbugs/issue4316.go index bb18a089624..de9a61b497d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4316.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4316.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4323.go b/gcc/testsuite/go.test/test/fixedbugs/issue4323.go index 6bb78f43cf8..f082a1fb79f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4323.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4323.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4326.go b/gcc/testsuite/go.test/test/fixedbugs/issue4326.go index 5ce2eea2661..6a510f990d4 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4326.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4326.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4348.go b/gcc/testsuite/go.test/test/fixedbugs/issue4348.go index 3dac8f7685c..8b1a56c1d51 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4348.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4348.go @@ -1,12 +1,14 @@ -// compile +// skip -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Issue 4348. After switch to 64-bit ints the compiler generates // illegal instructions when using large array bounds or indexes. +// Skip. We reject symbols larger that 2GB (Issue #9862). + package main // 1<<32 on a 64-bit machine, 1 otherwise. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4353.go b/gcc/testsuite/go.test/test/fixedbugs/issue4353.go index defe7c324c2..6a17c461620 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4353.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4353.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4359.go b/gcc/testsuite/go.test/test/fixedbugs/issue4359.go index b5adb4010b8..c79e9e218c9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4359.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4359.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p1.go index d732c8b363e..d010e936534 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p2.go index 33370d07a4e..0d3e23625ec 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p3.go b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p3.go index 13c996bc229..c275c6e222d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p3.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4370.dir/p3.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4370.go b/gcc/testsuite/go.test/test/fixedbugs/issue4370.go index 76b47e1a6d5..b1d036464a8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4370.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4370.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4396a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4396a.go index 11ae1f7c6c6..38dd4b8cfb3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4396a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4396a.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4396b.go b/gcc/testsuite/go.test/test/fixedbugs/issue4396b.go index d0bf28fac28..1284870ece6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4396b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4396b.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4399.go b/gcc/testsuite/go.test/test/fixedbugs/issue4399.go index 6674db9ec30..3dc212620af 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4399.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4399.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4405.go b/gcc/testsuite/go.test/test/fixedbugs/issue4405.go index b8458d77647..5ba3e1066cd 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4405.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4405.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4429.go b/gcc/testsuite/go.test/test/fixedbugs/issue4429.go index 6822760ef8c..9eb2e0f9c2a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4429.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4429.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4448.go b/gcc/testsuite/go.test/test/fixedbugs/issue4448.go index fa1d9fe49d3..f5e47150eea 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4448.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4448.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4452.go b/gcc/testsuite/go.test/test/fixedbugs/issue4452.go index 54dd214d69f..f91bd2c0fbe 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4452.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4452.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4458.go b/gcc/testsuite/go.test/test/fixedbugs/issue4458.go index 82b104a0fdf..59cfa9fcee8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4458.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4458.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. @@ -16,5 +16,5 @@ func (T) foo() {} func main() { av := T{} pav := &av - (**T).foo(&pav) // ERROR "no method|requires named type or pointer to named" + (**T).foo(&pav) // ERROR "no method .*foo|requires named type or pointer to named" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4463.go b/gcc/testsuite/go.test/test/fixedbugs/issue4463.go index 70977ceb782..6ad1952d672 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4463.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4463.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4468.go b/gcc/testsuite/go.test/test/fixedbugs/issue4468.go index ef0b46bcf68..d26725ec013 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4468.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4468.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. @@ -19,8 +19,12 @@ type S struct { } func F() { - go (F()) // ERROR "must be function call" - defer (F()) // ERROR "must be function call" + go F // ERROR "must be function call" + defer F // ERROR "must be function call" + go (F) // ERROR "must be function call|must not be parenthesized" + defer (F) // ERROR "must be function call|must not be parenthesized" + go (F()) // ERROR "must be function call|must not be parenthesized" + defer (F()) // ERROR "must be function call|must not be parenthesized" var s S (&s.t).F() go (&s.t).F() diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4470.go b/gcc/testsuite/go.test/test/fixedbugs/issue4470.go index 5ed09ca554b..d9224784558 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4470.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4470.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4495.go b/gcc/testsuite/go.test/test/fixedbugs/issue4495.go index 7ec1134d7b6..308acc22801 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4495.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4495.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4517a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4517a.go index a1b6b57e974..83d42e7e509 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4517a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4517a.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4517b.go b/gcc/testsuite/go.test/test/fixedbugs/issue4517b.go index f04103ff5b2..34fa98f8af8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4517b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4517b.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4517c.go b/gcc/testsuite/go.test/test/fixedbugs/issue4517c.go index 47b21cf4084..9023e0a8469 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4517c.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4517c.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4517d.go b/gcc/testsuite/go.test/test/fixedbugs/issue4517d.go index 3d727d433ed..197c225c6f0 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4517d.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4517d.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4518.go b/gcc/testsuite/go.test/test/fixedbugs/issue4518.go index e64b069bb99..c482b0f114a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4518.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4518.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. @@ -10,15 +10,13 @@ package main -func DontInline() {} - +//go:noinline func F(e interface{}) (int, int) { - DontInline() return 3, 7 } +//go:noinline func G() (int, int) { - DontInline() return 3, 7 } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4529.go b/gcc/testsuite/go.test/test/fixedbugs/issue4529.go index 4f37e7c36b6..66b96c73c73 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4529.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4529.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4545.go b/gcc/testsuite/go.test/test/fixedbugs/issue4545.go index c37ccef7cbf..534ba7113af 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4545.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4545.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4562.go b/gcc/testsuite/go.test/test/fixedbugs/issue4562.go index 29d98b0283d..8c958f5725d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4562.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4562.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4585.go b/gcc/testsuite/go.test/test/fixedbugs/issue4585.go index ad1242d1e5f..9191ec5df88 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4585.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4585.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg1.go b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg1.go index c447371c1ab..96cac0a5c1c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg1.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg2.go b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg2.go index 61c01d7aec2..98bc2a52fb9 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg2.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/pkg2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/prog.go b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/prog.go index 3220e85d3a6..32055b28e24 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/prog.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4590.dir/prog.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4614.go b/gcc/testsuite/go.test/test/fixedbugs/issue4614.go index 1aa318c2b23..ad378d8c531 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4614.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4614.go @@ -1,6 +1,6 @@ // compile -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4618.go b/gcc/testsuite/go.test/test/fixedbugs/issue4618.go index fe875b35013..0ba95230cf3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4618.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4618.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4620.go b/gcc/testsuite/go.test/test/fixedbugs/issue4620.go index 7b4ebf944d6..5aa29086f79 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4620.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4620.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4654.go b/gcc/testsuite/go.test/test/fixedbugs/issue4654.go index d3f582b20c6..76aff76a678 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4654.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4654.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4663.go b/gcc/testsuite/go.test/test/fixedbugs/issue4663.go index edaee93c5b7..971290d8ddf 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4663.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4663.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4667.go b/gcc/testsuite/go.test/test/fixedbugs/issue4667.go index 18d773c2cfb..31b32841be3 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4667.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4667.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4734.go b/gcc/testsuite/go.test/test/fixedbugs/issue4734.go index 69f66f2129f..45e609d5084 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4734.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4734.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4748.go b/gcc/testsuite/go.test/test/fixedbugs/issue4748.go index 73c75393cf4..f7c77cf882f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4748.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4748.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4752.go b/gcc/testsuite/go.test/test/fixedbugs/issue4752.go index d6781e39a22..af7bb92b58a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4752.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4752.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4776.go b/gcc/testsuite/go.test/test/fixedbugs/issue4776.go index 13781af1f36..a1009ad9613 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4776.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4776.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4785.go b/gcc/testsuite/go.test/test/fixedbugs/issue4785.go index c3dd6297d85..d0bcd56c711 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4785.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4785.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4909a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4909a.go index aefe2d64557..09e1b850990 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4909a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4909a.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue4964.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue4964.dir/a.go index 2b9e44e351a..216f352ca95 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue4964.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue4964.dir/a.go @@ -10,16 +10,14 @@ type T struct { Pointer *int } -func dontinline() {} - +//go:noinline func Store(t *T) { global = t.Pointer - dontinline() } +//go:noinline func Store2(t *T) { global2 = t.Pointer - dontinline() } func Get() *int { diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5002.go b/gcc/testsuite/go.test/test/fixedbugs/issue5002.go index 1e74fa1a1f6..5ac119a2b28 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5002.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5002.go @@ -1,6 +1,6 @@ // build -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5056.go b/gcc/testsuite/go.test/test/fixedbugs/issue5056.go index a2cde2a501e..6fb444aa679 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5056.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5056.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5172.go b/gcc/testsuite/go.test/test/fixedbugs/issue5172.go index a6acbd3db78..ed92ac6ff2b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5172.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5172.go @@ -12,8 +12,15 @@ type foo struct { x bar // ERROR "undefined" } +type T struct{} + +func (t T) Bar() {} + func main() { var f foo - go f.bar() // GCCGO_ERROR "undefined" - defer f.bar() // GCCGO_ERROR "undefined" + go f.bar() // ERROR "undefined" + defer f.bar() // ERROR "undefined" + + t := T{1} // ERROR "too many" + go t.Bar() } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5231.go b/gcc/testsuite/go.test/test/fixedbugs/issue5231.go index 4039913dc90..6bc882675f2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5231.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5231.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5358.go b/gcc/testsuite/go.test/test/fixedbugs/issue5358.go index c2b1da9e0e1..25f1e521fe8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5358.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5358.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5581.go b/gcc/testsuite/go.test/test/fixedbugs/issue5581.go index 36a4ad671d2..8834b4453d8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5581.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5581.go @@ -3,7 +3,7 @@ // Used to emit a spurious "invalid recursive type" error. // See golang.org/issue/5581. -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5698.go b/gcc/testsuite/go.test/test/fixedbugs/issue5698.go index 035bbd35d25..081541cb87d 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5698.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5698.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5704.go b/gcc/testsuite/go.test/test/fixedbugs/issue5704.go index 1dfa072143e..11b9a93246c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5704.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5704.go @@ -1,6 +1,6 @@ // run -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5809.go b/gcc/testsuite/go.test/test/fixedbugs/issue5809.go index ca060b55de6..fc8eeef82fa 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5809.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5809.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5820.go b/gcc/testsuite/go.test/test/fixedbugs/issue5820.go index 94de06d57db..1046d66afbe 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5820.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5820.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5841.go b/gcc/testsuite/go.test/test/fixedbugs/issue5841.go index cfc4a504c5a..2be1aeefb14 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5841.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5841.go @@ -1,6 +1,6 @@ // build -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5856.go b/gcc/testsuite/go.test/test/fixedbugs/issue5856.go index 35cadf8c9e7..f13258854e5 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5856.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5856.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue5963.go b/gcc/testsuite/go.test/test/fixedbugs/issue5963.go index 190e8f45647..f828303e492 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue5963.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue5963.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6004.go b/gcc/testsuite/go.test/test/fixedbugs/issue6004.go index 45aaffd2c90..2b3dcd923d6 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6004.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6004.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6036.go b/gcc/testsuite/go.test/test/fixedbugs/issue6036.go index 5f787c56900..8ebef5a447c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6036.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6036.go @@ -1,7 +1,7 @@ -// +build amd64 +// +build !386,!arm,!mips,!mipsle,!amd64p32 // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6055.go b/gcc/testsuite/go.test/test/fixedbugs/issue6055.go index 698f62ac956..459434892aa 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6055.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6055.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6131.go b/gcc/testsuite/go.test/test/fixedbugs/issue6131.go index 817e4a877cd..61548a2d52b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6131.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6131.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6140.go b/gcc/testsuite/go.test/test/fixedbugs/issue6140.go index d494933b2e2..dde7921d92f 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6140.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6140.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6247.go b/gcc/testsuite/go.test/test/fixedbugs/issue6247.go index eea8f9c878f..2786786ae11 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6247.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6247.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6269.go b/gcc/testsuite/go.test/test/fixedbugs/issue6269.go index af5feb72866..2930f52c8fe 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6269.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6269.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6298.go b/gcc/testsuite/go.test/test/fixedbugs/issue6298.go index 6303dbe5b09..ab3bfcdfe7c 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6298.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6298.go @@ -3,7 +3,7 @@ // golang.org/issue/6298. // Used to cause "internal error: typename ideal bool" -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/a.go index da90ca377b4..e5536feb61a 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/a.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/a.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/b.go index 3b35b2d324b..ce3d52ec1ab 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/b.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/b.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/main.go index f09b7274821..8d8c02b9076 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/main.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6513.dir/main.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue6899.go b/gcc/testsuite/go.test/test/fixedbugs/issue6899.go index a693bf28508..d7f85780298 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue6899.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue6899.go @@ -1,6 +1,6 @@ -// cmpout +// run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue887.go b/gcc/testsuite/go.test/test/fixedbugs/issue887.go index 5bc193bf96f..b68ba6997f8 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/issue887.go +++ b/gcc/testsuite/go.test/test/fixedbugs/issue887.go @@ -1,6 +1,6 @@ // compile -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/func6.go b/gcc/testsuite/go.test/test/func6.go index 456cb49f092..5b2f9f273ec 100644 --- a/gcc/testsuite/go.test/test/func6.go +++ b/gcc/testsuite/go.test/test/func6.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -9,7 +9,7 @@ package main func main() { - if func() bool { return true }() {} // 6g used to say this was a syntax error + if func() bool { return true }() {} // gc used to say this was a syntax error if (func() bool { return true })() {} if (func() bool { return true }()) {} } diff --git a/gcc/testsuite/go.test/test/func7.go b/gcc/testsuite/go.test/test/func7.go index 2d646b67860..3b22199f7e3 100644 --- a/gcc/testsuite/go.test/test/func7.go +++ b/gcc/testsuite/go.test/test/func7.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -23,7 +23,7 @@ func g() int { } func main() { - // 6g, 8g, 5g all used to evaluate g() before f(). + // gc used to evaluate g() before f(). if f() < g() { panic("wrong answer") } diff --git a/gcc/testsuite/go.test/test/func8.go b/gcc/testsuite/go.test/test/func8.go index 13051802ecd..9de01d43ea5 100644 --- a/gcc/testsuite/go.test/test/func8.go +++ b/gcc/testsuite/go.test/test/func8.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -21,16 +21,14 @@ func g() int { var xy string +//go:noinline func x() bool { - for false { - } // no inlining xy += "x" return false } +//go:noinline func y() string { - for false { - } // no inlining xy += "y" return "abc" } diff --git a/gcc/testsuite/go.test/test/funcdup.go b/gcc/testsuite/go.test/test/funcdup.go index d15d685792f..7b05d126066 100644 --- a/gcc/testsuite/go.test/test/funcdup.go +++ b/gcc/testsuite/go.test/test/funcdup.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/funcdup2.go b/gcc/testsuite/go.test/test/funcdup2.go index 1db1a396b2e..9513ef46bdd 100644 --- a/gcc/testsuite/go.test/test/funcdup2.go +++ b/gcc/testsuite/go.test/test/funcdup2.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/gc2.go b/gcc/testsuite/go.test/test/gc2.go index de52a4fbf2e..2f8eb9b70e6 100644 --- a/gcc/testsuite/go.test/test/gc2.go +++ b/gcc/testsuite/go.test/test/gc2.go @@ -1,6 +1,7 @@ +// +build !nacl,!js // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -36,7 +37,7 @@ func main() { } runtime.ReadMemStats(memstats) - obj := memstats.HeapObjects - st.HeapObjects + obj := int64(memstats.HeapObjects - st.HeapObjects) if obj > N/5 { fmt.Println("too many objects left:", obj) os.Exit(1) diff --git a/gcc/testsuite/go.test/test/golden.out b/gcc/testsuite/go.test/test/golden.out deleted file mode 100644 index 742a5d3f634..00000000000 --- a/gcc/testsuite/go.test/test/golden.out +++ /dev/null @@ -1,24 +0,0 @@ - -== ./ - -== ken/ - -== chan/ - -== interface/ - -== syntax/ - -== dwarf/ - -== safe/ - -== fixedbugs/ - -=========== fixedbugs/bug429.go -fatal error: all goroutines are asleep - deadlock! - -== bugs/ - -=========== bugs/bug395.go -bug395 is broken diff --git a/gcc/testsuite/go.test/test/goprint.go b/gcc/testsuite/go.test/test/goprint.go index cdaccf4f796..d44b259081e 100644 --- a/gcc/testsuite/go.test/test/goprint.go +++ b/gcc/testsuite/go.test/test/goprint.go @@ -1,6 +1,6 @@ -// cmpout +// run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -8,9 +8,25 @@ package main -import "time" +import ( + "log" + "runtime" + "time" +) func main() { + numg0 := runtime.NumGoroutine() + deadline := time.Now().Add(10 * time.Second) go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255)) - time.Sleep(100*time.Millisecond) + for { + numg := runtime.NumGoroutine() + if numg > numg0 { + if time.Now().After(deadline) { + log.Fatalf("%d goroutines > initial %d after deadline", numg, numg0) + } + runtime.Gosched() + continue + } + break + } } diff --git a/gcc/testsuite/go.test/test/goto.go b/gcc/testsuite/go.test/test/goto.go index ca477b3d0c3..d660c9ce624 100644 --- a/gcc/testsuite/go.test/test/goto.go +++ b/gcc/testsuite/go.test/test/goto.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -40,7 +40,7 @@ L: // goto across declaration not okay func _() { goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" - x := 1 // GCCGO_ERROR "defined here" + x := 1 // GCCGO_ERROR "defined here" _ = x L: } @@ -62,7 +62,7 @@ func _() { x := 1 _ = x } - x := 1 // GCCGO_ERROR "defined here" + x := 1 // GCCGO_ERROR "defined here" _ = x L: } @@ -77,8 +77,8 @@ L: // error shows first offending variable func _() { - goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" - x := 1 // GCCGO_ERROR "defined here" + goto L // ERROR "goto L jumps over declaration of y at LINE+3|goto jumps over declaration" + x := 1 // GCCGO_ERROR "defined here" _ = x y := 1 _ = y @@ -87,8 +87,8 @@ L: // goto not okay even if code path is dead func _() { - goto L // ERROR "goto L jumps over declaration of x at LINE+1|goto jumps over declaration" - x := 1 // GCCGO_ERROR "defined here" + goto L // ERROR "goto L jumps over declaration of y at LINE+3|goto jumps over declaration" + x := 1 // GCCGO_ERROR "defined here" _ = x y := 1 _ = y @@ -115,14 +115,14 @@ L: // goto into inner block not okay func _() { goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - { // GCCGO_ERROR "block starts here" + { // GCCGO_ERROR "block starts here" L: } } // goto backward into inner block still not okay func _() { - { // GCCGO_ERROR "block starts here" + { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" @@ -130,10 +130,10 @@ func _() { // error shows first (outermost) offending block func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" { { - { // GCCGO_ERROR "block starts here" + { // GCCGO_ERROR "block starts here" L: } } @@ -145,7 +145,7 @@ func _() { goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" x := 1 _ = x - { // GCCGO_ERROR "block starts here" + { // GCCGO_ERROR "block starts here" L: } } @@ -179,30 +179,30 @@ L: } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - if true { // GCCGO_ERROR "block starts here" + goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + if true { // GCCGO_ERROR "block starts here" L: } } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - if true { // GCCGO_ERROR "block starts here" + goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + if true { // GCCGO_ERROR "block starts here" L: } else { } } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" if true { - } else { // GCCGO_ERROR "block starts here" + } else { // GCCGO_ERROR "block starts here" L: } } func _() { - if false { // GCCGO_ERROR "block starts here" + if false { // GCCGO_ERROR "block starts here" L: } else { goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" @@ -212,7 +212,7 @@ func _() { func _() { if true { goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - } else { // GCCGO_ERROR "block starts here" + } else { // GCCGO_ERROR "block starts here" L: } } @@ -220,7 +220,7 @@ func _() { func _() { if true { goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - } else if false { // GCCGO_ERROR "block starts here" + } else if false { // GCCGO_ERROR "block starts here" L: } } @@ -228,7 +228,7 @@ func _() { func _() { if true { goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" - } else if false { // GCCGO_ERROR "block starts here" + } else if false { // GCCGO_ERROR "block starts here" L: } else { } @@ -241,9 +241,9 @@ func _() { // really is LINE+1 (like in the previous test), // even though it looks like it might be LINE+3 instead. if true { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" } else if false { - } else { // GCCGO_ERROR "block starts here" + } else { // GCCGO_ERROR "block starts here" L: } } @@ -287,14 +287,14 @@ func _() { } func _() { - for { // GCCGO_ERROR "block starts here" + for { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for { // GCCGO_ERROR "block starts here" + for { // GCCGO_ERROR "block starts here" goto L L1: } @@ -303,42 +303,42 @@ L: } func _() { - for i < n { // GCCGO_ERROR "block starts here" + for i < n { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here" + for i = 0; i < n; i++ { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for i = range x { // GCCGO_ERROR "block starts here" + for i = range x { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for i = range c { // GCCGO_ERROR "block starts here" + for i = range c { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for i = range m { // GCCGO_ERROR "block starts here" + for i = range m { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" } func _() { - for i = range s { // GCCGO_ERROR "block starts here" + for i = range s { // GCCGO_ERROR "block starts here" L: } goto L // ERROR "goto L jumps into block starting at LINE-3|goto jumps into block" @@ -395,29 +395,29 @@ func _() { } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" switch i { case 0: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" switch i { case 0: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" ; default: } } func _() { - goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" + goto L // ERROR "goto L jumps into block starting at LINE+3|goto jumps into block" switch i { case 0: default: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } @@ -426,14 +426,14 @@ func _() { default: goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" case 0: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } func _() { switch i { case 0: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" ; default: goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" @@ -495,7 +495,7 @@ func _() { goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" select { case c <- 1: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } @@ -503,7 +503,7 @@ func _() { goto L // ERROR "goto L jumps into block starting at LINE+2|goto jumps into block" select { case c <- 1: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" ; default: } @@ -514,7 +514,7 @@ func _() { select { case <-c: default: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } @@ -523,14 +523,14 @@ func _() { default: goto L // ERROR "goto L jumps into block starting at LINE+1|goto jumps into block" case <-c: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" } } func _() { select { case <-c: - L: // GCCGO_ERROR "block starts here" + L: // GCCGO_ERROR "block starts here" ; default: goto L // ERROR "goto L jumps into block starting at LINE-4|goto jumps into block" diff --git a/gcc/testsuite/go.test/test/helloworld.go b/gcc/testsuite/go.test/test/helloworld.go index 5025ec9bb35..06851d13b3a 100644 --- a/gcc/testsuite/go.test/test/helloworld.go +++ b/gcc/testsuite/go.test/test/helloworld.go @@ -1,4 +1,4 @@ -// cmpout +// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/import2.dir/import2.go b/gcc/testsuite/go.test/test/import2.dir/import2.go index 8bb1eb91913..9c54a1b87ea 100644 --- a/gcc/testsuite/go.test/test/import2.dir/import2.go +++ b/gcc/testsuite/go.test/test/import2.dir/import2.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/import2.dir/import3.go b/gcc/testsuite/go.test/test/import2.dir/import3.go index d7fe37b1996..3bf9cb0c3ca 100644 --- a/gcc/testsuite/go.test/test/import2.dir/import3.go +++ b/gcc/testsuite/go.test/test/import2.dir/import3.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/import2.go b/gcc/testsuite/go.test/test/import2.go index f8d0b0a0fd9..1ef1dd4a187 100644 --- a/gcc/testsuite/go.test/test/import2.go +++ b/gcc/testsuite/go.test/test/import2.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/index.go b/gcc/testsuite/go.test/test/index.go index a8c471bb3bf..91195ad632b 100644 --- a/gcc/testsuite/go.test/test/index.go +++ b/gcc/testsuite/go.test/test/index.go @@ -1,6 +1,6 @@ // skip -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -216,7 +216,7 @@ func main() { thisPass := 0 if c == "c" && (a == "a" || a == "pa" || n == "n" || i == "i64big" || i == "i64bigger" || i == "huge" || i == "fbad") { if i == "huge" { - // Due to a detail of 6g's internals, + // Due to a detail of gc's internals, // the huge constant errors happen in an // earlier pass than the others and inhibits // the next pass from running. @@ -251,7 +251,7 @@ func main() { if c == "" && (i == "fgood" || i == "fbad") { return } - // Integral float constat is ok. + // Integral float constant is ok. if c == "c" && n == "" && i == "fgood" { if pass == 0 { fmt.Fprintf(b, "\tuse(%s[%s])\n", pae, cni) diff --git a/gcc/testsuite/go.test/test/index0.go b/gcc/testsuite/go.test/test/index0.go index 04a16198d2a..62f339277b9 100644 --- a/gcc/testsuite/go.test/test/index0.go +++ b/gcc/testsuite/go.test/test/index0.go @@ -1,6 +1,6 @@ // runoutput ./index.go -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/index1.go b/gcc/testsuite/go.test/test/index1.go index e28efa35f1d..40efc54eff6 100644 --- a/gcc/testsuite/go.test/test/index1.go +++ b/gcc/testsuite/go.test/test/index1.go @@ -1,6 +1,6 @@ // errorcheckoutput ./index.go -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/index2.go b/gcc/testsuite/go.test/test/index2.go index a7107cc0510..2a210cc9818 100644 --- a/gcc/testsuite/go.test/test/index2.go +++ b/gcc/testsuite/go.test/test/index2.go @@ -1,6 +1,6 @@ // errorcheckoutput ./index.go -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/init.go b/gcc/testsuite/go.test/test/init.go index f4689443cf1..5e182281da8 100644 --- a/gcc/testsuite/go.test/test/init.go +++ b/gcc/testsuite/go.test/test/init.go @@ -9,13 +9,11 @@ package main -import "runtime" - func init() { } func main() { init() // ERROR "undefined.*init" - runtime.init() // ERROR "unexported.*runtime\.init" + runtime.init() // ERROR "undefined.*runtime\.init|reference to undefined name" var _ = init // ERROR "undefined.*init" } diff --git a/gcc/testsuite/go.test/test/init1.go b/gcc/testsuite/go.test/test/init1.go index f6eda6edfea..0803dced1c4 100644 --- a/gcc/testsuite/go.test/test/init1.go +++ b/gcc/testsuite/go.test/test/init1.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -17,22 +17,30 @@ func init() { go send(c) <-c - const chunk = 1 << 20 - memstats := new(runtime.MemStats) - runtime.ReadMemStats(memstats) - sys := memstats.Sys - b := make([]byte, chunk) + const N = 1000 + const MB = 1 << 20 + b := make([]byte, MB) for i := range b { b[i] = byte(i%10 + '0') } s := string(b) - for i := 0; i < 1000; i++ { + + memstats := new(runtime.MemStats) + runtime.ReadMemStats(memstats) + sys, numGC := memstats.Sys, memstats.NumGC + + // Generate 1,000 MB of garbage, only retaining 1 MB total. + for i := 0; i < N; i++ { x = []byte(s) } + + // Verify that the garbage collector ran by seeing if we + // allocated fewer than N*MB bytes from the system. runtime.ReadMemStats(memstats) - sys1 := memstats.Sys - if sys1-sys > chunk*50 { - println("allocated 1000 chunks of", chunk, "and used ", sys1-sys, "memory") + sys1, numGC1 := memstats.Sys, memstats.NumGC + if sys1-sys >= N*MB || numGC1 == numGC { + println("allocated 1000 chunks of", MB, "and used ", sys1-sys, "memory") + println("numGC went", numGC, "to", numGC1) panic("init1") } } diff --git a/gcc/testsuite/go.test/test/initializerr.go b/gcc/testsuite/go.test/test/initializerr.go index ca05414554d..5e2e9a91a0b 100644 --- a/gcc/testsuite/go.test/test/initializerr.go +++ b/gcc/testsuite/go.test/test/initializerr.go @@ -23,6 +23,7 @@ var a2 = S { Y: 3, Z: 2, Y: 3 } // ERROR "duplicate" var a3 = T { S{}, 2, 3, 4, 5, 6 } // ERROR "convert|too many" var a4 = [5]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } // ERROR "index|too many" var a5 = []byte { x: 2 } // ERROR "index" +var a6 = []byte{1: 1, 2: 2, 1: 3} // ERROR "duplicate" var ok1 = S { } // should be ok var ok2 = T { S: ok1 } // should be ok diff --git a/gcc/testsuite/go.test/test/interface/embed2.go b/gcc/testsuite/go.test/test/interface/embed2.go index 1636db78eb8..df3e2e435bb 100644 --- a/gcc/testsuite/go.test/test/interface/embed2.go +++ b/gcc/testsuite/go.test/test/interface/embed2.go @@ -12,20 +12,25 @@ import "os" const Value = 1e12 -type Inter interface { M() int64 } +type Inter interface { + M() int64 +} type T int64 + func (t T) M() int64 { return int64(t) } + var t = T(Value) var pt = &t var ti Inter = t var pti = &ti -type S struct { Inter } -var s = S{ ti } +type S struct{ Inter } + +var s = S{ti} var ps = &s -type SP struct { *Inter } // ERROR "interface" +type SP struct{ *Inter } // ERROR "interface" var i Inter var pi = &i @@ -43,25 +48,25 @@ func main() { check("t.M()", t.M()) check("pt.M()", pt.M()) check("ti.M()", ti.M()) - check("pti.M()", pti.M()) // ERROR "method" + check("pti.M()", pti.M()) // ERROR "pointer to interface, not interface" check("s.M()", s.M()) check("ps.M()", ps.M()) i = t check("i = t; i.M()", i.M()) - check("i = t; pi.M()", pi.M()) // ERROR "method" + check("i = t; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" i = pt check("i = pt; i.M()", i.M()) - check("i = pt; pi.M()", pi.M()) // ERROR "method" + check("i = pt; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" i = s check("i = s; i.M()", i.M()) - check("i = s; pi.M()", pi.M()) // ERROR "method" + check("i = s; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" i = ps check("i = ps; i.M()", i.M()) - check("i = ps; pi.M()", pi.M()) // ERROR "method" + check("i = ps; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" if !ok { println("BUG: interface10") diff --git a/gcc/testsuite/go.test/test/interface/explicit.go b/gcc/testsuite/go.test/test/interface/explicit.go index b10d02f2485..3f9451e8d2f 100644 --- a/gcc/testsuite/go.test/test/interface/explicit.go +++ b/gcc/testsuite/go.test/test/interface/explicit.go @@ -53,7 +53,12 @@ func main() { i2 = I2(i) // ERROR "invalid|missing N method" e = E(t) // ok - t = T(e) // ERROR "need explicit|need type assertion|incompatible" "as type [*]T" + t = T(e) // ERROR "need explicit|need type assertion|incompatible" + + // cannot type-assert non-interfaces + f := 2.0 + _ = f.(int) // ERROR "non-interface type|only valid for interface types" + } type M interface { @@ -81,7 +86,6 @@ var m2 M = jj // ERROR "incompatible|wrong type for M method" var m3 = M(ii) // ERROR "invalid|missing" var m4 = M(jj) // ERROR "invalid|wrong type for M method" - type B1 interface { _() // ERROR "methods must have a unique non-blank name" } diff --git a/gcc/testsuite/go.test/test/interface/noeq.go b/gcc/testsuite/go.test/test/interface/noeq.go index 1c5166ededf..bb36893cd0d 100644 --- a/gcc/testsuite/go.test/test/interface/noeq.go +++ b/gcc/testsuite/go.test/test/interface/noeq.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive1.go b/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive1.go index 441f0ecaa5a..8498cb5d751 100644 --- a/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive1.go +++ b/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive1.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive2.go b/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive2.go index e8048c672b2..29385df76df 100644 --- a/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive2.go +++ b/gcc/testsuite/go.test/test/interface/recursive1.dir/recursive2.go @@ -1,4 +1,4 @@ -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/interface/recursive1.go b/gcc/testsuite/go.test/test/interface/recursive1.go index 62f61088441..ea2f4eb934a 100644 --- a/gcc/testsuite/go.test/test/interface/recursive1.go +++ b/gcc/testsuite/go.test/test/interface/recursive1.go @@ -1,6 +1,6 @@ // compiledir -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/ken/cplx0.go b/gcc/testsuite/go.test/test/ken/cplx0.go index 665e52a5f35..5d78dc0147a 100644 --- a/gcc/testsuite/go.test/test/ken/cplx0.go +++ b/gcc/testsuite/go.test/test/ken/cplx0.go @@ -1,4 +1,4 @@ -// cmpout +// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/ken/embed.go b/gcc/testsuite/go.test/test/ken/embed.go index 9b35c56acfd..f7ca0665e26 100644 --- a/gcc/testsuite/go.test/test/ken/embed.go +++ b/gcc/testsuite/go.test/test/ken/embed.go @@ -253,7 +253,7 @@ func main() { panic("fail") } - // run it thru an interface + // run it through an interface i = s s = i.(*S) diff --git a/gcc/testsuite/go.test/test/ken/modconst.go b/gcc/testsuite/go.test/test/ken/modconst.go index d88cf100321..c27bf64bdf5 100644 --- a/gcc/testsuite/go.test/test/ken/modconst.go +++ b/gcc/testsuite/go.test/test/ken/modconst.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Test integer modulus by contstants. +// Test integer modulus by constants. package main diff --git a/gcc/testsuite/go.test/test/ken/string.go b/gcc/testsuite/go.test/test/ken/string.go index 6df8dc4ddf1..7bb3cabbc2d 100644 --- a/gcc/testsuite/go.test/test/ken/string.go +++ b/gcc/testsuite/go.test/test/ken/string.go @@ -1,4 +1,4 @@ -// cmpout +// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/label.go b/gcc/testsuite/go.test/test/label.go index b30c27ec44b..7deead6fba9 100644 --- a/gcc/testsuite/go.test/test/label.go +++ b/gcc/testsuite/go.test/test/label.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -17,8 +17,7 @@ L1: // ERROR "label .*L1.* defined and not used" for { } L2: // ERROR "label .*L2.* defined and not used" - select { - } + select {} L3: // ERROR "label .*L3.* defined and not used" switch { } @@ -59,4 +58,8 @@ L10: default: break L10 } + + goto L10 + + goto go2 // ERROR "label go2 not defined|reference to undefined label .*go2" } diff --git a/gcc/testsuite/go.test/test/label1.go b/gcc/testsuite/go.test/test/label1.go index f923a18820e..a8eaecbff2f 100644 --- a/gcc/testsuite/go.test/test/label1.go +++ b/gcc/testsuite/go.test/test/label1.go @@ -1,10 +1,9 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. - // Verify that erroneous labels are caught by the compiler. // This set is caught by pass 2. That's why this file is label1.go. // Does not compile. @@ -13,7 +12,19 @@ package main var x int -func f() { +func f1() { + switch x { + case 1: + continue // ERROR "continue is not in a loop$|continue statement not within for" + } + select { + default: + continue // ERROR "continue is not in a loop$|continue statement not within for" + } + +} + +func f2() { L1: for { if x == 0 { @@ -32,11 +43,17 @@ L2: break L2 } if x == 1 { - continue L2 // ERROR "invalid continue label .*L2" + continue L2 // ERROR "invalid continue label .*L2|continue is not in a loop$" } goto L2 } + for { + if x == 1 { + continue L2 // ERROR "invalid continue label .*L2" + } + } + L3: switch { case x > 10: @@ -44,7 +61,7 @@ L3: break L3 } if x == 12 { - continue L3 // ERROR "invalid continue label .*L3" + continue L3 // ERROR "invalid continue label .*L3|continue is not in a loop$" } goto L3 } @@ -55,7 +72,7 @@ L4: break L4 // ERROR "invalid break label .*L4" } if x == 14 { - continue L4 // ERROR "invalid continue label .*L4" + continue L4 // ERROR "invalid continue label .*L4|continue is not in a loop$" } if x == 15 { goto L4 @@ -63,12 +80,12 @@ L4: } L5: - f() + f2() if x == 16 { break L5 // ERROR "invalid break label .*L5" } if x == 17 { - continue L5 // ERROR "invalid continue label .*L5" + continue L5 // ERROR "invalid continue label .*L5|continue is not in a loop$" } if x == 18 { goto L5 @@ -85,4 +102,21 @@ L5: goto L1 } } + + continue // ERROR "continue is not in a loop$|continue statement not within for" + for { + continue on // ERROR "continue label not defined: on|invalid continue label .*on" + } + + break // ERROR "break is not in a loop, switch, or select|break statement not within for or switch or select" + for { + break dance // ERROR "break label not defined: dance|invalid break label .*dance" + } + + for { + switch x { + case 1: + continue + } + } } diff --git a/gcc/testsuite/go.test/test/linkx.go b/gcc/testsuite/go.test/test/linkx.go index 12d446ffc13..4f85b241a96 100644 --- a/gcc/testsuite/go.test/test/linkx.go +++ b/gcc/testsuite/go.test/test/linkx.go @@ -1,20 +1,38 @@ -// $G $D/$F.go && $L -X main.tbd hello $F.$A && ./$A.out +// skip -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Test the -X facility of the gc linker (6l etc.). +// This test is run by linkx_run.go. package main +import "fmt" + var tbd string +var overwrite string = "dibs" + +var tbdcopy = tbd +var overwritecopy = overwrite +var arraycopy = [2]string{tbd, overwrite} + +var b bool +var x int func main() { - if tbd != "hello" { - println("BUG: test/linkx", len(tbd), tbd) + fmt.Println(tbd) + fmt.Println(tbdcopy) + fmt.Println(arraycopy[0]) + + fmt.Println(overwrite) + fmt.Println(overwritecopy) + fmt.Println(arraycopy[1]) + + // Check non-string symbols are not overwritten. + // This also make them used. + if b || x != 0 { + panic("b or x overwritten") } } diff --git a/gcc/testsuite/go.test/test/map.go b/gcc/testsuite/go.test/test/map.go index 485e743fe46..2c1cf8a1403 100644 --- a/gcc/testsuite/go.test/test/map.go +++ b/gcc/testsuite/go.test/test/map.go @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file. // Test maps, almost exhaustively. -// NaN complexity test is in mapnan.go. +// Complexity (linearity) test is in maplinear.go. package main diff --git a/gcc/testsuite/go.test/test/map1.go b/gcc/testsuite/go.test/test/map1.go index 6f1a1c8ac01..b4aa70755fe 100644 --- a/gcc/testsuite/go.test/test/map1.go +++ b/gcc/testsuite/go.test/test/map1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -9,8 +9,6 @@ package main -func main() {} - type v bool var ( @@ -60,3 +58,11 @@ type T5 *int type T6 struct { F T5 } type T7 *T4 type T8 struct { F *T7 } + +func main() { + m := make(map[int]int) + delete() // ERROR "missing arguments|not enough arguments" + delete(m) // ERROR "missing second \(key\) argument|not enough arguments" + delete(m, 2, 3) // ERROR "too many arguments" + delete(1, m) // ERROR "first argument to delete must be map|argument 1 must be a map" +} diff --git a/gcc/testsuite/go.test/test/mapnan.go b/gcc/testsuite/go.test/test/mapnan.go deleted file mode 100644 index f081cab01d4..00000000000 --- a/gcc/testsuite/go.test/test/mapnan.go +++ /dev/null @@ -1,56 +0,0 @@ -// +build darwin linux -// run - -// 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. - -// Test that NaNs in maps don't go quadratic. - -package main - -import ( - "fmt" - "math" - "time" -) - -func main() { - - // Test that NaNs in maps don't go quadratic. - t := func(n int) time.Duration { - t1 := time.Now() - m := map[float64]int{} - nan := math.NaN() - for i := 0; i < n; i++ { - m[nan] = 1 - } - if len(m) != n { - panic("wrong size map after nan insertion") - } - return time.Since(t1) - } - - // Depending on the machine and OS, this test might be too fast - // to measure with accurate enough granularity. On failure, - // make it run longer, hoping that the timing granularity - // is eventually sufficient. - - n := 30000 // ~8ms user time on a Mid 2011 MacBook Air (1.8 GHz Core i7) - fails := 0 - for { - t1 := t(n) - t2 := t(2 * n) - // should be 2x (linear); allow up to 3x - if t2 < 3*t1 { - return - } - fails++ - if fails == 6 { - panic(fmt.Sprintf("too slow: %d inserts: %v; %d inserts: %v\n", n, t1, 2*n, t2)) - } - if fails < 4 { - n *= 2 - } - } -} diff --git a/gcc/testsuite/go.test/test/method1.go b/gcc/testsuite/go.test/test/method1.go index 365b8ca553d..bb8c81d7461 100644 --- a/gcc/testsuite/go.test/test/method1.go +++ b/gcc/testsuite/go.test/test/method1.go @@ -9,12 +9,16 @@ package main -type T struct { } -func (t *T) M(int, string) // GCCGO_ERROR "previous" -func (t *T) M(int, float64) { } // ERROR "redeclared|redefinition" +type T struct{} -func f(int, string) // GCCGO_ERROR "previous" -func f(int, float64) { } // ERROR "redeclared|redefinition" +func (t *T) M(int, string) // GCCGO_ERROR "previous" +func (t *T) M(int, float64) {} // ERROR "redeclared|redefinition" -func g(a int, b string) // GCCGO_ERROR "previous" -func g(a int, c string) // ERROR "redeclared|redefinition" +func (t T) H() // GCCGO_ERROR "previous" +func (t *T) H() {} // ERROR "redeclared|redefinition" + +func f(int, string) // GCCGO_ERROR "previous" +func f(int, float64) {} // ERROR "redeclared|redefinition" + +func g(a int, b string) // GCCGO_ERROR "previous" +func g(a int, c string) // ERROR "redeclared|redefinition" diff --git a/gcc/testsuite/go.test/test/method2.go b/gcc/testsuite/go.test/test/method2.go index aaa850e7191..ac1d771c050 100644 --- a/gcc/testsuite/go.test/test/method2.go +++ b/gcc/testsuite/go.test/test/method2.go @@ -33,5 +33,9 @@ var _ = (*Val).val // ERROR "method" var v Val var pv = &v -var _ = pv.val() // ERROR "method" -var _ = pv.val // ERROR "method" +var _ = pv.val() // ERROR "undefined|pointer to interface" +var _ = pv.val // ERROR "undefined|pointer to interface" + +func (t *T) g() int { return t.a } + +var _ = (T).g() // ERROR "needs pointer receiver|undefined|method requires pointer" diff --git a/gcc/testsuite/go.test/test/method4.dir/prog.go b/gcc/testsuite/go.test/test/method4.dir/prog.go index 77d580cffc5..cb5cf65f290 100644 --- a/gcc/testsuite/go.test/test/method4.dir/prog.go +++ b/gcc/testsuite/go.test/test/method4.dir/prog.go @@ -73,7 +73,14 @@ func main() { f4 := I2.Sum eq(f4(t1, a, 17), 27) eq(f4(t2, a, 18), 28) - + + // issue 6723 + f5 := (interface { + I2 + }).Sum + eq(f5(t1, a, 19), 29) + eq(f5(t2, a, 20), 30) + mt1 := method4a.T1(4) mt2 := &method4a.T2{4} diff --git a/gcc/testsuite/go.test/test/method5.go b/gcc/testsuite/go.test/test/method5.go index 36508f2e76f..d87bb6f5b27 100644 --- a/gcc/testsuite/go.test/test/method5.go +++ b/gcc/testsuite/go.test/test/method5.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/named.go b/gcc/testsuite/go.test/test/named.go index d0330ab2389..9763c76bfdf 100644 --- a/gcc/testsuite/go.test/test/named.go +++ b/gcc/testsuite/go.test/test/named.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/named1.go b/gcc/testsuite/go.test/test/named1.go index 4f122e4e3c9..7feae13b9d7 100644 --- a/gcc/testsuite/go.test/test/named1.go +++ b/gcc/testsuite/go.test/test/named1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. @@ -41,21 +41,21 @@ func main() { asBool(1 != 2) // ok now asBool(i < j) // ok now - _, b = m[2] + _, b = m[2] // ok now var inter interface{} - _, b = inter.(Map) + _, b = inter.(Map) // ok now _ = b var minter interface { M() } - _, b = minter.(Map) + _, b = minter.(Map) // ok now _ = b _, bb := <-c asBool(bb) // ERROR "cannot use.*type bool.*as type Bool" - _, b = <-c + _, b = <-c // ok now _ = b asString(String(slice)) // ok diff --git a/gcc/testsuite/go.test/test/nilcheck.go b/gcc/testsuite/go.test/test/nilcheck.go index fe05d05c925..6879438e9cd 100644 --- a/gcc/testsuite/go.test/test/nilcheck.go +++ b/gcc/testsuite/go.test/test/nilcheck.go @@ -1,6 +1,6 @@ // errorcheck -0 -N -d=nil -// Copyright 2013 The Go Authors. All rights reserved. +// 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. @@ -17,7 +17,7 @@ type Struct struct { type BigStruct struct { X int Y float64 - A [1<<20]int + A [1 << 20]int Z string } @@ -29,86 +29,86 @@ type Empty1 struct { } var ( - intp *int - arrayp *[10]int - array0p *[0]int - bigarrayp *[1<<26]int - structp *Struct + intp *int + arrayp *[10]int + array0p *[0]int + bigarrayp *[1 << 26]int + structp *Struct bigstructp *BigStruct - emptyp *Empty - empty1p *Empty1 + emptyp *Empty + empty1p *Empty1 ) func f1() { - _ = *intp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" + _ = *intp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" _ = *array0p // ERROR "nil check" _ = *array0p // ERROR "nil check" - _ = *intp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" + _ = *intp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" _ = *structp // ERROR "nil check" - _ = *emptyp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" + _ = *emptyp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" } func f2() { var ( - intp *int - arrayp *[10]int - array0p *[0]int - bigarrayp *[1<<20]int - structp *Struct + intp *int + arrayp *[10]int + array0p *[0]int + bigarrayp *[1 << 20]int + structp *Struct bigstructp *BigStruct - emptyp *Empty - empty1p *Empty1 + emptyp *Empty + empty1p *Empty1 ) - _ = *intp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" - _ = *array0p // ERROR "nil check" - _ = *array0p // ERROR "nil check" - _ = *intp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" - _ = *structp // ERROR "nil check" - _ = *emptyp // ERROR "nil check" - _ = *arrayp // ERROR "nil check" - _ = *bigarrayp // ERROR "nil check" + _ = *intp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" + _ = *array0p // ERROR "nil check" + _ = *array0p // ERROR "nil check" + _ = *intp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" + _ = *structp // ERROR "nil check" + _ = *emptyp // ERROR "nil check" + _ = *arrayp // ERROR "nil check" + _ = *bigarrayp // ERROR "nil check" _ = *bigstructp // ERROR "nil check" - _ = *empty1p // ERROR "nil check" + _ = *empty1p // ERROR "nil check" } func fx10k() *[10000]int -var b bool +var b bool func f3(x *[10000]int) { // Using a huge type and huge offsets so the compiler // does not expect the memory hardware to fault. _ = x[9999] // ERROR "nil check" - + for { if x[9999] != 0 { // ERROR "nil check" break } } - - x = fx10k() + + x = fx10k() _ = x[9999] // ERROR "nil check" if b { _ = x[9999] // ERROR "nil check" } else { _ = x[9999] // ERROR "nil check" - } + } _ = x[9999] // ERROR "nil check" - x = fx10k() + x = fx10k() if b { _ = x[9999] // ERROR "nil check" } else { _ = x[9999] // ERROR "nil check" - } + } _ = x[9999] // ERROR "nil check" - + fx10k() // This one is a bit redundant, if we figured out that // x wasn't going to change across the function call. @@ -138,7 +138,7 @@ func f3b() { _ = &x[9] // ERROR "nil check" } -func fx10() *[10]int +func fx10() *[10]int func f4(x *[10]int) { // Most of these have no checks because a real memory reference follows, @@ -146,33 +146,33 @@ func f4(x *[10]int) { // in the first unmapped page of memory. _ = x[9] // ERROR "nil check" - + for { if x[9] != 0 { // ERROR "nil check" break } } - - x = fx10() + + x = fx10() _ = x[9] // ERROR "nil check" if b { _ = x[9] // ERROR "nil check" } else { _ = x[9] // ERROR "nil check" - } + } _ = x[9] // ERROR "nil check" - x = fx10() + x = fx10() if b { _ = x[9] // ERROR "nil check" } else { _ = &x[9] // ERROR "nil check" - } + } _ = x[9] // ERROR "nil check" - + fx10() _ = x[9] // ERROR "nil check" - + x = fx10() y := fx10() _ = &x[9] // ERROR "nil check" @@ -182,3 +182,8 @@ func f4(x *[10]int) { _ = &x[9] // ERROR "nil check" } +func f5(m map[string]struct{}) bool { + // Existence-only map lookups should not generate a nil check + _, ok := m[""] + return ok +} diff --git a/gcc/testsuite/go.test/test/nilptr.go b/gcc/testsuite/go.test/test/nilptr.go index 9631d1618b5..c9a044dd362 100644 --- a/gcc/testsuite/go.test/test/nilptr.go +++ b/gcc/testsuite/go.test/test/nilptr.go @@ -1,12 +1,16 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. // Test that the implementation catches nil ptr indirection // in a large address space. +// +build !aix +// +build !darwin !arm64 +// Address space starts at 1<<32 on AIX and on darwin/arm64, so dummy is too far. + package main import "unsafe" diff --git a/gcc/testsuite/go.test/test/nilptr2.go b/gcc/testsuite/go.test/test/nilptr2.go index d2f4c912f64..8a85b6dbcb1 100644 --- a/gcc/testsuite/go.test/test/nilptr2.go +++ b/gcc/testsuite/go.test/test/nilptr2.go @@ -1,6 +1,6 @@ // run -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/nilptr3.go b/gcc/testsuite/go.test/test/nilptr3.go index 08597a02d95..e0f2ed97676 100644 --- a/gcc/testsuite/go.test/test/nilptr3.go +++ b/gcc/testsuite/go.test/test/nilptr3.go @@ -1,6 +1,9 @@ // errorcheck -0 -d=nil -// Copyright 2013 The Go Authors. All rights reserved. +// +build !wasm +// +build !aix + +// 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. @@ -17,7 +20,7 @@ type Struct struct { type BigStruct struct { X int Y float64 - A [1<<20]int + A [1 << 20]int Z string } @@ -29,99 +32,100 @@ type Empty1 struct { } var ( - intp *int - arrayp *[10]int - array0p *[0]int - bigarrayp *[1<<26]int - structp *Struct + intp *int + arrayp *[10]int + array0p *[0]int + bigarrayp *[1 << 26]int + structp *Struct bigstructp *BigStruct - emptyp *Empty - empty1p *Empty1 + emptyp *Empty + empty1p *Empty1 ) func f1() { _ = *intp // ERROR "generated nil check" - + // This one should be removed but the block copy needs // to be turned into its own pseudo-op in order to see // the indirect. _ = *arrayp // ERROR "generated nil check" - - // 0-byte indirect doesn't suffice + + // 0-byte indirect doesn't suffice. + // we don't registerize globals, so there are no removed.* nil checks. _ = *array0p // ERROR "generated nil check" - _ = *array0p // ERROR "removed repeated nil check" 386 + _ = *array0p // ERROR "removed nil check" - _ = *intp // ERROR "removed repeated nil check" - _ = *arrayp // ERROR "removed repeated nil check" + _ = *intp // ERROR "removed nil check" + _ = *arrayp // ERROR "removed nil check" _ = *structp // ERROR "generated nil check" - _ = *emptyp // ERROR "generated nil check" - _ = *arrayp // ERROR "removed repeated nil check" + _ = *emptyp // ERROR "generated nil check" + _ = *arrayp // ERROR "removed nil check" } func f2() { var ( - intp *int - arrayp *[10]int - array0p *[0]int - bigarrayp *[1<<20]int - structp *Struct + intp *int + arrayp *[10]int + array0p *[0]int + bigarrayp *[1 << 20]int + structp *Struct bigstructp *BigStruct - emptyp *Empty - empty1p *Empty1 + emptyp *Empty + empty1p *Empty1 ) - _ = *intp // ERROR "generated nil check" - _ = *arrayp // ERROR "generated nil check" - _ = *array0p // ERROR "generated nil check" - _ = *array0p // ERROR "removed repeated nil check" - _ = *intp // ERROR "removed repeated nil check" - _ = *arrayp // ERROR "removed repeated nil check" - _ = *structp // ERROR "generated nil check" - _ = *emptyp // ERROR "generated nil check" - _ = *arrayp // ERROR "removed repeated nil check" - _ = *bigarrayp // ERROR "generated nil check" ARM removed nil check before indirect!! + _ = *intp // ERROR "generated nil check" + _ = *arrayp // ERROR "generated nil check" + _ = *array0p // ERROR "generated nil check" + _ = *array0p // ERROR "removed.* nil check" + _ = *intp // ERROR "removed.* nil check" + _ = *arrayp // ERROR "removed.* nil check" + _ = *structp // ERROR "generated nil check" + _ = *emptyp // ERROR "generated nil check" + _ = *arrayp // ERROR "removed.* nil check" + _ = *bigarrayp // ERROR "generated nil check" ARM removed nil check before indirect!! _ = *bigstructp // ERROR "generated nil check" - _ = *empty1p // ERROR "generated nil check" + _ = *empty1p // ERROR "generated nil check" } func fx10k() *[10000]int -var b bool +var b bool func f3(x *[10000]int) { // Using a huge type and huge offsets so the compiler // does not expect the memory hardware to fault. _ = x[9999] // ERROR "generated nil check" - + for { - if x[9999] != 0 { // ERROR "generated nil check" + if x[9999] != 0 { // ERROR "removed nil check" break } } - - x = fx10k() + + x = fx10k() _ = x[9999] // ERROR "generated nil check" if b { - _ = x[9999] // ERROR "removed repeated nil check" + _ = x[9999] // ERROR "removed.* nil check" } else { - _ = x[9999] // ERROR "removed repeated nil check" - } - _ = x[9999] // ERROR "generated nil check" + _ = x[9999] // ERROR "removed.* nil check" + } + _ = x[9999] // ERROR "removed nil check" - x = fx10k() + x = fx10k() if b { _ = x[9999] // ERROR "generated nil check" } else { _ = x[9999] // ERROR "generated nil check" - } + } _ = x[9999] // ERROR "generated nil check" - + fx10k() // This one is a bit redundant, if we figured out that // x wasn't going to change across the function call. // But it's a little complex to do and in practice doesn't // matter enough. - _ = x[9999] // ERROR "generated nil check" + _ = x[9999] // ERROR "removed nil check" } func f3a() { @@ -130,7 +134,7 @@ func f3a() { z := fx10k() _ = &x[9] // ERROR "generated nil check" y = z - _ = &x[9] // ERROR "removed repeated nil check" + _ = &x[9] // ERROR "removed.* nil check" x = y _ = &x[9] // ERROR "generated nil check" } @@ -140,52 +144,108 @@ func f3b() { y := fx10k() _ = &x[9] // ERROR "generated nil check" y = x - _ = &x[9] // ERROR "removed repeated nil check" + _ = &x[9] // ERROR "removed.* nil check" x = y - _ = &x[9] // ERROR "removed repeated nil check" + _ = &x[9] // ERROR "removed.* nil check" } -func fx10() *[10]int +func fx10() *[10]int func f4(x *[10]int) { // Most of these have no checks because a real memory reference follows, // and the offset is small enough that if x is nil, the address will still be // in the first unmapped page of memory. - _ = x[9] // ERROR "removed nil check before indirect" - + _ = x[9] // ERROR "generated nil check" // bug: would like to remove this check (but nilcheck and load are in different blocks) + for { - if x[9] != 0 { // ERROR "removed nil check before indirect" + if x[9] != 0 { // ERROR "removed nil check" break } } - - x = fx10() - _ = x[9] // ERROR "removed nil check before indirect" + + x = fx10() + _ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect if b { - _ = x[9] // ERROR "removed nil check before indirect" + _ = x[9] // ERROR "removed nil check" } else { - _ = x[9] // ERROR "removed nil check before indirect" + _ = x[9] // ERROR "removed nil check" } - _ = x[9] // ERROR "removed nil check before indirect" + _ = x[9] // ERROR "removed nil check" - x = fx10() + x = fx10() if b { - _ = x[9] // ERROR "removed nil check before indirect" + _ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect } else { _ = &x[9] // ERROR "generated nil check" - } - _ = x[9] // ERROR "removed nil check before indirect" - + } + _ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect + fx10() - _ = x[9] // ERROR "removed nil check before indirect" - + _ = x[9] // ERROR "removed nil check" + x = fx10() y := fx10() _ = &x[9] // ERROR "generated nil check" y = x - _ = &x[9] // ERROR "removed repeated nil check" + _ = &x[9] // ERROR "removed[a-z ]* nil check" x = y - _ = &x[9] // ERROR "removed repeated nil check" + _ = &x[9] // ERROR "removed[a-z ]* nil check" +} + +func m1(m map[int][80]byte) byte { + v := m[3] // ERROR "removed nil check" + return v[5] +} +func m2(m map[int][800]byte) byte { + v := m[3] // ERROR "removed nil check" + return v[5] +} +func m3(m map[int][80]byte) (byte, bool) { + v, ok := m[3] // ERROR "removed nil check" + return v[5], ok +} +func m4(m map[int][800]byte) (byte, bool) { + v, ok := m[3] // ERROR "removed nil check" + return v[5], ok +} +func p1() byte { + p := new([100]byte) + return p[5] // ERROR "removed nil check" +} + +// make sure not to do nil check for access of PAUTOHEAP +//go:noinline +func (p *Struct) m() {} +func c1() { + var x Struct + func() { x.m() }() // ERROR "removed nil check" +} + +type SS struct { + x byte +} + +type TT struct { + SS } +func f(t *TT) *byte { + // See issue 17242. + s := &t.SS // ERROR "generated nil check" + return &s.x // ERROR "removed nil check" +} + +// make sure not to do nil check for newobject +func f7() (*Struct, float64) { + t := new(Struct) + p := &t.Y // ERROR "removed nil check" + return t, *p // ERROR "removed nil check" +} + +func f9() []int { + x := new([1]int) + x[0] = 1 // ERROR "removed nil check" + y := x[:] // ERROR "removed nil check" + return y +} diff --git a/gcc/testsuite/go.test/test/nul1.go b/gcc/testsuite/go.test/test/nul1.go index 20426b4fa08..fbba19857b9 100644 --- a/gcc/testsuite/go.test/test/nul1.go +++ b/gcc/testsuite/go.test/test/nul1.go @@ -36,7 +36,7 @@ var y = ` + "`in raw string \x00 foo`" + ` // ERROR "NUL" /* in other comment ` + "\x00" + ` */ // ERROR "NUL" -/* in source code */ ` + "\x00" + `// ERROR "NUL" "illegal character" +/* in source code */ ` + "\x00" + `// ERROR "NUL" var xx = "in string ` + "\xc2\xff" + `" // ERROR "UTF-8" @@ -47,10 +47,9 @@ var yy = ` + "`in raw string \xff foo`" + ` // ERROR "UTF-8" /* in other comment ` + "\xe0\x00\x00" + ` */ // ERROR "UTF-8|NUL" /* in variable name */ -var z` + "\xc1\x81" + ` int // ERROR "UTF-8" "invalid identifier character" +var z` + "\xc1\x81" + ` int // ERROR "UTF-8" -/* in source code */ ` + "var \xc2A int" + `// ERROR "UTF-8" "invalid identifier character" +/* in source code */ ` + "var \xc2A int" + `// ERROR "UTF-8" `) } - diff --git a/gcc/testsuite/go.test/test/peano.go b/gcc/testsuite/go.test/test/peano.go index 745f5153f6b..1102a972444 100644 --- a/gcc/testsuite/go.test/test/peano.go +++ b/gcc/testsuite/go.test/test/peano.go @@ -9,6 +9,8 @@ package main +import "runtime" + type Number *Number // ------------------------------------- @@ -116,7 +118,11 @@ var results = [...]int{ } func main() { - for i := 0; i <= 9; i++ { + max := 9 + if runtime.GOARCH == "wasm" { + max = 7 // stack size is limited + } + for i := 0; i <= max; i++ { if f := count(fact(gen(i))); f != results[i] { println("FAIL:", i, "!:", f, "!=", results[i]) panic(0) diff --git a/gcc/testsuite/go.test/test/printbig.go b/gcc/testsuite/go.test/test/printbig.go index 5693c58d4f6..9e08c39adc2 100644 --- a/gcc/testsuite/go.test/test/printbig.go +++ b/gcc/testsuite/go.test/test/printbig.go @@ -1,4 +1,4 @@ -// cmpout +// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/range.go b/gcc/testsuite/go.test/test/range.go index 8effbe9c53a..3da7d170b58 100644 --- a/gcc/testsuite/go.test/test/range.go +++ b/gcc/testsuite/go.test/test/range.go @@ -23,15 +23,68 @@ func seq(lo, hi int) chan int { return c } +const alphabet = "abcdefghijklmnopqrstuvwxyz" + +func testblankvars() { + n := 0 + for range alphabet { + n++ + } + if n != 26 { + println("for range: wrong count", n, "want 26") + panic("fail") + } + n = 0 + for _ = range alphabet { + n++ + } + if n != 26 { + println("for _ = range: wrong count", n, "want 26") + panic("fail") + } + n = 0 + for _, _ = range alphabet { + n++ + } + if n != 26 { + println("for _, _ = range: wrong count", n, "want 26") + panic("fail") + } + s := 0 + for i, _ := range alphabet { + s += i + } + if s != 325 { + println("for i, _ := range: wrong sum", s, "want 325") + panic("fail") + } + r := rune(0) + for _, v := range alphabet { + r += v + } + if r != 2847 { + println("for _, v := range: wrong sum", r, "want 2847") + panic("fail") + } +} + func testchan() { s := "" for i := range seq('a', 'z') { s += string(i) } - if s != "abcdefghijklmnopqrstuvwxyz" { + if s != alphabet { println("Wanted lowercase alphabet; got", s) panic("fail") } + n := 0 + for range seq('a', 'z') { + n++ + } + if n != 26 { + println("testchan wrong count", n, "want 26") + panic("fail") + } } // test that range over slice only evaluates @@ -87,6 +140,46 @@ func testslice1() { } } +func testslice2() { + n := 0 + nmake = 0 + for range makeslice() { + n++ + } + if nmake != 1 { + println("range called makeslice", nmake, "times") + panic("fail") + } + if n != 5 { + println("wrong count ranging over makeslice", n) + panic("fail") + } +} + +// test that range over []byte(string) only evaluates +// the expression after "range" once. + +func makenumstring() string { + nmake++ + return "\x01\x02\x03\x04\x05" +} + +func testslice3() { + s := byte(0) + nmake = 0 + for _, v := range []byte(makenumstring()) { + s += v + } + if nmake != 1 { + println("range called makenumstring", nmake, "times") + panic("fail") + } + if s != 15 { + println("wrong sum ranging over []byte(makenumstring)", s) + panic("fail") + } +} + // test that range over array only evaluates // the expression after "range" once. @@ -127,6 +220,22 @@ func testarray1() { } } +func testarray2() { + n := 0 + nmake = 0 + for range makearray() { + n++ + } + if nmake != 1 { + println("range called makearray", nmake, "times") + panic("fail") + } + if n != 5 { + println("wrong count ranging over makearray", n) + panic("fail") + } +} + func makearrayptr() *[5]int { nmake++ return &[5]int{1, 2, 3, 4, 5} @@ -176,6 +285,22 @@ func testarrayptr1() { } } +func testarrayptr2() { + n := 0 + nmake = 0 + for range makearrayptr() { + n++ + } + if nmake != 1 { + println("range called makearrayptr", nmake, "times") + panic("fail") + } + if n != 5 { + println("wrong count ranging over makearrayptr", n) + panic("fail") + } +} + // test that range over string only evaluates // the expression after "range" once. @@ -198,6 +323,26 @@ func teststring() { println("wrong sum ranging over makestring", s) panic("fail") } + + x := []rune{'a', 'b'} + i := 1 + for i, x[i] = range "c" { + break + } + if i != 0 || x[0] != 'a' || x[1] != 'c' { + println("wrong parallel assignment", i, x[0], x[1]) + panic("fail") + } + + y := []int{1, 2, 3} + r := rune(1) + for y[r], r = range "\x02" { + break + } + if r != 2 || y[0] != 1 || y[1] != 0 || y[2] != 3 { + println("wrong parallel assignment", r, y[0], y[1], y[2]) + panic("fail") + } } func teststring1() { @@ -216,6 +361,22 @@ func teststring1() { } } +func teststring2() { + n := 0 + nmake = 0 + for range makestring() { + n++ + } + if nmake != 1 { + println("range called makestring", nmake, "times") + panic("fail") + } + if n != 5 { + println("wrong count ranging over makestring", n) + panic("fail") + } +} + // test that range over map only evaluates // the expression after "range" once. @@ -256,6 +417,22 @@ func testmap1() { } } +func testmap2() { + n := 0 + nmake = 0 + for range makemap() { + n++ + } + if nmake != 1 { + println("range called makemap", nmake, "times") + panic("fail") + } + if n != 5 { + println("wrong count ranging over makemap", n) + panic("fail") + } +} + // test that range evaluates the index and value expressions // exactly once per iteration. @@ -295,16 +472,23 @@ func testcalls() { } func main() { + testblankvars() testchan() testarray() testarray1() + testarray2() testarrayptr() testarrayptr1() + testarrayptr2() testslice() testslice1() + testslice2() + testslice3() teststring() teststring1() + teststring2() testmap() testmap1() + testmap2() testcalls() } diff --git a/gcc/testsuite/go.test/test/recover.go b/gcc/testsuite/go.test/test/recover.go index 071be6667ac..e4187c018f6 100644 --- a/gcc/testsuite/go.test/test/recover.go +++ b/gcc/testsuite/go.test/test/recover.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -47,6 +47,7 @@ func main() { test11reflect1() test11reflect2() } + test111() test12() if !interp { test12reflect1() @@ -62,6 +63,7 @@ func main() { test14reflect1() test14reflect2() test15() + test16() } } @@ -77,7 +79,7 @@ func mustRecoverBody(v1, v2, v3, x interface{}) { } v = v2 if v == nil { - println("missing recover") + println("missing recover", x.(int)) die() // panic is useless here } if v != x { @@ -113,10 +115,23 @@ func withoutRecover() { mustNotRecover() // because it's a sub-call } +func withoutRecoverRecursive(n int) { + if n == 0 { + withoutRecoverRecursive(1) + } else { + v := recover() + if v != nil { + println("spurious recover (recursive)", v) + die() + } + } +} + func test1() { - defer mustNotRecover() // because mustRecover will squelch it - defer mustRecover(1) // because of panic below - defer withoutRecover() // should be no-op, leaving for mustRecover to find + defer mustNotRecover() // because mustRecover will squelch it + defer mustRecover(1) // because of panic below + defer withoutRecover() // should be no-op, leaving for mustRecover to find + defer withoutRecoverRecursive(0) // ditto panic(1) } @@ -137,7 +152,7 @@ func test1WithClosures() { mustNotRecover() v := recover() if v == nil { - println("missing recover") + println("missing recover", x.(int)) die() } if v != x { @@ -406,6 +421,49 @@ func test11reflect2() { panic(11) } +// tiny receiver, so basic wrapper in i.M() +type T3deeper struct{} + +func (T3deeper) M() { + badstate() // difference from T3 + mustRecoverBody(doubleRecover(), recover(), recover(), 111) +} + +func test111() { + var i I = T3deeper{} + defer i.M() + panic(111) +} + +type Tiny struct{} + +func (Tiny) M() { + panic(112) +} + +// i.M is a wrapper, and i.M panics. +// +// This is a torture test for an old implementation of recover that +// tried to deal with wrapper functions by doing some argument +// positioning math on both entry and exit. Doing anything on exit +// is a problem because sometimes functions exit via panic instead +// of an ordinary return, so panic would have to know to do the +// same math when unwinding the stack. It gets complicated fast. +// This particular test never worked with the old scheme, because +// panic never did the right unwinding math. +// +// The new scheme adjusts Panic.argp on entry to a wrapper. +// It has no exit work, so if a wrapper is interrupted by a panic, +// there's no cleanup that panic itself must do. +// This test just works now. +func badstate() { + defer func() { + recover() + }() + var i I = Tiny{} + i.M() +} + // large receiver, so basic wrapper in i.M() type T4 [2]string @@ -503,3 +561,27 @@ func test15() { defer f() panic(15) } + +func reflectFunc2(args []reflect.Value) (results []reflect.Value) { + // This will call reflectFunc3 + args[0].Interface().(func())() + return nil +} + +func reflectFunc3(args []reflect.Value) (results []reflect.Value) { + if v := recover(); v != nil { + println("spurious recover", v) + die() + } + return nil +} + +func test16() { + defer mustRecover(16) + + f2 := reflect.MakeFunc(reflect.TypeOf((func(func()))(nil)), reflectFunc2).Interface().(func(func())) + f3 := reflect.MakeFunc(reflect.TypeOf((func())(nil)), reflectFunc3).Interface().(func()) + defer f2(f3) + + panic(16) +} diff --git a/gcc/testsuite/go.test/test/recover1.go b/gcc/testsuite/go.test/test/recover1.go index b763a107417..c14a607c6ba 100644 --- a/gcc/testsuite/go.test/test/recover1.go +++ b/gcc/testsuite/go.test/test/recover1.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/recover2.go b/gcc/testsuite/go.test/test/recover2.go index 946d05ae637..31c06ba2dc1 100644 --- a/gcc/testsuite/go.test/test/recover2.go +++ b/gcc/testsuite/go.test/test/recover2.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -71,7 +71,7 @@ func test5() { } func test6() { - defer mustRecover("unhashable") + defer mustRecover("unhashable type main.T") var x T var z interface{} = x m := make(map[interface{}]int) diff --git a/gcc/testsuite/go.test/test/recover3.go b/gcc/testsuite/go.test/test/recover3.go index e17bfb3f6aa..1b26cb36367 100644 --- a/gcc/testsuite/go.test/test/recover3.go +++ b/gcc/testsuite/go.test/test/recover3.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/rename.go b/gcc/testsuite/go.test/test/rename.go index dc4341718dc..83f184b74dc 100644 --- a/gcc/testsuite/go.test/test/rename.go +++ b/gcc/testsuite/go.test/test/rename.go @@ -1,6 +1,6 @@ // run -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/rename1.go b/gcc/testsuite/go.test/test/rename1.go index 53db68de16e..c49a70a263d 100644 --- a/gcc/testsuite/go.test/test/rename1.go +++ b/gcc/testsuite/go.test/test/rename1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. @@ -10,10 +10,10 @@ package main func main() { - var n byte // ERROR "not a type|expected type" + var n byte // ERROR "not a type|expected type" var y = float32(0) // ERROR "cannot call|expected function" const ( - a = 1 + iota // ERROR "string|incompatible types" "convert iota" + a = 1 + iota // ERROR "invalid operation|incompatible types" ) } diff --git a/gcc/testsuite/go.test/test/reorder.go b/gcc/testsuite/go.test/test/reorder.go index 8fd623c1c70..3a87d025c2a 100644 --- a/gcc/testsuite/go.test/test/reorder.go +++ b/gcc/testsuite/go.test/test/reorder.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. @@ -19,6 +19,7 @@ func main() { p6() p7() p8() + p9() } var gx []int @@ -112,3 +113,39 @@ func p8() { panic(m[0]) } } + +// Issue #13433: Left-to-right assignment of OAS2XXX nodes. +func p9() { + var x bool + + // OAS2FUNC + x, x = fn() + checkOAS2XXX(x, "x, x = fn()") + + // OAS2RECV + var c = make(chan bool, 10) + c <- false + x, x = <-c + checkOAS2XXX(x, "x, x <-c") + + // OAS2MAPR + var m = map[int]bool{0: false} + x, x = m[0] + checkOAS2XXX(x, "x, x = m[0]") + + // OAS2DOTTYPE + var i interface{} = false + x, x = i.(bool) + checkOAS2XXX(x, "x, x = i.(bool)") +} + +//go:noinline +func fn() (bool, bool) { return false, true } + +// checks the order of OAS2XXX. +func checkOAS2XXX(x bool, s string) { + if !x { + fmt.Printf("%s; got=(false); want=(true)\n", s) + panic("failed") + } +} diff --git a/gcc/testsuite/go.test/test/reorder2.go b/gcc/testsuite/go.test/test/reorder2.go index d91f1d89531..07f1b158d0e 100644 --- a/gcc/testsuite/go.test/test/reorder2.go +++ b/gcc/testsuite/go.test/test/reorder2.go @@ -1,6 +1,6 @@ // run -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -58,9 +58,8 @@ func f(x, y string) { log += "f(" + x + ", " + y + ")" } +//go:noinline func ff(x, y string) { - for false { - } // prevent inl log += "ff(" + x + ", " + y + ")" } @@ -69,9 +68,8 @@ func h(x string) string { return x } +//go:noinline func g(x string) string { - for false { - } // prevent inl log += "g(" + x + ")" return x } @@ -168,6 +166,175 @@ func main() { } log = "" + x := 0 + switch x { + case 0: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in switch, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in switch, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in switch, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in switch, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + + c := make(chan int, 1) + c <- 1 + select { + case c <- 0: + case c <- 1: + case <-c: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in select1, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in select1, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in select1, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in select1, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + + c <- 1 + select { + case <-c: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in select2, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in select2, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in select2, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in select2, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + + c <- 1 + select { + default: + case c <- 1: + case <-c: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in select3, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in select3, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in select3, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in select3, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + + c <- 1 + select { + default: + case <-c: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in select4, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in select4, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in select4, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in select4, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + + select { + case <-c: + case <-c: + default: + if a("1")("2")("3"); log != "a(1)a(2)a(3)" { + println("in select5, expecting a(1)a(2)a(3) , got ", log) + err++ + } + log = "" + + if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" { + println("in select5, expecting a(1)b(2)a(2), got ", log) + err++ + } + log = "" + if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" { + println("in select5, expecting a(3)b(4)a(4)b(5)a(5), got ", log) + err++ + } + log = "" + var i I = T1(0) + if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" { + println("in select5, expecting a(6)ba(7)ba(8)ba(9), got", log) + err++ + } + log = "" + } + if err > 0 { panic("fail") } diff --git a/gcc/testsuite/go.test/test/return.go b/gcc/testsuite/go.test/test/return.go index 482f22bd5f4..95f94b9276c 100644 --- a/gcc/testsuite/go.test/test/return.go +++ b/gcc/testsuite/go.test/test/return.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/rotate.go b/gcc/testsuite/go.test/test/rotate.go index 1d7149702a8..9dc4b1e0ff8 100644 --- a/gcc/testsuite/go.test/test/rotate.go +++ b/gcc/testsuite/go.test/test/rotate.go @@ -2,7 +2,7 @@ // NOTE: the actual tests to run are rotate[0123].go -// Copyright 2012 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/rotate0.go b/gcc/testsuite/go.test/test/rotate0.go index 400b225cf7b..09dd9009529 100644 --- a/gcc/testsuite/go.test/test/rotate0.go +++ b/gcc/testsuite/go.test/test/rotate0.go @@ -1,6 +1,6 @@ // runoutput ./rotate.go -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/rotate1.go b/gcc/testsuite/go.test/test/rotate1.go index 98b0b1c849e..19757ec2a8b 100644 --- a/gcc/testsuite/go.test/test/rotate1.go +++ b/gcc/testsuite/go.test/test/rotate1.go @@ -1,6 +1,6 @@ // runoutput ./rotate.go -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/rotate2.go b/gcc/testsuite/go.test/test/rotate2.go index c50f8ce73bd..a55305af345 100644 --- a/gcc/testsuite/go.test/test/rotate2.go +++ b/gcc/testsuite/go.test/test/rotate2.go @@ -1,6 +1,6 @@ // runoutput ./rotate.go -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/rotate3.go b/gcc/testsuite/go.test/test/rotate3.go index 73d47d8524c..edd5d3ac9db 100644 --- a/gcc/testsuite/go.test/test/rotate3.go +++ b/gcc/testsuite/go.test/test/rotate3.go @@ -1,6 +1,6 @@ // runoutput ./rotate.go -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/run b/gcc/testsuite/go.test/test/run deleted file mode 100755 index d206312a29c..00000000000 --- a/gcc/testsuite/go.test/test/run +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2009 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. - -eval $(go tool dist env) -export GOARCH GOOS GOROOT -export E= - -case X"$GOARCH" in -Xamd64) - export A=6 - ;; -X386) - export A=8 - ;; -Xarm) - export A=5 - export E="$GORUN" - ;; -*) - echo 1>&2 run: unsupported '$GOARCH' - exit 1 -esac - -export G="${A}g ${GCFLAGS}" -export L=${A}l -export GOTRACEBACK=0 -export LANG=C -unset GREP_OPTIONS # in case user has a non-standard set - -unset GOROOT_FINAL # breaks ./ imports - -failed=0 - -PATH=${GOBIN:-$GOROOT/bin}:`pwd`:/bin:/usr/bin:/usr/local/bin - -# TODO: We add the tool directory to the PATH to avoid thinking about a better way. -PATH="$GOTOOLDIR:$PATH" - -RUNFILE="${TMPDIR:-/tmp}/gorun-$$-$USER" -TMP1FILE="${TMPDIR:-/tmp}/gotest1-$$-$USER" -TMP2FILE="${TMPDIR:-/tmp}/gotest2-$$-$USER" - -# don't run the machine out of memory: limit individual processes to 4GB. -# on thresher, 3GB suffices to run the tests; with 2GB, peano fails. -ulimit -v 4000000 - -# no core files please -ulimit -c 0 - -true >pass.out >times.out - -exclude=false # exclude nothing -golden=golden.out - -rm -f tmp.go # generated by some tests, left behind if interrupted - -filterout() { - grep '^'"$2"'$' $1 >/dev/null -} - -for dir in . ken chan interface syntax dwarf safe fixedbugs bugs -do - echo - echo '==' $dir'/' - for i in $(ls $dir/*.go 2>/dev/null) - do ( - if $exclude $i; then - exit 0 # continues for loop - fi - export F=$(basename $i .go) - export D=$dir - echo '. ./testlib' >"$RUNFILE" - sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >>"$RUNFILE" - if ! { time -p bash -c "bash '$RUNFILE' >'$TMP1FILE' 2>&1" ; } 2>"$TMP2FILE" - then - echo - echo "===========" $i - cat "$TMP1FILE" - echo >&2 fail: $i - echo "# $i # fail" >>pass.out - elif test -s "$TMP1FILE" - then - echo - echo "===========" $i - cat "$TMP1FILE" - if grep -q '^BUG' "$TMP1FILE" - then - if [ $dir != bugs ] - then - echo >&2 bug: $i - fi - echo "# $i # fail, BUG" >>pass.out - else - echo $i >>pass.out - fi - elif [ $dir = "bugs" ] - then - echo $i succeeded with no output. - else - echo $i >>pass.out - fi - echo $(awk 'NR==1{print $2}' "$TMP2FILE") $D/$F >>times.out - rm -f $F.$A $A.out tmp.go - ) done -done | # clean up some stack noise - egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' | - sed '/tmp.*Bus error/s/.*Bus/Bus/; /tmp.*Trace.BPT/s/.*Trace/Trace/ - s!'"$RUNFILE"'!$RUNFILE!g - s/^PC=0x[0-9a-f]*/pc: xxx/ - s/^pc: 0x[0-9a-f]*/pc: xxx/ - s/PC=0x[0-9a-f]*/PC=xxx/ - /^Trace\/breakpoint trap/d - /^Trace\/BPT trap/d - /RUNFILE/ s/line 1: *[0-9]*/line 1: PID/ - /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d - /Segmentation fault/d - /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out - -rm -f "$RUNFILE" "$TMP1FILE" "$TMP2FILE" *.$A *.a $A.out -diffmsg="" -if ! diff $golden run.out -then - diffmsg="; test output differs" - failed=1 -fi - -notinbugs=$(sed '/^== bugs/q' run.out | grep -c '^BUG') -inbugs=$(sed '1,/^== bugs/d' run.out | grep -c '^BUG') - -echo 2>&1 $inbugs known bugs';' $notinbugs unexpected bugs$diffmsg - -if [ "$failed" != "0" ]; then - echo FAILED -fi - -exit $failed diff --git a/gcc/testsuite/go.test/test/run.go b/gcc/testsuite/go.test/test/run.go index 5c94de6400f..4abf32d25c8 100644 --- a/gcc/testsuite/go.test/test/run.go +++ b/gcc/testsuite/go.test/test/run.go @@ -1,13 +1,10 @@ // skip -// Copyright 2012 The Go Authors. All rights reserved. +// 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. // Run runs tests in the test directory. -// -// TODO(bradfitz): docs of some sort, once we figure out how we're changing -// headers of files package main import ( @@ -15,7 +12,9 @@ import ( "errors" "flag" "fmt" - "go/build" + "hash/fnv" + "io" + "io/fs" "io/ioutil" "log" "os" @@ -33,22 +32,34 @@ import ( var ( verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") + keep = flag.Bool("k", false, "keep. keep temporary directory.") numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run") summary = flag.Bool("summary", false, "show summary of results") + allCodegen = flag.Bool("all_codegen", defaultAllCodeGen(), "run all goos/goarch for codegen") showSkips = flag.Bool("show_skips", false, "show skipped tests") + runSkips = flag.Bool("run_skips", false, "run skipped tests (ignore skip and build tags)") + linkshared = flag.Bool("linkshared", false, "") + updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output") runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run") + + shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.") + shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.") ) -var ( - // gc and ld are [568][gl]. - gc, ld string +// defaultAllCodeGen returns the default value of the -all_codegen +// flag. By default, we prefer to be fast (returning false), except on +// the linux-amd64 builder that's already very fast, so we get more +// test coverage on trybots. See https://golang.org/issue/34297. +func defaultAllCodeGen() bool { + return os.Getenv("GO_BUILDER_NAME") == "linux-amd64" +} - // letter is the build.ArchChar - letter string +var ( + goos, goarch string // dirs are the directories to look for *.go files in. // TODO(bradfitz): just use all directories? - dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "bugs"} + dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen", "runtime"} // ratec controls the max number of tests running at a time. ratec chan bool @@ -69,18 +80,19 @@ const maxTests = 5000 func main() { flag.Parse() - // Disable parallelism if printing - if *verbose { + goos = getenv("GOOS", runtime.GOOS) + goarch = getenv("GOARCH", runtime.GOARCH) + + findExecCmd() + + // Disable parallelism if printing or if using a simulator. + if *verbose || len(findExecCmd()) > 0 { *numParallel = 1 + *runoutputLimit = 1 } ratec = make(chan bool, *numParallel) rungatec = make(chan bool, *runoutputLimit) - var err error - letter, err = build.ArchChar(build.Default.GOARCH) - check(err) - gc = letter + "g" - ld = letter + "l" var tests []*test if flag.NArg() > 0 { @@ -115,16 +127,13 @@ func main() { failed := false resCount := map[string]int{} for _, test := range tests { - <-test.donec + <-test.donec status := "ok " errStr := "" - if _, isSkip := test.err.(skipError); isSkip { - status = "skip" + if e, isSkip := test.err.(skipError); isSkip { test.err = nil - if !skipOkay[path.Join(test.dir, test.gofile)] { - errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr - status = "FAIL" - } + errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + string(e) + status = "FAIL" } if test.err != nil { status = "FAIL" @@ -134,9 +143,6 @@ func main() { failed = true } resCount[status]++ - if status == "skip" && !*verbose && !*showSkips { - continue - } dt := fmt.Sprintf("%.3fs", test.dt.Seconds()) if status == "FAIL" { fmt.Printf("# go run run.go -- %s\n%s\nFAIL\t%s\t%s\n", @@ -161,22 +167,44 @@ func main() { } } -func toolPath(name string) string { - p := filepath.Join(os.Getenv("GOROOT"), "bin", "tool", name) - if _, err := os.Stat(p); err != nil { - log.Fatalf("didn't find binary at %s", p) +// goTool reports the path of the go tool to use to run the tests. +// If possible, use the same Go used to run run.go, otherwise +// fallback to the go version found in the PATH. +func goTool() string { + var exeSuffix string + if runtime.GOOS == "windows" { + exeSuffix = ".exe" } - return p + path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix) + if _, err := os.Stat(path); err == nil { + return path + } + // Just run "go" from PATH + return "go" +} + +func shardMatch(name string) bool { + if *shards == 0 { + return true + } + h := fnv.New32() + io.WriteString(h, name) + return int(h.Sum32()%uint32(*shards)) == *shard } func goFiles(dir string) []string { f, err := os.Open(dir) - check(err) + if err != nil { + log.Fatal(err) + } dirnames, err := f.Readdirnames(-1) - check(err) + f.Close() + if err != nil { + log.Fatal(err) + } names := []string{} for _, name := range dirnames { - if !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") { + if !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && shardMatch(name) { names = append(names, name) } } @@ -186,21 +214,43 @@ func goFiles(dir string) []string { type runCmd func(...string) ([]byte, error) -func compileFile(runcmd runCmd, longname string) (out []byte, err error) { - return runcmd("go", "tool", gc, "-e", longname) +func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, err error) { + cmd := []string{goTool(), "tool", "compile", "-e"} + cmd = append(cmd, flags...) + if *linkshared { + cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") + } + cmd = append(cmd, longname) + return runcmd(cmd...) } -func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err error) { - cmd := []string{"go", "tool", gc, "-e", "-D", ".", "-I", "."} +func compileInDir(runcmd runCmd, dir string, flags []string, localImports bool, names ...string) (out []byte, err error) { + cmd := []string{goTool(), "tool", "compile", "-e"} + if localImports { + // Set relative path for local imports and import search path to current dir. + cmd = append(cmd, "-D", ".", "-I", ".") + } + cmd = append(cmd, flags...) + if *linkshared { + cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") + } for _, name := range names { cmd = append(cmd, filepath.Join(dir, name)) } return runcmd(cmd...) } -func linkFile(runcmd runCmd, goname string) (err error) { - pfile := strings.Replace(goname, ".go", "."+letter, -1) - _, err = runcmd("go", "tool", ld, "-o", "a.exe", "-L", ".", pfile) +func linkFile(runcmd runCmd, goname string, ldflags []string) (err error) { + pfile := strings.Replace(goname, ".go", ".o", -1) + cmd := []string{goTool(), "tool", "link", "-w", "-o", "a.exe", "-L", "."} + if *linkshared { + cmd = append(cmd, "-linkshared", "-installsuffix=dynlink") + } + if ldflags != nil { + cmd = append(cmd, ldflags...) + } + cmd = append(cmd, pfile) + _, err = runcmd(cmd...) return } @@ -209,20 +259,13 @@ type skipError string func (s skipError) Error() string { return string(s) } -func check(err error) { - if err != nil { - log.Fatal(err) - } -} - // test holds the state of a test. type test struct { dir, gofile string donec chan bool // closed when done - dt time.Duration - - src string - action string // "compile", "build", etc. + dt time.Duration + + src string tempDir string err error @@ -283,9 +326,23 @@ func goDirFiles(longdir string) (filter []os.FileInfo, err error) { return } -var packageRE = regexp.MustCompile(`(?m)^package (\w+)`) +var packageRE = regexp.MustCompile(`(?m)^package ([\p{Lu}\p{Ll}\w]+)`) -func goDirPackages(longdir string) ([][]string, error) { +func getPackageNameFromSource(fn string) (string, error) { + data, err := ioutil.ReadFile(fn) + if err != nil { + return "", err + } + pkgname := packageRE.FindStringSubmatch(string(data)) + if pkgname == nil { + return "", fmt.Errorf("cannot find package name in %s", fn) + } + return pkgname[1], nil +} + +// If singlefilepkgs is set, each file is considered a separate package +// even if the package names are the same. +func goDirPackages(longdir string, singlefilepkgs bool) ([][]string, error) { files, err := goDirFiles(longdir) if err != nil { return nil, err @@ -294,19 +351,15 @@ func goDirPackages(longdir string) ([][]string, error) { m := make(map[string]int) for _, file := range files { name := file.Name() - data, err := ioutil.ReadFile(filepath.Join(longdir, name)) + pkgname, err := getPackageNameFromSource(filepath.Join(longdir, name)) if err != nil { - return nil, err - } - pkgname := packageRE.FindStringSubmatch(string(data)) - if pkgname == nil { - return nil, fmt.Errorf("cannot find package name in %s", name) + log.Fatal(err) } - i, ok := m[pkgname[1]] - if !ok { + i, ok := m[pkgname] + if singlefilepkgs || !ok { i = len(pkgs) pkgs = append(pkgs, nil) - m[pkgname[1]] = i + m[pkgname] = i } pkgs[i] = append(pkgs[i], name) } @@ -314,15 +367,16 @@ func goDirPackages(longdir string) ([][]string, error) { } type context struct { - GOOS string - GOARCH string + GOOS string + GOARCH string + noOptEnv bool } // shouldTest looks for build tags in a source file and returns // whether the file should be used according to the tags. func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) { - if idx := strings.Index(src, "\npackage"); idx >= 0 { - src = src[:idx] + if *runSkips { + return true, "" } for _, line := range strings.Split(src, "\n") { line = strings.TrimSpace(line) @@ -335,10 +389,13 @@ func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) { if len(line) == 0 || line[0] != '+' { continue } + gcFlags := os.Getenv("GO_GCFLAGS") ctxt := &context{ - GOOS: goos, - GOARCH: goarch, + GOOS: goos, + GOARCH: goarch, + noOptEnv: strings.Contains(gcFlags, "-N") || strings.Contains(gcFlags, "-l"), } + words := strings.Fields(line) if words[0] == "+build" { ok := false @@ -385,11 +442,31 @@ func (ctxt *context) match(name string) bool { return true } + if ctxt.noOptEnv && name == "gcflags_noopt" { + return true + } + + if name == "test_run" { + return true + } + return false } func init() { checkShouldTest() } +// goGcflags returns the -gcflags argument to use with go build / go run. +// This must match the flags used for building the standard library, +// or else the commands will rebuild any needed packages (like runtime) +// over and over. +func goGcflags() string { + return "-gcflags=all=" + os.Getenv("GO_GCFLAGS") +} + +func goGcflagsIsEmpty() bool { + return "" == os.Getenv("GO_GCFLAGS") +} + // run runs a test. func (t *test) run() { start := time.Now() @@ -408,85 +485,172 @@ func (t *test) run() { t.err = skipError("starts with newline") return } + + // Execution recipe stops at first blank line. pos := strings.Index(t.src, "\n\n") if pos == -1 { t.err = errors.New("double newline not found") return } - if ok, why := shouldTest(t.src, runtime.GOOS, runtime.GOARCH); !ok { - t.action = "skip" - if *showSkips { - fmt.Printf("%-20s %-20s: %s\n", t.action, t.goFileName(), why) - } - return - } action := t.src[:pos] if nl := strings.Index(action, "\n"); nl >= 0 && strings.Contains(action[:nl], "+build") { // skip first line action = action[nl+1:] } - if strings.HasPrefix(action, "//") { - action = action[2:] + action = strings.TrimPrefix(action, "//") + + // Check for build constraints only up to the actual code. + pkgPos := strings.Index(t.src, "\npackage") + if pkgPos == -1 { + pkgPos = pos // some files are intentionally malformed + } + if ok, why := shouldTest(t.src[:pkgPos], goos, goarch); !ok { + if *showSkips { + fmt.Printf("%-20s %-20s: %s\n", "skip", t.goFileName(), why) + } + return } var args, flags []string + var tim int wantError := false + wantAuto := false + singlefilepkgs := false + setpkgpaths := false + localImports := true f := strings.Fields(action) if len(f) > 0 { action = f[0] args = f[1:] } + // TODO: Clean up/simplify this switch statement. switch action { - case "rundircmpout": - action = "rundir" - t.action = "rundir" - case "cmpout": - action = "run" // the run case already looks for /.out files - fallthrough - case "compile", "compiledir", "build", "run", "runoutput", "rundir": - t.action = action + case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "buildrun", "runoutput", "rundir", "runindir", "asmcheck": + // nothing to do + case "errorcheckandrundir": + wantError = false // should be no error if also will run + case "errorcheckwithauto": + action = "errorcheck" + wantAuto = true + wantError = true case "errorcheck", "errorcheckdir", "errorcheckoutput": - t.action = action wantError = true - for len(args) > 0 && strings.HasPrefix(args[0], "-") { - if args[0] == "-0" { - wantError = false - } else { - flags = append(flags, args[0]) - } - args = args[1:] - } case "skip": - t.action = "skip" + if *runSkips { + break + } return default: t.err = skipError("skipped; unknown pattern: " + action) - t.action = "??" return } + // collect flags + for len(args) > 0 && strings.HasPrefix(args[0], "-") { + switch args[0] { + case "-1": + wantError = true + case "-0": + wantError = false + case "-s": + singlefilepkgs = true + case "-P": + setpkgpaths = true + case "-n": + // Do not set relative path for local imports to current dir, + // e.g. do not pass -D . -I . to the compiler. + // Used in fixedbugs/bug345.go to allow compilation and import of local pkg. + // See golang.org/issue/25635 + localImports = false + case "-t": // timeout in seconds + args = args[1:] + var err error + tim, err = strconv.Atoi(args[0]) + if err != nil { + t.err = fmt.Errorf("need number of seconds for -t timeout, got %s instead", args[0]) + } + + default: + flags = append(flags, args[0]) + } + args = args[1:] + } + if action == "errorcheck" { + found := false + for i, f := range flags { + if strings.HasPrefix(f, "-d=") { + flags[i] = f + ",ssa/check/on" + found = true + break + } + } + if !found { + flags = append(flags, "-d=ssa/check/on") + } + } + t.makeTempDir() - defer os.RemoveAll(t.tempDir) + if !*keep { + defer os.RemoveAll(t.tempDir) + } err = ioutil.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0644) - check(err) + if err != nil { + log.Fatal(err) + } // A few tests (of things like the environment) require these to be set. - os.Setenv("GOOS", runtime.GOOS) - os.Setenv("GOARCH", runtime.GOARCH) + if os.Getenv("GOOS") == "" { + os.Setenv("GOOS", runtime.GOOS) + } + if os.Getenv("GOARCH") == "" { + os.Setenv("GOARCH", runtime.GOARCH) + } - useTmp := true + var ( + runInDir = t.tempDir + tempDirIsGOPATH = false + ) runcmd := func(args ...string) ([]byte, error) { cmd := exec.Command(args[0], args[1:]...) var buf bytes.Buffer cmd.Stdout = &buf cmd.Stderr = &buf - if useTmp { - cmd.Dir = t.tempDir - cmd.Env = envForDir(cmd.Dir) + cmd.Env = append(os.Environ(), "GOENV=off", "GOFLAGS=") + if runInDir != "" { + cmd.Dir = runInDir + // Set PWD to match Dir to speed up os.Getwd in the child process. + cmd.Env = append(cmd.Env, "PWD="+cmd.Dir) + } + if tempDirIsGOPATH { + cmd.Env = append(cmd.Env, "GOPATH="+t.tempDir) + } + + var err error + + if tim != 0 { + err = cmd.Start() + // This command-timeout code adapted from cmd/go/test.go + if err == nil { + tick := time.NewTimer(time.Duration(tim) * time.Second) + done := make(chan error) + go func() { + done <- cmd.Wait() + }() + select { + case err = <-done: + // ok + case <-tick.C: + cmd.Process.Kill() + err = <-done + // err = errors.New("Test timeout") + } + tick.Stop() + } + } else { + err = cmd.Run() } - err := cmd.Run() if err != nil { err = fmt.Errorf("%s\n%s", err, buf.Bytes()) } @@ -498,8 +662,67 @@ func (t *test) run() { default: t.err = fmt.Errorf("unimplemented action %q", action) + case "asmcheck": + // Compile Go file and match the generated assembly + // against a set of regexps in comments. + ops := t.wantedAsmOpcodes(long) + self := runtime.GOOS + "/" + runtime.GOARCH + for _, env := range ops.Envs() { + // Only run checks relevant to the current GOOS/GOARCH, + // to avoid triggering a cross-compile of the runtime. + if string(env) != self && !strings.HasPrefix(string(env), self+"/") && !*allCodegen { + continue + } + // -S=2 forces outermost line numbers when disassembling inlined code. + cmdline := []string{"build", "-gcflags", "-S=2"} + + // Append flags, but don't override -gcflags=-S=2; add to it instead. + for i := 0; i < len(flags); i++ { + flag := flags[i] + switch { + case strings.HasPrefix(flag, "-gcflags="): + cmdline[2] += " " + strings.TrimPrefix(flag, "-gcflags=") + case strings.HasPrefix(flag, "--gcflags="): + cmdline[2] += " " + strings.TrimPrefix(flag, "--gcflags=") + case flag == "-gcflags", flag == "--gcflags": + i++ + if i < len(flags) { + cmdline[2] += " " + flags[i] + } + default: + cmdline = append(cmdline, flag) + } + } + + cmdline = append(cmdline, long) + cmd := exec.Command(goTool(), cmdline...) + cmd.Env = append(os.Environ(), env.Environ()...) + if len(flags) > 0 && flags[0] == "-race" { + cmd.Env = append(cmd.Env, "CGO_ENABLED=1") + } + + var buf bytes.Buffer + cmd.Stdout, cmd.Stderr = &buf, &buf + if err := cmd.Run(); err != nil { + fmt.Println(env, "\n", cmd.Stderr) + t.err = err + return + } + + t.err = t.asmCheck(buf.String(), long, env, ops[env]) + if t.err != nil { + return + } + } + return + case "errorcheck": - cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter} + // Compile Go file. + // Fail if wantError is true and compilation was successful and vice versa. + // Match errors produced by gc against errors in comments. + // TODO(gri) remove need for -C (disable printing of columns in error messages) + cmdline := []string{goTool(), "tool", "compile", "-C", "-e", "-o", "a.o"} + // No need to add -dynlink even if linkshared if we're just checking for errors... cmdline = append(cmdline, flags...) cmdline = append(cmdline, long) out, err := runcmd(cmdline...) @@ -514,39 +737,50 @@ func (t *test) run() { return } } - t.err = t.errorCheck(string(out), long, t.gofile) + if *updateErrors { + t.updateErrors(string(out), long) + } + t.err = t.errorCheck(string(out), wantAuto, long, t.gofile) return case "compile": - _, t.err = compileFile(runcmd, long) + // Compile Go file. + _, t.err = compileFile(runcmd, long, flags) case "compiledir": - // Compile all files in the directory in lexicographic order. + // Compile all files in the directory as packages in lexicographic order. longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) + pkgs, err := goDirPackages(longdir, singlefilepkgs) if err != nil { t.err = err return } for _, gofiles := range pkgs { - _, t.err = compileInDir(runcmd, longdir, gofiles...) + _, t.err = compileInDir(runcmd, longdir, flags, localImports, gofiles...) if t.err != nil { return } } - case "errorcheckdir": - // errorcheck all files in lexicographic order - // useful for finding importing errors + case "errorcheckdir", "errorcheckandrundir": + // Compile and errorCheck all files in the directory as packages in lexicographic order. + // If errorcheckdir and wantError, compilation of the last package must fail. + // If errorcheckandrundir and wantError, compilation of the package prior the last must fail. longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) + pkgs, err := goDirPackages(longdir, singlefilepkgs) if err != nil { t.err = err return } + errPkg := len(pkgs) - 1 + if wantError && action == "errorcheckandrundir" { + // The last pkg should compiled successfully and will be run in next case. + // Preceding pkg must return an error from compileInDir. + errPkg-- + } for i, gofiles := range pkgs { - out, err := compileInDir(runcmd, longdir, gofiles...) - if i == len(pkgs)-1 { + out, err := compileInDir(runcmd, longdir, flags, localImports, gofiles...) + if i == errPkg { if wantError && err == nil { t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) return @@ -562,34 +796,66 @@ func (t *test) run() { for _, name := range gofiles { fullshort = append(fullshort, filepath.Join(longdir, name), name) } - t.err = t.errorCheck(string(out), fullshort...) + t.err = t.errorCheck(string(out), wantAuto, fullshort...) if t.err != nil { break } } + if action == "errorcheckdir" { + return + } + fallthrough case "rundir": - // Compile all files in the directory in lexicographic order. - // then link as if the last file is the main package and run it + // Compile all files in the directory as packages in lexicographic order. + // In case of errorcheckandrundir, ignore failed compilation of the package before the last. + // Link as if the last file is the main package, run it. + // Verify the expected output. longdir := filepath.Join(cwd, t.goDirName()) - pkgs, err := goDirPackages(longdir) + pkgs, err := goDirPackages(longdir, singlefilepkgs) if err != nil { t.err = err return } + // Split flags into gcflags and ldflags + ldflags := []string{} + for i, fl := range flags { + if fl == "-ldflags" { + ldflags = flags[i+1:] + flags = flags[0:i] + break + } + } + for i, gofiles := range pkgs { - _, err := compileInDir(runcmd, longdir, gofiles...) - if err != nil { + pflags := []string{} + pflags = append(pflags, flags...) + if setpkgpaths { + fp := filepath.Join(longdir, gofiles[0]) + pkgname, err := getPackageNameFromSource(fp) + if err != nil { + log.Fatal(err) + } + pflags = append(pflags, "-p", pkgname) + } + _, err := compileInDir(runcmd, longdir, pflags, localImports, gofiles...) + // Allow this package compilation fail based on conditions below; + // its errors were checked in previous case. + if err != nil && !(wantError && action == "errorcheckandrundir" && i == len(pkgs)-2) { t.err = err return } if i == len(pkgs)-1 { - err = linkFile(runcmd, gofiles[0]) + err = linkFile(runcmd, gofiles[0], ldflags) if err != nil { t.err = err return } - out, err := runcmd(append([]string{filepath.Join(t.tempDir, "a.exe")}, args...)...) + var cmd []string + cmd = append(cmd, findExecCmd()...) + cmd = append(cmd, filepath.Join(t.tempDir, "a.exe")) + cmd = append(cmd, args...) + out, err := runcmd(cmd...) if err != nil { t.err = err return @@ -600,50 +866,256 @@ func (t *test) run() { } } + case "runindir": + // Make a shallow copy of t.goDirName() in its own module and GOPATH, and + // run "go run ." in it. The module path (and hence import path prefix) of + // the copy is equal to the basename of the source directory. + // + // It's used when test a requires a full 'go build' in order to compile + // the sources, such as when importing multiple packages (issue29612.dir) + // or compiling a package containing assembly files (see issue15609.dir), + // but still needs to be run to verify the expected output. + tempDirIsGOPATH = true + srcDir := t.goDirName() + modName := filepath.Base(srcDir) + gopathSrcDir := filepath.Join(t.tempDir, "src", modName) + runInDir = gopathSrcDir + + if err := overlayDir(gopathSrcDir, srcDir); err != nil { + t.err = err + return + } + + modFile := fmt.Sprintf("module %s\ngo 1.14\n", modName) + if err := ioutil.WriteFile(filepath.Join(gopathSrcDir, "go.mod"), []byte(modFile), 0666); err != nil { + t.err = err + return + } + + cmd := []string{goTool(), "run", goGcflags()} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + cmd = append(cmd, ".") + out, err := runcmd(cmd...) + if err != nil { + t.err = err + return + } + if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } + case "build": - _, err := runcmd("go", "build", "-o", "a.exe", long) + // Build Go file. + _, err := runcmd(goTool(), "build", goGcflags(), "-o", "a.exe", long) + if err != nil { + t.err = err + } + + case "builddir", "buildrundir": + // Build an executable from all the .go and .s files in a subdirectory. + // Run it and verify its output in the buildrundir case. + longdir := filepath.Join(cwd, t.goDirName()) + files, dirErr := ioutil.ReadDir(longdir) + if dirErr != nil { + t.err = dirErr + break + } + var gos []string + var asms []string + for _, file := range files { + switch filepath.Ext(file.Name()) { + case ".go": + gos = append(gos, filepath.Join(longdir, file.Name())) + case ".s": + asms = append(asms, filepath.Join(longdir, file.Name())) + } + + } + if len(asms) > 0 { + emptyHdrFile := filepath.Join(t.tempDir, "go_asm.h") + if err := ioutil.WriteFile(emptyHdrFile, nil, 0666); err != nil { + t.err = fmt.Errorf("write empty go_asm.h: %s", err) + return + } + cmd := []string{goTool(), "tool", "asm", "-gensymabis", "-o", "symabis"} + cmd = append(cmd, asms...) + _, err = runcmd(cmd...) + if err != nil { + t.err = err + break + } + } + var objs []string + cmd := []string{goTool(), "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} + if len(asms) > 0 { + cmd = append(cmd, "-asmhdr", "go_asm.h", "-symabis", "symabis") + } + cmd = append(cmd, gos...) + _, err := runcmd(cmd...) + if err != nil { + t.err = err + break + } + objs = append(objs, "go.o") + if len(asms) > 0 { + cmd = []string{goTool(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"} + cmd = append(cmd, asms...) + _, err = runcmd(cmd...) + if err != nil { + t.err = err + break + } + objs = append(objs, "asm.o") + } + cmd = []string{goTool(), "tool", "pack", "c", "all.a"} + cmd = append(cmd, objs...) + _, err = runcmd(cmd...) + if err != nil { + t.err = err + break + } + cmd = []string{goTool(), "tool", "link", "-o", "a.exe", "all.a"} + _, err = runcmd(cmd...) if err != nil { t.err = err + break + } + if action == "buildrundir" { + cmd = append(findExecCmd(), filepath.Join(t.tempDir, "a.exe")) + out, err := runcmd(cmd...) + if err != nil { + t.err = err + break + } + if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } + } + + case "buildrun": + // Build an executable from Go file, then run it, verify its output. + // Useful for timeout tests where failure mode is infinite loop. + // TODO: not supported on NaCl + cmd := []string{goTool(), "build", goGcflags(), "-o", "a.exe"} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + longdirgofile := filepath.Join(filepath.Join(cwd, t.dir), t.gofile) + cmd = append(cmd, flags...) + cmd = append(cmd, longdirgofile) + _, err := runcmd(cmd...) + if err != nil { + t.err = err + return + } + cmd = []string{"./a.exe"} + out, err := runcmd(append(cmd, args...)...) + if err != nil { + t.err = err + return + } + + if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { + t.err = fmt.Errorf("incorrect output\n%s", out) } case "run": - useTmp = false - out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) + // Run Go file if no special go command flags are provided; + // otherwise build an executable and run it. + // Verify the output. + runInDir = "" + var out []byte + var err error + if len(flags)+len(args) == 0 && goGcflagsIsEmpty() && !*linkshared && goarch == runtime.GOARCH && goos == runtime.GOOS { + // If we're not using special go command flags, + // skip all the go command machinery. + // This avoids any time the go command would + // spend checking whether, for example, the installed + // package runtime is up to date. + // Because we run lots of trivial test programs, + // the time adds up. + pkg := filepath.Join(t.tempDir, "pkg.a") + if _, err := runcmd(goTool(), "tool", "compile", "-o", pkg, t.goFileName()); err != nil { + t.err = err + return + } + exe := filepath.Join(t.tempDir, "test.exe") + cmd := []string{goTool(), "tool", "link", "-s", "-w"} + cmd = append(cmd, "-o", exe, pkg) + if _, err := runcmd(cmd...); err != nil { + t.err = err + return + } + out, err = runcmd(append([]string{exe}, args...)...) + } else { + cmd := []string{goTool(), "run", goGcflags()} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + cmd = append(cmd, flags...) + cmd = append(cmd, t.goFileName()) + out, err = runcmd(append(cmd, args...)...) + } if err != nil { t.err = err + return } if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { t.err = fmt.Errorf("incorrect output\n%s", out) } case "runoutput": + // Run Go file and write its output into temporary Go file. + // Run generated Go file and verify its output. rungatec <- true defer func() { <-rungatec }() - useTmp = false - out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) + runInDir = "" + cmd := []string{goTool(), "run", goGcflags()} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + cmd = append(cmd, t.goFileName()) + out, err := runcmd(append(cmd, args...)...) if err != nil { t.err = err + return } tfile := filepath.Join(t.tempDir, "tmp__.go") if err := ioutil.WriteFile(tfile, out, 0666); err != nil { t.err = fmt.Errorf("write tempfile:%s", err) return } - out, err = runcmd("go", "run", tfile) + cmd = []string{goTool(), "run", goGcflags()} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + cmd = append(cmd, tfile) + out, err = runcmd(cmd...) if err != nil { t.err = err + return } if string(out) != t.expectedOutput() { t.err = fmt.Errorf("incorrect output\n%s", out) } case "errorcheckoutput": - useTmp = false - out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) + // Run Go file and write its output into temporary Go file. + // Compile and errorCheck generated Go file. + runInDir = "" + cmd := []string{goTool(), "run", goGcflags()} + if *linkshared { + cmd = append(cmd, "-linkshared") + } + cmd = append(cmd, t.goFileName()) + out, err := runcmd(append(cmd, args...)...) if err != nil { t.err = err + return } tfile := filepath.Join(t.tempDir, "tmp__.go") err = ioutil.WriteFile(tfile, out, 0666) @@ -651,7 +1123,7 @@ func (t *test) run() { t.err = fmt.Errorf("write tempfile:%s", err) return } - cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter} + cmdline := []string{goTool(), "tool", "compile", "-e", "-o", "a.o"} cmdline = append(cmdline, flags...) cmdline = append(cmdline, tfile) out, err = runcmd(cmdline...) @@ -666,11 +1138,28 @@ func (t *test) run() { return } } - t.err = t.errorCheck(string(out), tfile, "tmp__.go") + t.err = t.errorCheck(string(out), false, tfile, "tmp__.go") return } } +var execCmd []string + +func findExecCmd() []string { + if execCmd != nil { + return execCmd + } + execCmd = []string{} // avoid work the second time + if goos == runtime.GOOS && goarch == runtime.GOARCH { + return execCmd + } + path, err := exec.LookPath(fmt.Sprintf("go_%s_%s_exec", goos, goarch)) + if err == nil { + execCmd = []string{path} + } + return execCmd +} + func (t *test) String() string { return filepath.Join(t.dir, t.gofile) } @@ -678,7 +1167,12 @@ func (t *test) String() string { func (t *test) makeTempDir() { var err error t.tempDir, err = ioutil.TempDir("", "") - check(err) + if err != nil { + log.Fatal(err) + } + if *keep { + log.Printf("Temporary directory is %s", t.tempDir) + } } func (t *test) expectedOutput() string { @@ -689,29 +1183,45 @@ func (t *test) expectedOutput() string { return string(b) } -func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { - defer func() { - if *verbose && err != nil { - log.Printf("%s gc output:\n%s", t, outStr) - } - }() - var errs []error - - var out []string - // 6g error messages continue onto additional lines with leading tabs. +func splitOutput(out string, wantAuto bool) []string { + // gc error messages continue onto additional lines with leading tabs. // Split the output at the beginning of each line that doesn't begin with a tab. - for _, line := range strings.Split(outStr, "\n") { + // lines are impossible to match so those are filtered out. + var res []string + for _, line := range strings.Split(out, "\n") { if strings.HasSuffix(line, "\r") { // remove '\r', output by compiler on windows line = line[:len(line)-1] } if strings.HasPrefix(line, "\t") { - out[len(out)-1] += "\n" + line - } else if strings.HasPrefix(line, "go tool") { + res[len(res)-1] += "\n" + line + } else if strings.HasPrefix(line, "go tool") || strings.HasPrefix(line, "#") || !wantAuto && strings.HasPrefix(line, "") { continue } else if strings.TrimSpace(line) != "" { - out = append(out, line) + res = append(res, line) } } + return res +} + +// errorCheck matches errors in outStr against comments in source files. +// For each line of the source files which should generate an error, +// there should be a comment of the form // ERROR "regexp". +// If outStr has an error for a line which has no such comment, +// this function will report an error. +// Likewise if outStr does not have an error for a line which has a comment, +// or if the error message does not match the . +// The syntax is Perl but it's best to stick to egrep. +// +// Sources files are supplied as fullshort slice. +// It consists of pairs: full path to source file and its base name. +func (t *test) errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) { + defer func() { + if *verbose && err != nil { + log.Printf("%s gc output:\n%s", t, outStr) + } + }() + var errs []error + out := splitOutput(outStr, wantAuto) // Cut directory name. for i := range out { @@ -729,7 +1239,11 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { for _, we := range want { var errmsgs []string - errmsgs, out = partitionStrings(we.filterRe, out) + if we.auto { + errmsgs, out = partitionStrings("", out) + } else { + errmsgs, out = partitionStrings(we.prefix, out) + } if len(errmsgs) == 0 { errs = append(errs, fmt.Errorf("%s:%d: missing error %q", we.file, we.lineNum, we.reStr)) continue @@ -737,7 +1251,13 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { matched := false n := len(out) for _, errmsg := range errmsgs { - if we.re.MatchString(errmsg) { + // Assume errmsg says "file:line: foo". + // Cut leading "file:line: " to avoid accidental matching of file name instead of message. + text := errmsg + if i := strings.Index(text, " "); i >= 0 { + text = text[i+1:] + } + if we.re.MatchString(text) { matched = true } else { out = append(out, errmsg) @@ -768,12 +1288,100 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { fmt.Fprintf(&buf, "%s\n", err.Error()) } return errors.New(buf.String()) +} + +func (t *test) updateErrors(out, file string) { + base := path.Base(file) + // Read in source file. + src, err := ioutil.ReadFile(file) + if err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + lines := strings.Split(string(src), "\n") + // Remove old errors. + for i, ln := range lines { + pos := strings.Index(ln, " // ERROR ") + if pos >= 0 { + lines[i] = ln[:pos] + } + } + // Parse new errors. + errors := make(map[int]map[string]bool) + tmpRe := regexp.MustCompile(`autotmp_[0-9]+`) + for _, errStr := range splitOutput(out, false) { + colon1 := strings.Index(errStr, ":") + if colon1 < 0 || errStr[:colon1] != file { + continue + } + colon2 := strings.Index(errStr[colon1+1:], ":") + if colon2 < 0 { + continue + } + colon2 += colon1 + 1 + line, err := strconv.Atoi(errStr[colon1+1 : colon2]) + line-- + if err != nil || line < 0 || line >= len(lines) { + continue + } + msg := errStr[colon2+2:] + msg = strings.Replace(msg, file, base, -1) // normalize file mentions in error itself + msg = strings.TrimLeft(msg, " \t") + for _, r := range []string{`\`, `*`, `+`, `?`, `[`, `]`, `(`, `)`} { + msg = strings.Replace(msg, r, `\`+r, -1) + } + msg = strings.Replace(msg, `"`, `.`, -1) + msg = tmpRe.ReplaceAllLiteralString(msg, `autotmp_[0-9]+`) + if errors[line] == nil { + errors[line] = make(map[string]bool) + } + errors[line][msg] = true + } + // Add new errors. + for line, errs := range errors { + var sorted []string + for e := range errs { + sorted = append(sorted, e) + } + sort.Strings(sorted) + lines[line] += " // ERROR" + for _, e := range sorted { + lines[line] += fmt.Sprintf(` "%s$"`, e) + } + } + // Write new file. + err = ioutil.WriteFile(file, []byte(strings.Join(lines, "\n")), 0640) + if err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + // Polish. + exec.Command(goTool(), "fmt", file).CombinedOutput() +} +// matchPrefix reports whether s is of the form ^(.*/)?prefix(:|[), +// That is, it needs the file name prefix followed by a : or a [, +// and possibly preceded by a directory name. +func matchPrefix(s, prefix string) bool { + i := strings.Index(s, ":") + if i < 0 { + return false + } + j := strings.LastIndex(s[:i], "/") + s = s[j+1:] + if len(s) <= len(prefix) || s[:len(prefix)] != prefix { + return false + } + switch s[len(prefix)] { + case '[', ':': + return true + } + return false } -func partitionStrings(rx *regexp.Regexp, strs []string) (matched, unmatched []string) { +func partitionStrings(prefix string, strs []string) (matched, unmatched []string) { for _, s := range strs { - if rx.MatchString(s) { + if matchPrefix(s, prefix) { matched = append(matched, s) } else { unmatched = append(unmatched, s) @@ -783,20 +1391,24 @@ func partitionStrings(rx *regexp.Regexp, strs []string) (matched, unmatched []st } type wantedError struct { - reStr string - re *regexp.Regexp - lineNum int - file string - filterRe *regexp.Regexp // /^file:linenum\b/m + reStr string + re *regexp.Regexp + lineNum int + auto bool // match line + file string + prefix string } var ( errRx = regexp.MustCompile(`// (?:GC_)?ERROR (.*)`) + errAutoRx = regexp.MustCompile(`// (?:GC_)?ERRORAUTO (.*)`) errQuotesRx = regexp.MustCompile(`"([^"]*)"`) lineRx = regexp.MustCompile(`LINE(([+-])([0-9]+))?`) ) func (t *test) wantedErrors(file, short string) (errs []wantedError) { + cache := make(map[string]*regexp.Regexp) + src, _ := ioutil.ReadFile(file) for i, line := range strings.Split(string(src), "\n") { lineNum := i + 1 @@ -804,7 +1416,13 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { // double comment disables ERROR continue } - m := errRx.FindStringSubmatch(line) + var auto bool + m := errAutoRx.FindStringSubmatch(line) + if m != nil { + auto = true + } else { + m = errRx.FindStringSubmatch(line) + } if m == nil { continue } @@ -825,17 +1443,23 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { } return fmt.Sprintf("%s:%d", short, n) }) - re, err := regexp.Compile(rx) - if err != nil { - log.Fatalf("%s:%d: invalid regexp in ERROR line: %v", t.goFileName(), lineNum, err) + re := cache[rx] + if re == nil { + var err error + re, err = regexp.Compile(rx) + if err != nil { + log.Fatalf("%s:%d: invalid regexp \"%s\" in ERROR line: %v", t.goFileName(), lineNum, rx, err) + } + cache[rx] = re } - filterPattern := fmt.Sprintf(`^(\w+/)?%s:%d[:[]`, regexp.QuoteMeta(short), lineNum) + prefix := fmt.Sprintf("%s:%d", short, lineNum) errs = append(errs, wantedError{ - reStr: rx, - re: re, - filterRe: regexp.MustCompile(filterPattern), - lineNum: lineNum, - file: short, + reStr: rx, + re: re, + prefix: prefix, + auto: auto, + lineNum: lineNum, + file: short, }) } } @@ -843,15 +1467,267 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { return } -var skipOkay = map[string]bool{ - "linkx.go": true, // like "run" but wants linker flags - "sinit.go": true, - "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir. - "fixedbugs/bug302.go": true, // tests both .$O and .a imports. - "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation. - "fixedbugs/bug369.go": true, // needs compiler flags. - "fixedbugs/bug429.go": true, // like "run" but program should fail - "bugs/bug395.go": true, +const ( + // Regexp to match a single opcode check: optionally begin with "-" (to indicate + // a negative check), followed by a string literal enclosed in "" or ``. For "", + // backslashes must be handled. + reMatchCheck = `-?(?:\x60[^\x60]*\x60|"(?:[^"\\]|\\.)*")` +) + +var ( + // Regexp to split a line in code and comment, trimming spaces + rxAsmComment = regexp.MustCompile(`^\s*(.*?)\s*(?://\s*(.+)\s*)?$`) + + // Regexp to extract an architecture check: architecture name (or triplet), + // followed by semi-colon, followed by a comma-separated list of opcode checks. + // Extraneous spaces are ignored. + rxAsmPlatform = regexp.MustCompile(`(\w+)(/\w+)?(/\w*)?\s*:\s*(` + reMatchCheck + `(?:\s*,\s*` + reMatchCheck + `)*)`) + + // Regexp to extract a single opcoded check + rxAsmCheck = regexp.MustCompile(reMatchCheck) + + // List of all architecture variants. Key is the GOARCH architecture, + // value[0] is the variant-changing environment variable, and values[1:] + // are the supported variants. + archVariants = map[string][]string{ + "386": {"GO386", "sse2", "softfloat"}, + "amd64": {}, + "arm": {"GOARM", "5", "6", "7"}, + "arm64": {}, + "mips": {"GOMIPS", "hardfloat", "softfloat"}, + "mips64": {"GOMIPS64", "hardfloat", "softfloat"}, + "ppc64": {"GOPPC64", "power8", "power9"}, + "ppc64le": {"GOPPC64", "power8", "power9"}, + "s390x": {}, + "wasm": {}, + } +) + +// wantedAsmOpcode is a single asmcheck check +type wantedAsmOpcode struct { + fileline string // original source file/line (eg: "/path/foo.go:45") + line int // original source line + opcode *regexp.Regexp // opcode check to be performed on assembly output + negative bool // true if the check is supposed to fail rather than pass + found bool // true if the opcode check matched at least one in the output +} + +// A build environment triplet separated by slashes (eg: linux/386/sse2). +// The third field can be empty if the arch does not support variants (eg: "plan9/amd64/") +type buildEnv string + +// Environ returns the environment it represents in cmd.Environ() "key=val" format +// For instance, "linux/386/sse2".Environ() returns {"GOOS=linux", "GOARCH=386", "GO386=sse2"} +func (b buildEnv) Environ() []string { + fields := strings.Split(string(b), "/") + if len(fields) != 3 { + panic("invalid buildEnv string: " + string(b)) + } + env := []string{"GOOS=" + fields[0], "GOARCH=" + fields[1]} + if fields[2] != "" { + env = append(env, archVariants[fields[1]][0]+"="+fields[2]) + } + return env +} + +// asmChecks represents all the asmcheck checks present in a test file +// The outer map key is the build triplet in which the checks must be performed. +// The inner map key represent the source file line ("filename.go:1234") at which the +// checks must be performed. +type asmChecks map[buildEnv]map[string][]wantedAsmOpcode + +// Envs returns all the buildEnv in which at least one check is present +func (a asmChecks) Envs() []buildEnv { + var envs []buildEnv + for e := range a { + envs = append(envs, e) + } + sort.Slice(envs, func(i, j int) bool { + return string(envs[i]) < string(envs[j]) + }) + return envs +} + +func (t *test) wantedAsmOpcodes(fn string) asmChecks { + ops := make(asmChecks) + + comment := "" + src, _ := ioutil.ReadFile(fn) + for i, line := range strings.Split(string(src), "\n") { + matches := rxAsmComment.FindStringSubmatch(line) + code, cmt := matches[1], matches[2] + + // Keep comments pending in the comment variable until + // we find a line that contains some code. + comment += " " + cmt + if code == "" { + continue + } + + // Parse and extract any architecture check from comments, + // made by one architecture name and multiple checks. + lnum := fn + ":" + strconv.Itoa(i+1) + for _, ac := range rxAsmPlatform.FindAllStringSubmatch(comment, -1) { + archspec, allchecks := ac[1:4], ac[4] + + var arch, subarch, os string + switch { + case archspec[2] != "": // 3 components: "linux/386/sse2" + os, arch, subarch = archspec[0], archspec[1][1:], archspec[2][1:] + case archspec[1] != "": // 2 components: "386/sse2" + os, arch, subarch = "linux", archspec[0], archspec[1][1:] + default: // 1 component: "386" + os, arch, subarch = "linux", archspec[0], "" + if arch == "wasm" { + os = "js" + } + } + + if _, ok := archVariants[arch]; !ok { + log.Fatalf("%s:%d: unsupported architecture: %v", t.goFileName(), i+1, arch) + } + + // Create the build environments corresponding the above specifiers + envs := make([]buildEnv, 0, 4) + if subarch != "" { + envs = append(envs, buildEnv(os+"/"+arch+"/"+subarch)) + } else { + subarchs := archVariants[arch] + if len(subarchs) == 0 { + envs = append(envs, buildEnv(os+"/"+arch+"/")) + } else { + for _, sa := range archVariants[arch][1:] { + envs = append(envs, buildEnv(os+"/"+arch+"/"+sa)) + } + } + } + + for _, m := range rxAsmCheck.FindAllString(allchecks, -1) { + negative := false + if m[0] == '-' { + negative = true + m = m[1:] + } + + rxsrc, err := strconv.Unquote(m) + if err != nil { + log.Fatalf("%s:%d: error unquoting string: %v", t.goFileName(), i+1, err) + } + + // Compile the checks as regular expressions. Notice that we + // consider checks as matching from the beginning of the actual + // assembler source (that is, what is left on each line of the + // compile -S output after we strip file/line info) to avoid + // trivial bugs such as "ADD" matching "FADD". This + // doesn't remove genericity: it's still possible to write + // something like "F?ADD", but we make common cases simpler + // to get right. + oprx, err := regexp.Compile("^" + rxsrc) + if err != nil { + log.Fatalf("%s:%d: %v", t.goFileName(), i+1, err) + } + + for _, env := range envs { + if ops[env] == nil { + ops[env] = make(map[string][]wantedAsmOpcode) + } + ops[env][lnum] = append(ops[env][lnum], wantedAsmOpcode{ + negative: negative, + fileline: lnum, + line: i + 1, + opcode: oprx, + }) + } + } + } + comment = "" + } + + return ops +} + +func (t *test) asmCheck(outStr string, fn string, env buildEnv, fullops map[string][]wantedAsmOpcode) (err error) { + // The assembly output contains the concatenated dump of multiple functions. + // the first line of each function begins at column 0, while the rest is + // indented by a tabulation. These data structures help us index the + // output by function. + functionMarkers := make([]int, 1) + lineFuncMap := make(map[string]int) + + lines := strings.Split(outStr, "\n") + rxLine := regexp.MustCompile(fmt.Sprintf(`\((%s:\d+)\)\s+(.*)`, regexp.QuoteMeta(fn))) + + for nl, line := range lines { + // Check if this line begins a function + if len(line) > 0 && line[0] != '\t' { + functionMarkers = append(functionMarkers, nl) + } + + // Search if this line contains a assembly opcode (which is prefixed by the + // original source file/line in parenthesis) + matches := rxLine.FindStringSubmatch(line) + if len(matches) == 0 { + continue + } + srcFileLine, asm := matches[1], matches[2] + + // Associate the original file/line information to the current + // function in the output; it will be useful to dump it in case + // of error. + lineFuncMap[srcFileLine] = len(functionMarkers) - 1 + + // If there are opcode checks associated to this source file/line, + // run the checks. + if ops, found := fullops[srcFileLine]; found { + for i := range ops { + if !ops[i].found && ops[i].opcode.FindString(asm) != "" { + ops[i].found = true + } + } + } + } + functionMarkers = append(functionMarkers, len(lines)) + + var failed []wantedAsmOpcode + for _, ops := range fullops { + for _, o := range ops { + // There's a failure if a negative match was found, + // or a positive match was not found. + if o.negative == o.found { + failed = append(failed, o) + } + } + } + if len(failed) == 0 { + return + } + + // At least one asmcheck failed; report them + sort.Slice(failed, func(i, j int) bool { + return failed[i].line < failed[j].line + }) + + lastFunction := -1 + var errbuf bytes.Buffer + fmt.Fprintln(&errbuf) + for _, o := range failed { + // Dump the function in which this opcode check was supposed to + // pass but failed. + funcIdx := lineFuncMap[o.fileline] + if funcIdx != 0 && funcIdx != lastFunction { + funcLines := lines[functionMarkers[funcIdx]:functionMarkers[funcIdx+1]] + log.Println(strings.Join(funcLines, "\n")) + lastFunction = funcIdx // avoid printing same function twice + } + + if o.negative { + fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %q\n", t.goFileName(), o.line, env, o.opcode.String()) + } else { + fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %q\n", t.goFileName(), o.line, env, o.opcode.String()) + } + } + err = errors.New(errbuf.String()) + return } // defaultRunOutputLimit returns the number of runoutput tests that @@ -886,7 +1762,7 @@ func checkShouldTest() { // Build tags separated by a space are OR-ed together. assertNot(shouldTest("// +build arm 386", "linux", "amd64")) - // Build tags seperated by a comma are AND-ed together. + // Build tags separated by a comma are AND-ed together. assertNot(shouldTest("// +build !windows,!plan9", "windows", "amd64")) assertNot(shouldTest("// +build !windows,!plan9", "plan9", "386")) @@ -898,19 +1774,75 @@ func checkShouldTest() { assert(shouldTest("// +build !windows !plan9", "windows", "amd64")) } -// envForDir returns a copy of the environment -// suitable for running in the given directory. -// The environment is the current process's environment -// but with an updated $PWD, so that an os.Getwd in the -// child will be faster. -func envForDir(dir string) []string { - env := os.Environ() - for i, kv := range env { - if strings.HasPrefix(kv, "PWD=") { - env[i] = "PWD=" + dir - return env - } +func getenv(key, def string) string { + value := os.Getenv(key) + if value != "" { + return value } - env = append(env, "PWD="+dir) - return env + return def +} + +// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added. +func overlayDir(dstRoot, srcRoot string) error { + dstRoot = filepath.Clean(dstRoot) + if err := os.MkdirAll(dstRoot, 0777); err != nil { + return err + } + + srcRoot, err := filepath.Abs(srcRoot) + if err != nil { + return err + } + + return filepath.WalkDir(srcRoot, func(srcPath string, d fs.DirEntry, err error) error { + if err != nil || srcPath == srcRoot { + return err + } + + suffix := strings.TrimPrefix(srcPath, srcRoot) + for len(suffix) > 0 && suffix[0] == filepath.Separator { + suffix = suffix[1:] + } + dstPath := filepath.Join(dstRoot, suffix) + + var info fs.FileInfo + if d.Type()&os.ModeSymlink != 0 { + info, err = os.Stat(srcPath) + } else { + info, err = d.Info() + } + if err != nil { + return err + } + perm := info.Mode() & os.ModePerm + + // Always copy directories (don't symlink them). + // If we add a file in the overlay, we don't want to add it in the original. + if info.IsDir() { + return os.MkdirAll(dstPath, perm|0200) + } + + // If the OS supports symlinks, use them instead of copying bytes. + if err := os.Symlink(srcPath, dstPath); err == nil { + return nil + } + + // Otherwise, copy the bytes. + src, err := os.Open(srcPath) + if err != nil { + return err + } + defer src.Close() + + dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm) + if err != nil { + return err + } + + _, err = io.Copy(dst, src) + if closeErr := dst.Close(); err == nil { + err = closeErr + } + return err + }) } diff --git a/gcc/testsuite/go.test/test/rune.go b/gcc/testsuite/go.test/test/rune.go index c013c471d32..73a5aa23f82 100644 --- a/gcc/testsuite/go.test/test/rune.go +++ b/gcc/testsuite/go.test/test/rune.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/runtime.go b/gcc/testsuite/go.test/test/runtime.go index 89f59e3edb1..bccc9b53afc 100644 --- a/gcc/testsuite/go.test/test/runtime.go +++ b/gcc/testsuite/go.test/test/runtime.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 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. diff --git a/gcc/testsuite/go.test/test/safe/main.go b/gcc/testsuite/go.test/test/safe/main.go deleted file mode 100644 index d173ed92663..00000000000 --- a/gcc/testsuite/go.test/test/safe/main.go +++ /dev/null @@ -1,14 +0,0 @@ -// true - -// 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 main - -// can't use local path with -u, use -I. instead -import "pkg" // ERROR "import unsafe package" - -func main() { - print(pkg.Float32bits(1.0)) -} diff --git a/gcc/testsuite/go.test/test/safe/nousesafe.go b/gcc/testsuite/go.test/test/safe/nousesafe.go deleted file mode 100644 index fcd25af3154..00000000000 --- a/gcc/testsuite/go.test/test/safe/nousesafe.go +++ /dev/null @@ -1,8 +0,0 @@ -// $G $D/pkg.go && pack grc pkg.a pkg.$A 2> /dev/null && rm pkg.$A && errchk $G -I . -u $D/main.go -// rm -f pkg.a - -// 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 ignored diff --git a/gcc/testsuite/go.test/test/safe/pkg.go b/gcc/testsuite/go.test/test/safe/pkg.go deleted file mode 100644 index bebc43a214c..00000000000 --- a/gcc/testsuite/go.test/test/safe/pkg.go +++ /dev/null @@ -1,16 +0,0 @@ -// true - -// 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. - -// a package that uses unsafe on the inside but not in it's api - -package pkg - -import "unsafe" - -// this should be inlinable -func Float32bits(f float32) uint32 { - return *(*uint32)(unsafe.Pointer(&f)) -} \ No newline at end of file diff --git a/gcc/testsuite/go.test/test/safe/usesafe.go b/gcc/testsuite/go.test/test/safe/usesafe.go deleted file mode 100644 index 5d0829e290b..00000000000 --- a/gcc/testsuite/go.test/test/safe/usesafe.go +++ /dev/null @@ -1,8 +0,0 @@ -// $G $D/pkg.go && pack grcS pkg.a pkg.$A 2> /dev/null && rm pkg.$A && $G -I . -u $D/main.go -// rm -f pkg.a - -// 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 ignored diff --git a/gcc/testsuite/go.test/test/shift2.go b/gcc/testsuite/go.test/test/shift2.go index 80e6bbc190d..adbfb773073 100644 --- a/gcc/testsuite/go.test/test/shift2.go +++ b/gcc/testsuite/go.test/test/shift2.go @@ -1,6 +1,6 @@ // compile -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/sigchld.go b/gcc/testsuite/go.test/test/sigchld.go index a60d28deaab..3b496064091 100644 --- a/gcc/testsuite/go.test/test/sigchld.go +++ b/gcc/testsuite/go.test/test/sigchld.go @@ -1,5 +1,5 @@ -// +build !windows -// cmpout +// +build !plan9,!windows +// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/gcc/testsuite/go.test/test/sinit.go b/gcc/testsuite/go.test/test/sinit.go index 5e50e1100a8..df4d50d3676 100644 --- a/gcc/testsuite/go.test/test/sinit.go +++ b/gcc/testsuite/go.test/test/sinit.go @@ -1,17 +1,17 @@ -// $G -S $D/$F.go | egrep initdone >/dev/null && echo BUG sinit || true +// skip -// NOTE: This test is not run by 'run.go' and so not run by all.bash. -// To run this test you must use the ./run shell script. - -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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 that many initializations can be done at link time and // generate no executable init functions. +// This test is run by sinit_run.go. package p +import "unsafe" + // Should be no init func in the assembly. // All these initializations should be done at link time. @@ -43,15 +43,12 @@ var c = []int{1201, 1202, 1203} var aa = [3][3]int{[3]int{2001, 2002, 2003}, [3]int{2004, 2005, 2006}, [3]int{2007, 2008, 2009}} var as = [3]S{S{2101, 2102, 2103}, S{2104, 2105, 2106}, S{2107, 2108, 2109}} -var ac = [3][]int{[]int{2201, 2202, 2203}, []int{2204, 2205, 2206}, []int{2207, 2208, 2209}} var sa = SA{[3]int{3001, 3002, 3003}, [3]int{3004, 3005, 3006}, [3]int{3007, 3008, 3009}} var ss = SS{S{3101, 3102, 3103}, S{3104, 3105, 3106}, S{3107, 3108, 3109}} -var sc = SC{[]int{3201, 3202, 3203}, []int{3204, 3205, 3206}, []int{3207, 3208, 3209}} var ca = [][3]int{[3]int{4001, 4002, 4003}, [3]int{4004, 4005, 4006}, [3]int{4007, 4008, 4009}} var cs = []S{S{4101, 4102, 4103}, S{4104, 4105, 4106}, S{4107, 4108, 4109}} -var cc = [][]int{[]int{4201, 4202, 4203}, []int{4204, 4205, 4206}, []int{4207, 4208, 4209}} var answers = [...]int{ // s @@ -106,20 +103,27 @@ var answers = [...]int{ } var ( - copy_zero = zero - copy_one = one - copy_pi = pi - copy_slice = slice + copy_zero = zero + copy_one = one + copy_pi = pi + copy_slice = slice copy_sliceInt = sliceInt - copy_hello = hello - copy_bytes = bytes + copy_hello = hello + + // Could be handled without an initialization function, but + // requires special handling for "a = []byte("..."); b = a" + // which is not a likely case. + // copy_bytes = bytes + // https://codereview.appspot.com/171840043 is one approach to + // make this special case work. + copy_four, copy_five = four, five - copy_x, copy_y = x, y - copy_nilslice = nilslice - copy_nilmap = nilmap - copy_nilfunc = nilfunc - copy_nilchan = nilchan - copy_nilptr = nilptr + copy_x, copy_y = x, y + copy_nilslice = nilslice + copy_nilmap = nilmap + copy_nilfunc = nilfunc + copy_nilchan = nilchan + copy_nilptr = nilptr ) var copy_a = a @@ -128,15 +132,12 @@ var copy_c = c var copy_aa = aa var copy_as = as -var copy_ac = ac var copy_sa = sa var copy_ss = ss -var copy_sc = sc var copy_ca = ca var copy_cs = cs -var copy_cc = cc var copy_answers = answers @@ -172,7 +173,7 @@ var sx []int var s0 = []int{0, 0, 0} var s1 = []int{1, 2, 3} -func fi() int +func fi() int { return 1 } var ax [10]int var a0 = [10]int{0, 0, 0} @@ -202,58 +203,66 @@ var pt0b = &T{X: 0} var pt1 = &T{X: 1, Y: 2} var pt1a = &T{3, 4} -var copy_bx = bx +// The checks similar to +// var copy_bx = bx +// are commented out. The compiler no longer statically initializes them. +// See issue 7665 and https://codereview.appspot.com/93200044. +// If https://codereview.appspot.com/169040043 is submitted, and this +// test is changed to pass -complete to the compiler, then we can +// uncomment the copy lines again. + +// var copy_bx = bx var copy_b0 = b0 var copy_b1 = b1 -var copy_fx = fx +// var copy_fx = fx var copy_f0 = f0 var copy_f1 = f1 -var copy_gx = gx +// var copy_gx = gx var copy_g0 = g0 var copy_g1 = g1 -var copy_ix = ix +// var copy_ix = ix var copy_i0 = i0 var copy_i1 = i1 -var copy_jx = jx +// var copy_jx = jx var copy_j0 = j0 var copy_j1 = j1 -var copy_cx = cx +// var copy_cx = cx var copy_c0 = c0 var copy_c1 = c1 -var copy_dx = dx +// var copy_dx = dx var copy_d0 = d0 var copy_d1 = d1 -var copy_sx = sx +// var copy_sx = sx var copy_s0 = s0 var copy_s1 = s1 -var copy_ax = ax +// var copy_ax = ax var copy_a0 = a0 var copy_a1 = a1 -var copy_tx = tx +// var copy_tx = tx var copy_t0 = t0 var copy_t0a = t0a var copy_t0b = t0b var copy_t1 = t1 var copy_t1a = t1a -var copy_psx = psx +// var copy_psx = psx var copy_ps0 = ps0 var copy_ps1 = ps1 -var copy_pax = pax +// var copy_pax = pax var copy_pa0 = pa0 var copy_pa1 = pa1 -var copy_ptx = ptx +// var copy_ptx = ptx var copy_pt0 = pt0 var copy_pt0a = pt0a var copy_pt0b = pt0b @@ -266,6 +275,11 @@ type T1 int func (t *T1) M() {} -type Mer interface { M() } +type Mer interface { + M() +} var _ Mer = (*T1)(nil) + +var Byte byte +var PtrByte unsafe.Pointer = unsafe.Pointer(&Byte) diff --git a/gcc/testsuite/go.test/test/sizeof.go b/gcc/testsuite/go.test/test/sizeof.go index c3db1e5c3ae..3e2689fda70 100644 --- a/gcc/testsuite/go.test/test/sizeof.go +++ b/gcc/testsuite/go.test/test/sizeof.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/slice3err.go b/gcc/testsuite/go.test/test/slice3err.go index 83fb39be4c1..1309fdd56bd 100644 --- a/gcc/testsuite/go.test/test/slice3err.go +++ b/gcc/testsuite/go.test/test/slice3err.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/stress/maps.go b/gcc/testsuite/go.test/test/stress/maps.go index d022e19ade0..8ada23a9806 100644 --- a/gcc/testsuite/go.test/test/stress/maps.go +++ b/gcc/testsuite/go.test/test/stress/maps.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. @@ -97,6 +97,8 @@ func (m intMap) Len() int { return len(m) } func (m intMap) RangeAll() { for _ = range m { } + for range m { + } } func stressMaps() { diff --git a/gcc/testsuite/go.test/test/stress/parsego.go b/gcc/testsuite/go.test/test/stress/parsego.go index a781f19937b..98c4d9ad1bc 100644 --- a/gcc/testsuite/go.test/test/stress/parsego.go +++ b/gcc/testsuite/go.test/test/stress/parsego.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. @@ -64,7 +64,7 @@ func parseDir(dirpath string) map[string]*ast.Package { } func stressParseGo() { - pkgroot := runtime.GOROOT() + "/src/pkg/" + pkgroot := runtime.GOROOT() + "/src/" for { m := make(map[string]map[string]*ast.Package) for _, pkg := range packages { diff --git a/gcc/testsuite/go.test/test/stress/runstress.go b/gcc/testsuite/go.test/test/stress/runstress.go index 76ab2a8b4fa..3f16fc9fb3f 100644 --- a/gcc/testsuite/go.test/test/stress/runstress.go +++ b/gcc/testsuite/go.test/test/stress/runstress.go @@ -1,4 +1,4 @@ -// Copyright 2013 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/struct0.go b/gcc/testsuite/go.test/test/struct0.go index e29eb30f544..403e977ac91 100644 --- a/gcc/testsuite/go.test/test/struct0.go +++ b/gcc/testsuite/go.test/test/struct0.go @@ -1,6 +1,6 @@ // run -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/syntax/chan.go b/gcc/testsuite/go.test/test/syntax/chan.go index 3b68bda35f5..6f9d77df909 100644 --- a/gcc/testsuite/go.test/test/syntax/chan.go +++ b/gcc/testsuite/go.test/test/syntax/chan.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -8,10 +8,10 @@ package main type xyz struct { ch chan -} // ERROR "unexpected .*}.* in channel type" +} // ERROR "unexpected .*}.* in channel type|missing channel element type" -func Foo(y chan) { // ERROR "unexpected .*\).* in channel type" +func Foo(y chan) { // ERROR "unexpected .*\).* in channel type|missing channel element type" } -func Bar(x chan, y int) { // ERROR "unexpected comma in channel type" +func Bar(x chan, y int) { // ERROR "unexpected comma in channel type|missing channel element type" } diff --git a/gcc/testsuite/go.test/test/syntax/chan1.go b/gcc/testsuite/go.test/test/syntax/chan1.go index 4860422ad87..88a5b4777b8 100644 --- a/gcc/testsuite/go.test/test/syntax/chan1.go +++ b/gcc/testsuite/go.test/test/syntax/chan1.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -10,8 +10,8 @@ var c chan int var v int func main() { - if c <- v { // ERROR "used as value" + if c <- v { // ERROR "cannot use c <- v as value|send statement used as value" } } -var _ = c <- v // ERROR "used as value" +var _ = c <- v // ERROR "unexpected <-|send statement used as value" diff --git a/gcc/testsuite/go.test/test/syntax/composite.go b/gcc/testsuite/go.test/test/syntax/composite.go index 6565334935b..f891931b6c9 100644 --- a/gcc/testsuite/go.test/test/syntax/composite.go +++ b/gcc/testsuite/go.test/test/syntax/composite.go @@ -1,11 +1,11 @@ // errorcheck -// Copyright 2012 The Go Authors. All rights reserved. +// 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 main var a = []int{ - 3 // ERROR "need trailing comma before newline in composite literal" + 3 // ERROR "need trailing comma before newline in composite literal|expecting comma or }" } diff --git a/gcc/testsuite/go.test/test/syntax/else.go b/gcc/testsuite/go.test/test/syntax/else.go index e985a9c09c7..95373290715 100644 --- a/gcc/testsuite/go.test/test/syntax/else.go +++ b/gcc/testsuite/go.test/test/syntax/else.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/syntax/forvar.go b/gcc/testsuite/go.test/test/syntax/forvar.go deleted file mode 100644 index dc592d2b641..00000000000 --- a/gcc/testsuite/go.test/test/syntax/forvar.go +++ /dev/null @@ -1,10 +0,0 @@ -// errorcheck - -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -func main() { - for var x = 0; x < 10; x++ { // ERROR "var declaration not allowed in for initializer" diff --git a/gcc/testsuite/go.test/test/syntax/if.go b/gcc/testsuite/go.test/test/syntax/if.go index b2a65f9a593..c208a9f1360 100644 --- a/gcc/testsuite/go.test/test/syntax/if.go +++ b/gcc/testsuite/go.test/test/syntax/if.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. diff --git a/gcc/testsuite/go.test/test/syntax/import.go b/gcc/testsuite/go.test/test/syntax/import.go index f0a79212626..8010beddf87 100644 --- a/gcc/testsuite/go.test/test/syntax/import.go +++ b/gcc/testsuite/go.test/test/syntax/import.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/interface.go b/gcc/testsuite/go.test/test/syntax/interface.go index 0b76b5416fb..010d3ce5783 100644 --- a/gcc/testsuite/go.test/test/syntax/interface.go +++ b/gcc/testsuite/go.test/test/syntax/interface.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/semi2.go b/gcc/testsuite/go.test/test/syntax/semi2.go index 23d7bd0ee88..921678999a1 100644 --- a/gcc/testsuite/go.test/test/syntax/semi2.go +++ b/gcc/testsuite/go.test/test/syntax/semi2.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/semi5.go b/gcc/testsuite/go.test/test/syntax/semi5.go index cf690f08406..c54a994d9f0 100644 --- a/gcc/testsuite/go.test/test/syntax/semi5.go +++ b/gcc/testsuite/go.test/test/syntax/semi5.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/semi7.go b/gcc/testsuite/go.test/test/syntax/semi7.go index 6c9ade8bc2b..a1948b0f7d3 100644 --- a/gcc/testsuite/go.test/test/syntax/semi7.go +++ b/gcc/testsuite/go.test/test/syntax/semi7.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. @@ -8,7 +8,7 @@ package main func main() { if x { } // GCCGO_ERROR "undefined" - else { } // ERROR "unexpected semicolon or newline before .?else.?" + else { } // ERROR "unexpected semicolon or newline before .?else.?|unexpected else" } diff --git a/gcc/testsuite/go.test/test/syntax/topexpr.go b/gcc/testsuite/go.test/test/syntax/topexpr.go index c5958f5dd2c..be080d20e53 100644 --- a/gcc/testsuite/go.test/test/syntax/topexpr.go +++ b/gcc/testsuite/go.test/test/syntax/topexpr.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/typesw.go b/gcc/testsuite/go.test/test/syntax/typesw.go index cd8cf35236a..37819339789 100644 --- a/gcc/testsuite/go.test/test/syntax/typesw.go +++ b/gcc/testsuite/go.test/test/syntax/typesw.go @@ -1,13 +1,13 @@ // errorcheck -// Copyright 2011 The Go Authors. All rights reserved. +// 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. package main func main() { - switch main() := interface{}(nil).(type) { // ERROR "invalid variable name" + switch main() := interface{}(nil).(type) { // ERROR "invalid variable name|cannot use .* as value" default: } } diff --git a/gcc/testsuite/go.test/test/syntax/vareq.go b/gcc/testsuite/go.test/test/syntax/vareq.go index f08955e91bc..0d4bb78b8fb 100644 --- a/gcc/testsuite/go.test/test/syntax/vareq.go +++ b/gcc/testsuite/go.test/test/syntax/vareq.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/syntax/vareq1.go b/gcc/testsuite/go.test/test/syntax/vareq1.go index e900eabebec..a2f9f34d33c 100644 --- a/gcc/testsuite/go.test/test/syntax/vareq1.go +++ b/gcc/testsuite/go.test/test/syntax/vareq1.go @@ -1,10 +1,10 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main -var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|expected ';' or newline after top level declaration" +var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|unexpected { after top level declaration|expected ';' or newline after top level declaration" diff --git a/gcc/testsuite/go.test/test/testlib b/gcc/testsuite/go.test/test/testlib deleted file mode 100644 index 4a17f4feb9c..00000000000 --- a/gcc/testsuite/go.test/test/testlib +++ /dev/null @@ -1,170 +0,0 @@ -# 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. - -# These function names are also known to -# (and are the plan for transitioning to) run.go. - -# helper (not known to run.go) -# group file list by packages and return list of packages -# each package is a comma-separated list of go files. -pkgs() { - pkglist=$(grep -h '^package ' $* | awk '{print $2}' | sort -u) - for p in $pkglist - do - echo $(grep -l "^package $p\$" $*) | tr ' ' , - done | sort -} - -_match() { - case $1 in - *,*) - #echo >&2 "match comma separated $1" - first=$(echo $1 | sed 's/,.*//') - rest=$(echo $1 | sed 's/[^,]*,//') - if _match $first && _match $rest; then - return 0 - fi - return 1 - ;; - '!'*) - #echo >&2 "match negation $1" - neg=$(echo $1 | sed 's/^!//') - if _match $neg; then - return 1 - fi - return 0 - ;; - $GOARCH|$GOOS) - #echo >&2 "match GOARCH or GOOS $1" - return 0 - ;; - esac - return 1 -} - -# +build aborts execution if the supplied tags don't match, -# i.e. none of the tags (x or !x) matches GOARCH or GOOS. -+build() { - if (( $# == 0 )); then - return - fi - m=0 - for tag; do - if _match $tag; then - m=1 - fi - done - if [ $m = 0 ]; then - #echo >&2 no match - exit 0 - fi - unset m -} - -compile() { - $G $D/$F.go -} - -compiledir() { - for pkg in $(pkgs $D/$F.dir/*.go) - do - $G -I . $(echo $pkg | tr , ' ') || return 1 - done -} - -errorcheckdir() { - lastzero="" - if [ "$1" = "-0" ]; then - lastzero="-0" - fi - pkgs=$(pkgs $D/$F.dir/*.go) - for pkg in $pkgs.last - do - zero="-0" - case $pkg in - *.last) - pkg=$(echo $pkg |sed 's/\.last$//') - zero=$lastzero - esac - errchk $zero $G -D . -I . -e $(echo $pkg | tr , ' ') - done -} - -rundir() { - lastfile="" - for pkg in $(pkgs $D/$F.dir/*.go) - do - name=$(echo $pkg | sed 's/\.go.*//; s/.*\///') - $G -D . -I . -e $(echo $pkg | tr , ' ') || return 1 - lastfile=$name - done - $L -o $A.out -L . $lastfile.$A - ./$A.out -} - -rundircmpout() { - lastfile="" - for pkg in $(pkgs $D/$F.dir/*.go) - do - name=$(echo $pkg | sed 's/\.go.*//; s/.*\///') - $G -D . -I . -e $(echo $pkg | tr , ' ') || return 1 - lastfile=$name - done - $L -o $A.out -L . $lastfile.$A - ./$A.out 2>&1 | cmp - $D/$F.out -} - -build() { - $G $D/$F.go && $L $F.$A -} - -runoutput() { - go run "$D/$F.go" "$@" > tmp.go - go run tmp.go -} - -run() { - gofiles="" - ingo=true - while $ingo; do - case "$1" in - *.go) - gofiles="$gofiles $1" - shift - ;; - *) - ingo=false - ;; - esac - done - - $G $D/$F.go $gofiles && $L $F.$A && ./$A.out "$@" -} - -cmpout() { - $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out -} - -errorcheck() { - zero="" - if [ "$1" = "-0" ]; then - zero="-0" - shift - fi - errchk $zero $G -e $* $D/$F.go -} - -errorcheckoutput() { - zero="" - if [ "$1" = "-0" ]; then - zero="-0" - shift - fi - go run "$D/$F.go" "$@" > tmp.go - errchk $zero $G -e tmp.go -} - -skip() { - true -} diff --git a/gcc/testsuite/go.test/test/torture.go b/gcc/testsuite/go.test/test/torture.go index bbf6d347d99..197b481e66d 100644 --- a/gcc/testsuite/go.test/test/torture.go +++ b/gcc/testsuite/go.test/test/torture.go @@ -337,3 +337,10 @@ func ChainDivConst(a int) int { func ChainMulBytes(a, b, c byte) byte { return a*(a*(a*(a*(a*(a*(a*(a*(a*b+c)+c)+c)+c)+c)+c)+c)+c) + c } + +func ChainCap() { + select { + case <-make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int))))))))): + default: + } +} diff --git a/gcc/testsuite/go.test/test/typecheck.go b/gcc/testsuite/go.test/test/typecheck.go index a2ad91ff4c3..4c55d2edcb5 100644 --- a/gcc/testsuite/go.test/test/typecheck.go +++ b/gcc/testsuite/go.test/test/typecheck.go @@ -1,5 +1,9 @@ // errorcheck +// 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. + // Verify that the Go compiler will not // die after running into an undefined // type in the argument list for a @@ -8,11 +12,11 @@ package main -func mine(int b) int { // ERROR "undefined.*b" - return b + 2 // ERROR "undefined.*b" +func mine(int b) int { // ERROR "undefined.*b" + return b + 2 // ERROR "undefined.*b" } func main() { - mine() // GCCGO_ERROR "not enough arguments" - c = mine() // ERROR "undefined.*c|not enough arguments" "cannot assign to c" + mine() // GCCGO_ERROR "not enough arguments" + c = mine() // ERROR "undefined.*c|not enough arguments" } diff --git a/gcc/testsuite/go.test/test/typeswitch3.go b/gcc/testsuite/go.test/test/typeswitch3.go index 287e32e71e1..13881875667 100644 --- a/gcc/testsuite/go.test/test/typeswitch3.go +++ b/gcc/testsuite/go.test/test/typeswitch3.go @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Verify that erroneous type switches are caught be the compiler. +// Verify that erroneous type switches are caught by the compiler. // Issue 2700, among other things. // Does not compile. @@ -18,26 +18,39 @@ type I interface { M() } -func main(){ +func main() { var x I switch x.(type) { - case string: // ERROR "impossible" + case string: // ERROR "impossible" println("FAIL") } - + // Issue 2700: if the case type is an interface, nothing is impossible - + var r io.Reader - + _, _ = r.(io.Writer) - + switch r.(type) { case io.Writer: } - + // Issue 2827. - switch _ := r.(type) { // ERROR "invalid variable name _|no new variables" + switch _ := r.(type) { // ERROR "invalid variable name _|no new variables" } } +func noninterface() { + var i int + switch i.(type) { // ERROR "cannot type switch on non-interface value" + case string: + case int: + } + type S struct { + name string + } + var s S + switch s.(type) { // ERROR "cannot type switch on non-interface value" + } +} diff --git a/gcc/testsuite/go.test/test/undef.go b/gcc/testsuite/go.test/test/undef.go index 0a77e59370b..61524f3d4c3 100644 --- a/gcc/testsuite/go.test/test/undef.go +++ b/gcc/testsuite/go.test/test/undef.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/varerr.go b/gcc/testsuite/go.test/test/varerr.go index 22aa9324f98..82ab814197d 100644 --- a/gcc/testsuite/go.test/test/varerr.go +++ b/gcc/testsuite/go.test/test/varerr.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 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. diff --git a/gcc/testsuite/go.test/test/zerodivide.go b/gcc/testsuite/go.test/test/zerodivide.go index 9ab27135359..214d4811644 100644 --- a/gcc/testsuite/go.test/test/zerodivide.go +++ b/gcc/testsuite/go.test/test/zerodivide.go @@ -28,6 +28,8 @@ var ( i32, j32, k32 int32 = 0, 0, 1 i64, j64, k64 int64 = 0, 0, 1 + bb = []int16{2, 0} + u, v, w uint = 0, 0, 1 u8, v8, w8 uint8 = 0, 0, 1 u16, v16, w16 uint16 = 0, 0, 1 @@ -124,6 +126,10 @@ var errorTests = []ErrorTest{ ErrorTest{"int32 1/0", func() { use(k32 / j32) }, "divide"}, ErrorTest{"int64 1/0", func() { use(k64 / j64) }, "divide"}, + // From issue 5790, we should ensure that _ assignments + // still evaluate and generate zerodivide panics. + ErrorTest{"int16 _ = bb[0]/bb[1]", func() { _ = bb[0] / bb[1] }, "divide"}, + ErrorTest{"uint 0/0", func() { use(u / v) }, "divide"}, ErrorTest{"uint8 0/0", func() { use(u8 / v8) }, "divide"}, ErrorTest{"uint16 0/0", func() { use(u16 / v16) }, "divide"}, @@ -195,9 +201,6 @@ func alike(a, b float64) bool { func main() { bad := false for _, t := range errorTests { - if t.err != "" { - continue - } err := error_(t.fn) switch { case t.err == "" && err == "":