From: Ian Lance Taylor Date: Tue, 29 Mar 2011 20:29:24 +0000 (+0000) Subject: Update to current master Go testsuite. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8915876911d0ccd86ef397a49779e7352f0563f5;p=gcc.git Update to current master Go testsuite. From-SVN: r171695 --- diff --git a/gcc/testsuite/go.test/test/append.go b/gcc/testsuite/go.test/test/append.go new file mode 100644 index 00000000000..96421c36b89 --- /dev/null +++ b/gcc/testsuite/go.test/test/append.go @@ -0,0 +1,227 @@ +// $G $F.go && $L $F.$A && ./$A.out + +// 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. + +// Semi-exhaustive test for append() + +package main + +import ( + "fmt" + "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) + } + verifyStruct() + verifyInterface() +} + + +var tests = []struct { + name string + result, expected interface{} +}{ + {"bool a", append([]bool{}), []bool{}}, + {"bool b", append([]bool{}, true), []bool{true}}, + {"bool c", append([]bool{}, true, false, true, true), []bool{true, false, true, true}}, + + {"bool d", append([]bool{true, false, true}), []bool{true, false, true}}, + {"bool e", append([]bool{true, false, true}, false), []bool{true, false, true, false}}, + {"bool f", append([]bool{true, false, true}, false, false, false), []bool{true, false, true, false, false, false}}, + + {"bool g", append([]bool{}, []bool{true}...), []bool{true}}, + {"bool h", append([]bool{}, []bool{true, false, true, false}...), []bool{true, false, true, false}}, + + {"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}}, + + {"byte d", append([]byte{0, 1, 2}), []byte{0, 1, 2}}, + {"byte e", append([]byte{0, 1, 2}, 3), []byte{0, 1, 2, 3}}, + {"byte f", append([]byte{0, 1, 2}, 3, 4, 5), []byte{0, 1, 2, 3, 4, 5}}, + + {"byte g", append([]byte{}, []byte{0}...), []byte{0}}, + {"byte h", append([]byte{}, []byte{0, 1, 2, 3}...), []byte{0, 1, 2, 3}}, + + {"byte i", append([]byte{0, 1, 2}, []byte{3}...), []byte{0, 1, 2, 3}}, + {"byte j", append([]byte{0, 1, 2}, []byte{3, 4, 5}...), []byte{0, 1, 2, 3, 4, 5}}, + + + {"int16 a", append([]int16{}), []int16{}}, + {"int16 b", append([]int16{}, 0), []int16{0}}, + {"int16 c", append([]int16{}, 0, 1, 2, 3), []int16{0, 1, 2, 3}}, + + {"int16 d", append([]int16{0, 1, 2}), []int16{0, 1, 2}}, + {"int16 e", append([]int16{0, 1, 2}, 3), []int16{0, 1, 2, 3}}, + {"int16 f", append([]int16{0, 1, 2}, 3, 4, 5), []int16{0, 1, 2, 3, 4, 5}}, + + {"int16 g", append([]int16{}, []int16{0}...), []int16{0}}, + {"int16 h", append([]int16{}, []int16{0, 1, 2, 3}...), []int16{0, 1, 2, 3}}, + + {"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}}, + + {"uint32 d", append([]uint32{0, 1, 2}), []uint32{0, 1, 2}}, + {"uint32 e", append([]uint32{0, 1, 2}, 3), []uint32{0, 1, 2, 3}}, + {"uint32 f", append([]uint32{0, 1, 2}, 3, 4, 5), []uint32{0, 1, 2, 3, 4, 5}}, + + {"uint32 g", append([]uint32{}, []uint32{0}...), []uint32{0}}, + {"uint32 h", append([]uint32{}, []uint32{0, 1, 2, 3}...), []uint32{0, 1, 2, 3}}, + + {"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}}, + + {"float64 d", append([]float64{0, 1, 2}), []float64{0, 1, 2}}, + {"float64 e", append([]float64{0, 1, 2}, 3), []float64{0, 1, 2, 3}}, + {"float64 f", append([]float64{0, 1, 2}, 3, 4, 5), []float64{0, 1, 2, 3, 4, 5}}, + + {"float64 g", append([]float64{}, []float64{0}...), []float64{0}}, + {"float64 h", append([]float64{}, []float64{0, 1, 2, 3}...), []float64{0, 1, 2, 3}}, + + {"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}}, + + {"complex128 d", append([]complex128{0, 1, 2}), []complex128{0, 1, 2}}, + {"complex128 e", append([]complex128{0, 1, 2}, 3), []complex128{0, 1, 2, 3}}, + {"complex128 f", append([]complex128{0, 1, 2}, 3, 4, 5), []complex128{0, 1, 2, 3, 4, 5}}, + + {"complex128 g", append([]complex128{}, []complex128{0}...), []complex128{0}}, + {"complex128 h", append([]complex128{}, []complex128{0, 1, 2, 3}...), []complex128{0, 1, 2, 3}}, + + {"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"}}, + + {"string d", append([]string{"0", "1", "2"}), []string{"0", "1", "2"}}, + {"string e", append([]string{"0", "1", "2"}, "3"), []string{"0", "1", "2", "3"}}, + {"string f", append([]string{"0", "1", "2"}, "3", "4", "5"), []string{"0", "1", "2", "3", "4", "5"}}, + + {"string g", append([]string{}, []string{"0"}...), []string{"0"}}, + {"string h", append([]string{}, []string{"0", "1", "2", "3"}...), []string{"0", "1", "2", "3"}}, + + {"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"}}, +} + + +func verifyStruct() { + type T struct { + a, b, c string + } + type S []T + e := make(S, 100) + for i := range e { + e[i] = T{"foo", fmt.Sprintf("%d", i), "bar"} + } + + verify("struct a", append(S{}), S{}) + verify("struct b", append(S{}, e[0]), e[0:1]) + verify("struct c", append(S{}, e[0], e[1], e[2]), e[0:3]) + + verify("struct d", append(e[0:1]), e[0:1]) + verify("struct e", append(e[0:1], e[1]), e[0:2]) + verify("struct f", append(e[0:1], e[1], e[2], e[3]), e[0:4]) + + verify("struct g", append(e[0:3]), e[0:3]) + verify("struct h", append(e[0:3], e[3]), e[0:4]) + verify("struct i", append(e[0:3], e[3], e[4], e[5], e[6]), e[0:7]) + + for i := range e { + verify("struct j", append(S{}, e[0:i]...), e[0:i]) + input := make(S, i) + copy(input, e[0:i]) + verify("struct k", append(input, e[i:]...), e) + verify("struct k - input modified", input, e[0:i]) + } + + s := make(S, 10, 20) + r := make(S, len(s)+len(e)) + for i, x := range e { + r[len(s)+i] = x + } + verify("struct l", append(s), s) + verify("struct m", append(s, e...), r) +} + + +func verifyInterface() { + type T interface{} + type S []T + e := make(S, 100) + for i := range e { + switch i % 4 { + case 0: + e[i] = i + case 1: + e[i] = "foo" + case 2: + e[i] = fmt.Sprintf("%d", i) + case 3: + e[i] = float64(i) + } + } + + verify("interface a", append(S{}), S{}) + verify("interface b", append(S{}, e[0]), e[0:1]) + verify("interface c", append(S{}, e[0], e[1], e[2]), e[0:3]) + + verify("interface d", append(e[0:1]), e[0:1]) + verify("interface e", append(e[0:1], e[1]), e[0:2]) + verify("interface f", append(e[0:1], e[1], e[2], e[3]), e[0:4]) + + verify("interface g", append(e[0:3]), e[0:3]) + verify("interface h", append(e[0:3], e[3]), e[0:4]) + verify("interface i", append(e[0:3], e[3], e[4], e[5], e[6]), e[0:7]) + + for i := range e { + verify("interface j", append(S{}, e[0:i]...), e[0:i]) + input := make(S, i) + copy(input, e[0:i]) + verify("interface k", append(input, e[i:]...), e) + verify("interface k - input modified", input, e[0:i]) + } + + s := make(S, 10, 20) + r := make(S, len(s)+len(e)) + for i, x := range e { + r[len(s)+i] = x + } + verify("interface l", append(s), s) + verify("interface m", append(s, e...), r) +} diff --git a/gcc/testsuite/go.test/test/arm-pass.txt b/gcc/testsuite/go.test/test/arm-pass.txt deleted file mode 100644 index 2c7230f100a..00000000000 --- a/gcc/testsuite/go.test/test/arm-pass.txt +++ /dev/null @@ -1,488 +0,0 @@ -./235.go -# ./64bit.go # fail, flaky on android build -./args.go -./assign.go -./assign1.go -./bigalg.go -./bigmap.go -./blank.go -./blank1.go -./chancap.go -./char_lit.go -./char_lit1.go -./closedchan.go -./closure.go -./cmp1.go -./cmp2.go -./cmp3.go -./cmp4.go -./cmp5.go -./cmplx.go -# ./cmplxdivide.go # fail, BUG -./cmplxdivide1.go -./complit.go -./compos.go -./const.go -./const1.go -./const2.go -./const3.go -./convert.go -./convert3.go -./convlit.go -./convlit1.go -./copy.go -./ddd.go -./ddd1.go -./ddd2.go -./ddd3.go -./decl.go -./declbad.go -./defer.go -./deferprint.go -./empty.go -./env.go -./escape.go -./float_lit.go -./floatcmp.go -./for.go -./func.go -./func1.go -./func2.go -./func3.go -./func4.go -./func5.go -./gc.go -./gc1.go -./hashmap.go -./helloworld.go -./if.go -./if1.go -./import.go -./import1.go -./import2.go -./import3.go -./import4.go -./indirect.go -./indirect1.go -./initcomma.go -./initialize.go -./initializerr.go -./initsyscall.go -./int_lit.go -./intcvt.go -./iota.go -./literal.go -./malloc1.go -# ./mallocfin.go # fail -./mallocrand.go -./mallocrep.go -./mallocrep1.go -# ./map.go # fail -./method.go -./method1.go -./method2.go -./method3.go -./named.go -./named1.go -./nil.go -./nul1.go -./parentype.go -./peano.go -./printbig.go -./range.go -./recover.go -./recover1.go -./recover2.go -# ./recover3.go # fail -./rename.go -./rename1.go -./runtime.go -./sieve.go -./sigchld.go -./simassign.go -./sinit.go -./stack.go -./string_lit.go -./stringrange.go -./switch.go -./switch1.go -./test0.go -./turing.go -./typeswitch.go -./typeswitch1.go -./typeswitch2.go -./undef.go -./utf.go -./varerr.go -./varinit.go -./vectors.go -./zerodivide.go -ken/array.go -ken/chan.go -ken/chan1.go -ken/complit.go -# ken/cplx0.go # output fail -# ken/cplx1.go # fail -# ken/cplx2.go # fail -# ken/cplx3.go # output fail -# ken/cplx4.go # fail, BUG -# ken/cplx5.go # output fail -ken/divconst.go -ken/divmod.go -ken/embed.go -ken/for.go -ken/interbasic.go -ken/interfun.go -ken/intervar.go -ken/label.go -ken/litfun.go -ken/mfunc.go -ken/modconst.go -ken/ptrfun.go -ken/ptrvar.go -ken/range.go -ken/rob1.go -ken/rob2.go -ken/robfor.go -ken/robfunc.go -ken/robif.go -ken/shift.go -ken/simparray.go -ken/simpbool.go -ken/simpconv.go -ken/simpfun.go -ken/simpprint.go -ken/simpswitch.go -ken/simpvar.go -ken/slicearray.go -ken/sliceslice.go -ken/string.go -ken/strvar.go -chan/doubleselect.go -chan/fifo.go -chan/goroutines.go -chan/nonblock.go -chan/perm.go -chan/powser1.go -chan/powser2.go -chan/select.go -chan/select2.go -# chan/select3.go # fail -chan/sieve1.go -chan/sieve2.go -interface/bigdata.go -interface/convert.go -interface/convert1.go -interface/convert2.go -interface/embed.go -interface/embed0.go -interface/embed1.go -interface/explicit.go -interface/fail.go -interface/fake.go -interface/pointer.go -interface/receiver.go -interface/receiver1.go -interface/recursive.go -interface/returntype.go -interface/struct.go -nilptr/arrayindex.go -nilptr/arrayindex1.go -nilptr/arraytoslice.go -nilptr/arraytoslice1.go -nilptr/arraytoslice2.go -nilptr/slicearray.go -nilptr/structfield.go -nilptr/structfield1.go -nilptr/structfield2.go -nilptr/structfieldaddr.go -syntax/forvar.go -syntax/import.go -syntax/interface.go -syntax/semi1.go -syntax/semi2.go -syntax/semi3.go -syntax/semi4.go -syntax/semi5.go -syntax/semi6.go -syntax/semi7.go -syntax/slice.go -syntax/topexpr.go -syntax/vareq.go -syntax/vareq1.go -fixedbugs/bug000.go -fixedbugs/bug001.go -fixedbugs/bug002.go -fixedbugs/bug003.go -fixedbugs/bug004.go -fixedbugs/bug005.go -fixedbugs/bug006.go -fixedbugs/bug007.go -fixedbugs/bug008.go -fixedbugs/bug009.go -fixedbugs/bug010.go -fixedbugs/bug011.go -fixedbugs/bug012.go -fixedbugs/bug013.go -fixedbugs/bug014.go -fixedbugs/bug015.go -fixedbugs/bug016.go -fixedbugs/bug017.go -fixedbugs/bug020.go -fixedbugs/bug021.go -fixedbugs/bug022.go -fixedbugs/bug023.go -fixedbugs/bug024.go -fixedbugs/bug026.go -fixedbugs/bug027.go -fixedbugs/bug028.go -fixedbugs/bug030.go -fixedbugs/bug031.go -fixedbugs/bug035.go -fixedbugs/bug036.go -fixedbugs/bug037.go -fixedbugs/bug038.go -fixedbugs/bug039.go -fixedbugs/bug040.go -fixedbugs/bug045.go -fixedbugs/bug046.go -fixedbugs/bug047.go -fixedbugs/bug048.go -fixedbugs/bug049.go -fixedbugs/bug050.go -fixedbugs/bug051.go -fixedbugs/bug052.go -fixedbugs/bug053.go -fixedbugs/bug054.go -fixedbugs/bug055.go -fixedbugs/bug056.go -fixedbugs/bug057.go -fixedbugs/bug058.go -fixedbugs/bug059.go -fixedbugs/bug060.go -fixedbugs/bug061.go -fixedbugs/bug062.go -fixedbugs/bug063.go -fixedbugs/bug064.go -fixedbugs/bug065.go -fixedbugs/bug066.go -fixedbugs/bug067.go -fixedbugs/bug068.go -fixedbugs/bug069.go -fixedbugs/bug070.go -fixedbugs/bug071.go -fixedbugs/bug072.go -fixedbugs/bug073.go -fixedbugs/bug074.go -fixedbugs/bug075.go -fixedbugs/bug076.go -fixedbugs/bug077.go -fixedbugs/bug078.go -fixedbugs/bug080.go -fixedbugs/bug081.go -fixedbugs/bug082.go -fixedbugs/bug083.go -fixedbugs/bug084.go -fixedbugs/bug085.go -fixedbugs/bug086.go -fixedbugs/bug087.go -fixedbugs/bug088.go -fixedbugs/bug089.go -fixedbugs/bug090.go -fixedbugs/bug091.go -fixedbugs/bug092.go -fixedbugs/bug093.go -fixedbugs/bug094.go -fixedbugs/bug096.go -fixedbugs/bug097.go -fixedbugs/bug098.go -fixedbugs/bug099.go -fixedbugs/bug101.go -fixedbugs/bug102.go -fixedbugs/bug103.go -fixedbugs/bug104.go -fixedbugs/bug106.go -fixedbugs/bug107.go -fixedbugs/bug108.go -fixedbugs/bug109.go -fixedbugs/bug110.go -fixedbugs/bug111.go -fixedbugs/bug112.go -fixedbugs/bug113.go -fixedbugs/bug114.go -fixedbugs/bug115.go -fixedbugs/bug116.go -fixedbugs/bug117.go -fixedbugs/bug118.go -fixedbugs/bug119.go -fixedbugs/bug120.go -fixedbugs/bug121.go -fixedbugs/bug122.go -fixedbugs/bug123.go -fixedbugs/bug126.go -fixedbugs/bug127.go -fixedbugs/bug128.go -fixedbugs/bug129.go -fixedbugs/bug130.go -fixedbugs/bug131.go -fixedbugs/bug132.go -fixedbugs/bug133.go -fixedbugs/bug135.go -fixedbugs/bug136.go -fixedbugs/bug137.go -fixedbugs/bug139.go -fixedbugs/bug140.go -fixedbugs/bug141.go -fixedbugs/bug142.go -fixedbugs/bug143.go -fixedbugs/bug144.go -fixedbugs/bug145.go -fixedbugs/bug146.go -fixedbugs/bug147.go -fixedbugs/bug148.go -fixedbugs/bug149.go -fixedbugs/bug150.go -fixedbugs/bug151.go -fixedbugs/bug152.go -fixedbugs/bug154.go -fixedbugs/bug155.go -fixedbugs/bug156.go -fixedbugs/bug157.go -fixedbugs/bug158.go -fixedbugs/bug159.go -fixedbugs/bug160.go -fixedbugs/bug161.go -fixedbugs/bug163.go -fixedbugs/bug164.go -fixedbugs/bug165.go -fixedbugs/bug167.go -fixedbugs/bug168.go -fixedbugs/bug169.go -fixedbugs/bug170.go -fixedbugs/bug171.go -fixedbugs/bug172.go -fixedbugs/bug173.go -fixedbugs/bug174.go -fixedbugs/bug175.go -fixedbugs/bug176.go -fixedbugs/bug177.go -fixedbugs/bug178.go -fixedbugs/bug179.go -fixedbugs/bug180.go -fixedbugs/bug181.go -fixedbugs/bug182.go -fixedbugs/bug183.go -fixedbugs/bug184.go -fixedbugs/bug185.go -fixedbugs/bug186.go -fixedbugs/bug187.go -fixedbugs/bug188.go -fixedbugs/bug189.go -fixedbugs/bug190.go -fixedbugs/bug191.go -fixedbugs/bug192.go -fixedbugs/bug193.go -fixedbugs/bug194.go -fixedbugs/bug195.go -fixedbugs/bug196.go -fixedbugs/bug197.go -fixedbugs/bug198.go -fixedbugs/bug199.go -fixedbugs/bug200.go -fixedbugs/bug201.go -fixedbugs/bug202.go -fixedbugs/bug203.go -fixedbugs/bug204.go -fixedbugs/bug205.go -fixedbugs/bug206.go -fixedbugs/bug207.go -fixedbugs/bug208.go -fixedbugs/bug209.go -fixedbugs/bug211.go -fixedbugs/bug212.go -fixedbugs/bug213.go -fixedbugs/bug214.go -fixedbugs/bug215.go -fixedbugs/bug216.go -fixedbugs/bug217.go -fixedbugs/bug218.go -fixedbugs/bug219.go -fixedbugs/bug220.go -fixedbugs/bug221.go -fixedbugs/bug222.go -fixedbugs/bug223.go -fixedbugs/bug224.go -fixedbugs/bug225.go -fixedbugs/bug226.go -fixedbugs/bug227.go -fixedbugs/bug228.go -fixedbugs/bug229.go -fixedbugs/bug230.go -fixedbugs/bug231.go -fixedbugs/bug232.go -fixedbugs/bug233.go -fixedbugs/bug234.go -fixedbugs/bug235.go -fixedbugs/bug236.go -fixedbugs/bug237.go -fixedbugs/bug238.go -fixedbugs/bug239.go -fixedbugs/bug240.go -fixedbugs/bug241.go -fixedbugs/bug242.go -# fixedbugs/bug243.go # fail, flaky on android build -fixedbugs/bug244.go -fixedbugs/bug245.go -fixedbugs/bug246.go -fixedbugs/bug247.go -fixedbugs/bug248.go -fixedbugs/bug249.go -fixedbugs/bug250.go -fixedbugs/bug251.go -fixedbugs/bug252.go -fixedbugs/bug253.go -fixedbugs/bug254.go -fixedbugs/bug255.go -fixedbugs/bug256.go -fixedbugs/bug257.go -fixedbugs/bug258.go -fixedbugs/bug259.go -fixedbugs/bug261.go -fixedbugs/bug262.go -fixedbugs/bug263.go -fixedbugs/bug264.go -fixedbugs/bug265.go -fixedbugs/bug266.go -fixedbugs/bug267.go -fixedbugs/bug268.go -fixedbugs/bug269.go -fixedbugs/bug270.go -fixedbugs/bug271.go -fixedbugs/bug272.go -fixedbugs/bug273.go -fixedbugs/bug274.go -fixedbugs/bug275.go -fixedbugs/bug276.go -fixedbugs/bug277.go -fixedbugs/bug278.go -fixedbugs/bug279.go -fixedbugs/bug280.go -fixedbugs/bug281.go -fixedbugs/bug282.go -fixedbugs/bug283.go -fixedbugs/bug284.go -fixedbugs/bug285.go -fixedbugs/bug286.go -fixedbugs/bug287.go -fixedbugs/bug288.go -fixedbugs/bug289.go -fixedbugs/bug290.go -fixedbugs/bug291.go -fixedbugs/bug292.go -fixedbugs/bug293.go -fixedbugs/bug294.go -fixedbugs/bug295.go -fixedbugs/bug296.go -fixedbugs/bug297.go -fixedbugs/bug298.go -# bugs/bug260.go # fail, BUG diff --git a/gcc/testsuite/go.test/test/bench/Makefile b/gcc/testsuite/go.test/test/bench/Makefile new file mode 100644 index 00000000000..145fe0cea63 --- /dev/null +++ b/gcc/testsuite/go.test/test/bench/Makefile @@ -0,0 +1,14 @@ +# 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. + +include ../../src/Make.inc + +all: + @echo "make clean or timing" + +timing: + ./timing.sh + +clean: + rm -f [568].out *.[568] diff --git a/gcc/testsuite/go.test/test/bench/clean.bash b/gcc/testsuite/go.test/test/bench/clean.bash deleted file mode 100755 index d56c0e39405..00000000000 --- a/gcc/testsuite/go.test/test/bench/clean.bash +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -OS=568 -rm -f [$OS].out *.[$OS] diff --git a/gcc/testsuite/go.test/test/bench/fannkuch-parallel.go b/gcc/testsuite/go.test/test/bench/fannkuch-parallel.go index 7897eac0524..7e9b98d5051 100644 --- a/gcc/testsuite/go.test/test/bench/fannkuch-parallel.go +++ b/gcc/testsuite/go.test/test/bench/fannkuch-parallel.go @@ -44,7 +44,7 @@ import ( ) var n = flag.Int("n", 7, "count") -var nCPU = flag.Int("ncpu", 2, "number of cpus") +var nCPU = flag.Int("ncpu", 4, "number of cpus") type Job struct { start []int diff --git a/gcc/testsuite/go.test/test/bench/fasta.c b/gcc/testsuite/go.test/test/bench/fasta.c index 78a8490d710..64c1c520581 100644 --- a/gcc/testsuite/go.test/test/bench/fasta.c +++ b/gcc/testsuite/go.test/test/bench/fasta.c @@ -41,10 +41,12 @@ POSSIBILITY OF SUCH DAMAGE. #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) @@ -214,4 +216,4 @@ main(int argc, const char **argv) { ">THREE Homo sapiens frequency\n", n*5, &rand); return 0; -} \ No newline at end of file +} diff --git a/gcc/testsuite/go.test/test/bench/fasta.go b/gcc/testsuite/go.test/test/bench/fasta.go index 470bdb3285a..d13edd5dcfa 100644 --- a/gcc/testsuite/go.test/test/bench/fasta.go +++ b/gcc/testsuite/go.test/test/bench/fasta.go @@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE. package main import ( - "bytes" "flag" "os" ) @@ -49,7 +48,7 @@ var n = flag.Int("n", 1000, "length of result") const Line = 60 func Repeat(alu []byte, n int) { - buf := bytes.Add(alu, alu) + buf := append(alu, alu...) off := 0 for n > 0 { m := n @@ -138,28 +137,28 @@ func main() { flag.Parse() iub := []Acid{ - Acid{prob: 0.27, sym: 'a'}, - Acid{prob: 0.12, sym: 'c'}, - Acid{prob: 0.12, sym: 'g'}, - Acid{prob: 0.27, sym: 't'}, - Acid{prob: 0.02, sym: 'B'}, - Acid{prob: 0.02, sym: 'D'}, - Acid{prob: 0.02, sym: 'H'}, - Acid{prob: 0.02, sym: 'K'}, - Acid{prob: 0.02, sym: 'M'}, - Acid{prob: 0.02, sym: 'N'}, - Acid{prob: 0.02, sym: 'R'}, - Acid{prob: 0.02, sym: 'S'}, - Acid{prob: 0.02, sym: 'V'}, - Acid{prob: 0.02, sym: 'W'}, - Acid{prob: 0.02, sym: 'Y'}, + {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{ - Acid{prob: 0.3029549426680, sym: 'a'}, - Acid{prob: 0.1979883004921, sym: 'c'}, - Acid{prob: 0.1975473066391, sym: 'g'}, - Acid{prob: 0.3015094502008, sym: 't'}, + {prob: 0.3029549426680, sym: 'a'}, + {prob: 0.1979883004921, sym: 'c'}, + {prob: 0.1975473066391, sym: 'g'}, + {prob: 0.3015094502008, sym: 't'}, } alu := []byte( @@ -192,9 +191,7 @@ func (b *buffer) Flush() { func (b *buffer) WriteString(s string) { p := b.NextWrite(len(s)) - for i := 0; i < len(s); i++ { - p[i] = s[i] - } + copy(p, s) } func (b *buffer) NextWrite(n int) []byte { @@ -204,6 +201,6 @@ func (b *buffer) NextWrite(n int) []byte { p = *b } out := p[len(p) : len(p)+n] - *b = p[0 : len(p)+n] + *b = p[:len(p)+n] return out } diff --git a/gcc/testsuite/go.test/test/bench/k-nucleotide-parallel.go b/gcc/testsuite/go.test/test/bench/k-nucleotide-parallel.go index 0234f33d113..96c80d8f0c8 100644 --- a/gcc/testsuite/go.test/test/bench/k-nucleotide-parallel.go +++ b/gcc/testsuite/go.test/test/bench/k-nucleotide-parallel.go @@ -41,6 +41,7 @@ import ( "fmt" "io/ioutil" "os" + "runtime" "sort" ) @@ -97,6 +98,7 @@ func printKnucs(a kNucArray) { } func main() { + runtime.GOMAXPROCS(4) in := bufio.NewReader(os.Stdin) three := []byte(">THREE ") for { diff --git a/gcc/testsuite/go.test/test/bench/pidigits.go b/gcc/testsuite/go.test/test/bench/pidigits.go index dcfb502ce2a..e59312177f4 100644 --- a/gcc/testsuite/go.test/test/bench/pidigits.go +++ b/gcc/testsuite/go.test/test/bench/pidigits.go @@ -49,6 +49,7 @@ 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) @@ -80,7 +81,6 @@ func extract_digit() int64 { } func next_term(k int64) { - // TODO(eds) If big.Int ever gets a Scale method, y2 and bigk could be int64 y2.SetInt64(k*2 + 1) bigk.SetInt64(k) @@ -92,15 +92,15 @@ func next_term(k int64) { } func eliminate_digit(d int64) { - tmp := big.NewInt(0).Set(denom) - accum.Sub(accum, tmp.Mul(tmp, big.NewInt(d))) + 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) + fmt.Printf(s, arg...) } } diff --git a/gcc/testsuite/go.test/test/bench/timing.log b/gcc/testsuite/go.test/test/bench/timing.log index e7b0b48c11f..a967f27d223 100644 --- a/gcc/testsuite/go.test/test/bench/timing.log +++ b/gcc/testsuite/go.test/test/bench/timing.log @@ -90,7 +90,7 @@ mandelbrot 5500 gc mandelbrot 74.32u 0.00s 74.35r gc_B mandelbrot 74.28u 0.01s 74.31r -meteor 16000 +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 @@ -209,7 +209,7 @@ mandelbrot 16000 gc mandelbrot 64.05u 0.02s 64.08r # *** -14% gc_B mandelbrot 64.10u 0.02s 64.14r # *** -14% -meteor 16000 +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 @@ -307,7 +307,7 @@ mandelbrot 16000 gc mandelbrot 63.31u 0.01s 63.35r # -1% gc_B mandelbrot 63.29u 0.00s 63.31r # -1% -meteor 16000 +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 @@ -414,7 +414,7 @@ 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, 2009 +Jan 6, 2010 # Long-overdue update. All numbers included in this complete run. # Some programs (e.g. reverse-complement) rewritten for speed. @@ -429,7 +429,7 @@ fasta -n 25000000 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 +# 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 @@ -445,7 +445,6 @@ nbody -n 50000000 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 - gccgo -O2 binary-tree-freelist.go 0.00u 0.00s 0.00r gc binary-tree 7.23u 0.01s 7.25r # # -19% gc binary-tree-freelist 0.43u 0.00s 0.44r # -9% @@ -478,7 +477,7 @@ mandelbrot 16000 gc mandelbrot 66.05u 0.00s 66.07r # -3% gc_B mandelbrot 66.06u 0.00s 66.07r # -3% -meteor 16000 +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 @@ -498,3 +497,180 @@ 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 diff --git a/gcc/testsuite/go.test/test/bench/timing.sh b/gcc/testsuite/go.test/test/bench/timing.sh index c52c0af94a6..473c9b312f8 100755 --- a/gcc/testsuite/go.test/test/bench/timing.sh +++ b/gcc/testsuite/go.test/test/bench/timing.sh @@ -8,6 +8,12 @@ set -e eval $(gomake --no-print-directory -f ../../src/Make.inc go-env) PATH=.:$PATH +havegccgo=false +if which gccgo >/dev/null 2>&1 +then + havegccgo=true +fi + mode=run case X"$1" in X-test) @@ -30,8 +36,6 @@ runonly() { fi } - - run() { if [ $mode = test ] then @@ -57,6 +61,10 @@ run() { fi return fi + if ! $havegccgo && echo $1 | grep -q '^gccgo ' + then + return + fi echo -n ' '$1' ' $1 shift @@ -67,7 +75,7 @@ run() { fasta() { runonly echo 'fasta -n 25000000' run 'gcc -O2 fasta.c' a.out 25000000 - #run 'gccgo -O2 fasta.go' a.out -n 25000000 #commented out until WriteString is in bufio + 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 } @@ -85,7 +93,7 @@ revcomp() { nbody() { runonly echo 'nbody -n 50000000' - run 'gcc -O2 nbody.c' a.out 50000000 + run 'gcc -O2 -lm nbody.c' 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 @@ -115,7 +123,8 @@ regexdna() { runonly a.out 100000 > x runonly echo 'regex-dna 100000' run 'gcc -O2 regex-dna.c -lpcre' a.out x # should be using 25000000 runonly echo 'k-nucleotide 1000000' run 'gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0' a.out 1 - status := 0 - var b1 [10]T1 - a0, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[0])[2:], 16) - a1, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[1])[2:], 16) - if a1 != a0 + 1 { - fmt.Println("FAIL") - if report { - fmt.Println("alignment should be 1, is", a1-a0) - } - status = 1 - } - var b2 [10]T2 - a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[0])[2:], 16) - a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[1])[2:], 16) - if a1 != a0 + 2 { - if status == 0 { - fmt.Println("FAIL") - status = 1 - } - if report { - fmt.Println("alignment should be 2, is", a1-a0) - } - } - var b4 [10]T4 - a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[0])[2:], 16) - a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[1])[2:], 16) - if a1 != a0 + 4 { - if status == 0 { - fmt.Println("FAIL") - status = 1 - } - if report { - fmt.Println("alignment should be 4, is", a1-a0) - } - } - os.Exit(status) -} diff --git a/gcc/testsuite/go.test/test/bugs/bug322.dir/lib.go b/gcc/testsuite/go.test/test/bugs/bug322.dir/lib.go new file mode 100644 index 00000000000..0de56d3d649 --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug322.dir/lib.go @@ -0,0 +1,15 @@ +// 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 lib + +type T struct { + x int // non-exported field +} + +func (t T) M() { +} + +func (t *T) PM() { +} diff --git a/gcc/testsuite/go.test/test/bugs/bug322.dir/main.go b/gcc/testsuite/go.test/test/bugs/bug322.dir/main.go new file mode 100644 index 00000000000..0ab5b32e453 --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug322.dir/main.go @@ -0,0 +1,47 @@ +// 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 + +import "./lib" + +type I interface { + M() +} + +type PI interface { + PM() +} + +func main() { + var t lib.T + t.M() + t.PM() + + // This is still an error. + // var i1 I = t + // i1.M() + + // This combination is illegal because + // PM requires a pointer receiver. + // var pi1 PI = t + // pi1.PM() + + var pt = &t + pt.M() + pt.PM() + + var i2 I = pt + i2.M() + + var pi2 PI = pt + pi2.PM() +} + +/* +These should not be errors anymore: + +bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver +bug322.dir/main.go:32: implicit assignment of unexported field 'x' of lib.T in method receiver +*/ diff --git a/gcc/testsuite/go.test/test/bugs/bug322.go b/gcc/testsuite/go.test/test/bugs/bug322.go new file mode 100644 index 00000000000..ad0e62dc8c9 --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug322.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly + +// 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 case for issue 1402. +ignored diff --git a/gcc/testsuite/go.test/test/bugs/bug324.dir/main.go b/gcc/testsuite/go.test/test/bugs/bug324.dir/main.go new file mode 100644 index 00000000000..4c1a18d9ca2 --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug324.dir/main.go @@ -0,0 +1,48 @@ +// 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 + +import ( + "./p" +) + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() { println("main.Implementation.private()") } + + +func main() { + // nothing unusual here + var x Exported + x = new(Implementation) + x.private() // main.Implementation.private() + + // same here - should be and is legal + var px p.Exported + px = p.X + + // this assignment is correctly illegal: + // px.private undefined (cannot refer to unexported field or method private) + // px.private() + + // this assignment is correctly illegal: + // *Implementation does not implement p.Exported (missing p.private method) + // px = new(Implementation) + + // this assignment is correctly illegal: + // p.Exported does not implement Exported (missing private method) + // x = px + + // this assignment unexpectedly compiles and then executes + x = px.(Exported) + + // this is a legitimate call, but because of the previous assignment, + // it invokes the method private in p! + x.private() // p.Implementation.private() +} diff --git a/gcc/testsuite/go.test/test/bugs/bug324.dir/p.go b/gcc/testsuite/go.test/test/bugs/bug324.dir/p.go new file mode 100644 index 00000000000..d1e3b991aad --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug324.dir/p.go @@ -0,0 +1,15 @@ +// 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 p + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() { println("p.Implementation.private()") } + +var X = new(Implementation) diff --git a/gcc/testsuite/go.test/test/bugs/bug324.go b/gcc/testsuite/go.test/test/bugs/bug324.go new file mode 100644 index 00000000000..e188515d772 --- /dev/null +++ b/gcc/testsuite/go.test/test/bugs/bug324.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go && $L main.$A && ! ./$A.out || echo BUG: should fail + +// 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 case for issue 1550 +ignored diff --git a/gcc/testsuite/go.test/test/chan/select4.go b/gcc/testsuite/go.test/test/chan/select4.go new file mode 100644 index 00000000000..46618ac8812 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/select4.go @@ -0,0 +1,25 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +package main + +func f() *int { + println("BUG: called f") + return new(int) +} + +func main() { + var x struct { + a int + } + c := make(chan int, 1) + c1 := make(chan int) + c <- 42 + select { + case *f() = <-c1: + // nothing + case x.a = <-c: + if x.a != 42 { + println("BUG:", x.a) + } + } +} diff --git a/gcc/testsuite/go.test/test/chan/select5.go b/gcc/testsuite/go.test/test/chan/select5.go new file mode 100644 index 00000000000..e7ca9e015c1 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/select5.go @@ -0,0 +1,482 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go && +// $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: select5 +// rm -f tmp.go + +// 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. + +// Generate test of channel operations and simple selects. +// Only doing one real send or receive at a time, but phrased +// in various ways that the compiler may or may not rewrite +// into simpler expressions. + +package main + +import ( + "bufio" + "fmt" + "io" + "os" + "template" +) + +func main() { + out := bufio.NewWriter(os.Stdout) + 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. + // 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() { + run(t, a, out) + } + fmt.Fprintln(out, `}`) + } + + do(recv) + do(send) + do(recvOrder) + do(sendOrder) + do(nonblock) + + fmt.Fprintln(out, "//", a.nreset, "cases") + out.Flush() +} + +func run(t *template.Template, a interface{}, out io.Writer) { + if err := t.Execute(out, a); err != nil { + panic(err) + } +} + +type arg struct{ + def bool + nreset int +} + +func (a *arg) Maybe() bool { + return maybe() +} + +func (a *arg) MaybeDefault() bool { + if a.def { + return false + } + a.def = maybe() + return a.def +} + +func (a *arg) MustDefault() bool { + return !a.def +} + +func (a *arg) reset() { + a.def = false + a.nreset++ +} + +const header = `// GENERATED BY select5.go; DO NOT EDIT + +package main + +// channel is buffered so test is single-goroutine. +// we are not interested in the concurrency aspects +// of select, just testing that the right calls happen. +var c = make(chan int, 1) +var nilch chan int +var n = 1 +var x int +var i interface{} +var dummy = make(chan int) +var m = make(map[int]int) +var order = 0 + +func f(p *int) *int { + return p +} + +// check order of operations by ensuring that +// successive calls to checkorder have increasing o values. +func checkorder(o int) { + if o <= order { + println("invalid order", o, "after", order) + panic("order") + } + order = o +} + +func fc(c chan int, o int) chan int { + checkorder(o) + return c +} + +func fp(p *int, o int) *int { + checkorder(o) + return p +} + +func fn(n, o int) int { + checkorder(o) + return n +} + +func die(x int) { + println("have", x, "want", n) + panic("chan") +} + +func main() { + // everything happens in init funcs +} +` + +func parse(s string) *template.Template { + t := template.New(nil) + t.SetDelims("〈", "〉") + if err := t.Parse(s); err != nil { + panic(s) + } + return t +} + +var recv = parse(` + 〈# Send n, receive it one way or another into x, check that they match.〉 + c <- n + 〈.section Maybe〉 + x = <-c + 〈.or〉 + select { + 〈# Blocking or non-blocking, before the receive.〉 + 〈# The compiler implements two-case select where one is default with custom code,〉 + 〈# so test the default branch both before and after the send.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Receive from c. Different cases are direct, indirect, :=, interface, and map assignment.〉 + 〈.section Maybe〉 + case x = <-c: + 〈.or〉〈.section Maybe〉 + case *f(&x) = <-c: + 〈.or〉〈.section Maybe〉 + case y := <-c: + x = y + 〈.or〉〈.section Maybe〉 + case i = <-c: + x = i.(int) + 〈.or〉 + case m[13] = <-c: + x = m[13] + 〈.end〉〈.end〉〈.end〉〈.end〉 + 〈# Blocking or non-blocking again, after the receive.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Dummy send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case dummy <- 1: + panic("dummy send") + 〈.end〉 + 〈.section Maybe〉 + case <-dummy: + panic("dummy receive") + 〈.end〉 + 〈# Nil channel send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case nilch <- 1: + panic("nilch send") + 〈.end〉 + 〈.section Maybe〉 + case <-nilch: + panic("nilch recv") + 〈.end〉 + } + 〈.end〉 + if x != n { + die(x) + } + n++ +`) + +var recvOrder = parse(` + 〈# Send n, receive it one way or another into x, check that they match.〉 + 〈# Check order of operations along the way by calling functions that check〉 + 〈# that the argument sequence is strictly increasing.〉 + order = 0 + c <- n + 〈.section Maybe〉 + 〈# Outside of select, left-to-right rule applies.〉 + 〈# (Inside select, assignment waits until case is chosen,〉 + 〈# so right hand side happens before anything on left hand side.〉 + *fp(&x, 1) = <-fc(c, 2) + 〈.or〉〈.section Maybe〉 + m[fn(13, 1)] = <-fc(c, 2) + x = m[13] + 〈.or〉 + select { + 〈# Blocking or non-blocking, before the receive.〉 + 〈# The compiler implements two-case select where one is default with custom code,〉 + 〈# so test the default branch both before and after the send.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Receive from c. Different cases are direct, indirect, :=, interface, and map assignment.〉 + 〈.section Maybe〉 + case *fp(&x, 100) = <-fc(c, 1): + 〈.or〉〈.section Maybe〉 + case y := <-fc(c, 1): + x = y + 〈.or〉〈.section Maybe〉 + case i = <-fc(c, 1): + x = i.(int) + 〈.or〉 + case m[fn(13, 100)] = <-fc(c, 1): + x = m[13] + 〈.end〉〈.end〉〈.end〉 + 〈# Blocking or non-blocking again, after the receive.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Dummy send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case fc(dummy, 2) <- fn(1, 3): + panic("dummy send") + 〈.end〉 + 〈.section Maybe〉 + case <-fc(dummy, 4): + panic("dummy receive") + 〈.end〉 + 〈# Nil channel send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case fc(nilch, 5) <- fn(1, 6): + panic("nilch send") + 〈.end〉 + 〈.section Maybe〉 + case <-fc(nilch, 7): + panic("nilch recv") + 〈.end〉 + } + 〈.end〉〈.end〉 + if x != n { + die(x) + } + n++ +`) + +var send = parse(` + 〈# Send n one way or another, receive it into x, check that they match.〉 + 〈.section Maybe〉 + c <- n + 〈.or〉 + select { + 〈# Blocking or non-blocking, before the receive (same reason as in recv).〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Send c <- n. No real special cases here, because no values come back〉 + 〈# from the send operation.〉 + case c <- n: + 〈# Blocking or non-blocking.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Dummy send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case dummy <- 1: + panic("dummy send") + 〈.end〉 + 〈.section Maybe〉 + case <-dummy: + panic("dummy receive") + 〈.end〉 + 〈# Nil channel send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case nilch <- 1: + panic("nilch send") + 〈.end〉 + 〈.section Maybe〉 + case <-nilch: + panic("nilch recv") + 〈.end〉 + } + 〈.end〉 + x = <-c + if x != n { + die(x) + } + n++ +`) + +var sendOrder = parse(` + 〈# Send n one way or another, receive it into x, check that they match.〉 + 〈# Check order of operations along the way by calling functions that check〉 + 〈# that the argument sequence is strictly increasing.〉 + order = 0 + 〈.section Maybe〉 + fc(c, 1) <- fn(n, 2) + 〈.or〉 + select { + 〈# Blocking or non-blocking, before the receive (same reason as in recv).〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Send c <- n. No real special cases here, because no values come back〉 + 〈# from the send operation.〉 + case fc(c, 1) <- fn(n, 2): + 〈# Blocking or non-blocking.〉 + 〈.section MaybeDefault〉 + default: + panic("nonblock") + 〈.end〉 + 〈# Dummy send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case fc(dummy, 3) <- fn(1, 4): + panic("dummy send") + 〈.end〉 + 〈.section Maybe〉 + case <-fc(dummy, 5): + panic("dummy receive") + 〈.end〉 + 〈# Nil channel send, receive to keep compiler from optimizing select.〉 + 〈.section Maybe〉 + case fc(nilch, 6) <- fn(1, 7): + panic("nilch send") + 〈.end〉 + 〈.section Maybe〉 + case <-fc(nilch, 8): + panic("nilch recv") + 〈.end〉 + } + 〈.end〉 + x = <-c + if x != n { + die(x) + } + n++ +`) + +var nonblock = parse(` + x = n + 〈# Test various combinations of non-blocking operations.〉 + 〈# Receive assignments must not edit or even attempt to compute the address of the lhs.〉 + select { + 〈.section MaybeDefault〉 + default: + 〈.end〉 + 〈.section Maybe〉 + case dummy <- 1: + panic("dummy <- 1") + 〈.end〉 + 〈.section Maybe〉 + case nilch <- 1: + panic("nilch <- 1") + 〈.end〉 + 〈.section Maybe〉 + case <-dummy: + panic("<-dummy") + 〈.end〉 + 〈.section Maybe〉 + case x = <-dummy: + panic("<-dummy x") + 〈.end〉 + 〈.section Maybe〉 + case **(**int)(nil) = <-dummy: + panic("<-dummy (and didn't crash saving result!)") + 〈.end〉 + 〈.section Maybe〉 + case <-nilch: + panic("<-nilch") + 〈.end〉 + 〈.section Maybe〉 + case x = <-nilch: + panic("<-nilch x") + 〈.end〉 + 〈.section Maybe〉 + case **(**int)(nil) = <-nilch: + panic("<-nilch (and didn't crash saving result!)") + 〈.end〉 + 〈.section MustDefault〉 + default: + 〈.end〉 + } + if x != n { + die(x) + } + n++ +`) + +// Code for enumerating all possible paths through +// some logic. The logic should call choose(n) when +// it wants to choose between n possibilities. +// On successive runs through the logic, choose(n) +// will return 0, 1, ..., n-1. The helper maybe() is +// similar but returns true and then false. +// +// Given a function gen that generates an output +// using choose and maybe, code can generate all +// possible outputs using +// +// for next() { +// gen() +// } + +type choice struct { + i, n int +} + +var choices []choice +var cp int = -1 + +func maybe() bool { + return choose(2) == 0 +} + +func choose(n int) int { + if cp >= len(choices) { + // never asked this before: start with 0. + choices = append(choices, choice{0, n}) + cp = len(choices) + return 0 + } + // otherwise give recorded answer + if n != choices[cp].n { + panic("inconsistent choices") + } + i := choices[cp].i + cp++ + return i +} + +func next() bool { + if cp < 0 { + // start a new round + cp = 0 + return true + } + + // increment last choice sequence + cp = len(choices)-1 + for cp >= 0 && choices[cp].i == choices[cp].n-1 { + cp-- + } + if cp < 0 { + choices = choices[:0] + return false + } + choices[cp].i++ + choices = choices[:cp+1] + cp = 0 + return true +} + diff --git a/gcc/testsuite/go.test/test/chan/sendstmt.go b/gcc/testsuite/go.test/test/chan/sendstmt.go new file mode 100644 index 00000000000..ee6f765cf88 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/sendstmt.go @@ -0,0 +1,37 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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. + +package main + +func main() { + chanchan() + sendprec() +} + +func chanchan() { + cc := make(chan chan int, 1) + c := make(chan int, 1) + cc <- c + select { + case <-cc <- 2: + default: + panic("nonblock") + } + if <-c != 2 { + panic("bad receive") + } +} + +func sendprec() { + c := make(chan bool, 1) + 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/closure.go b/gcc/testsuite/go.test/test/closure.go index 54e4cf8eae3..3033c02ed81 100644 --- a/gcc/testsuite/go.test/test/closure.go +++ b/gcc/testsuite/go.test/test/closure.go @@ -98,4 +98,15 @@ func main() { println("newfunc returned broken funcs") panic("fail") } + + ff(1) +} + +func ff(x int) { + call(func() { + _ = x + }) +} + +func call(func()) { } diff --git a/gcc/testsuite/go.test/test/cmp1.go b/gcc/testsuite/go.test/test/cmp1.go index db0a486dd33..698544c5821 100644 --- a/gcc/testsuite/go.test/test/cmp1.go +++ b/gcc/testsuite/go.test/test/cmp1.go @@ -26,6 +26,8 @@ func istrue(b bool) { } } +type T *int + func main() { var a []int var b map[string]int @@ -55,6 +57,24 @@ func main() { isfalse(ib == id) istrue(ic == id) istrue(ie == ie) + + // these are okay because one side of the + // comparison need only be assignable to the other. + isfalse(a == ib) + isfalse(a == ic) + isfalse(a == id) + isfalse(b == ic) + isfalse(b == id) + istrue(c == id) + istrue(e == ie) + + isfalse(ia == b) + isfalse(ia == c) + isfalse(ia == d) + isfalse(ib == c) + isfalse(ib == d) + istrue(ic == d) + istrue(ie == e) // 6g used to let this go through as true. var g uint64 = 123 @@ -73,4 +93,38 @@ func main() { println("m[ic] = ", m[ic]) panic("bad m[ic]") } + + // non-interface comparisons + { + c := make(chan int) + c1 := (<-chan int)(c) + c2 := (chan<- int)(c) + istrue(c == c1) + istrue(c == c2) + istrue(c1 == c) + istrue(c2 == c) + + d := make(chan int) + isfalse(c == d) + isfalse(d == c) + isfalse(d == c1) + isfalse(d == c2) + isfalse(c1 == d) + isfalse(c2 == d) + } + + // named types vs not + { + var x = new(int) + var y T + var z T = x + + isfalse(x == y) + istrue(x == z) + isfalse(y == z) + + isfalse(y == x) + istrue(z == x) + isfalse(z == y) + } } diff --git a/gcc/testsuite/go.test/test/cmp6.go b/gcc/testsuite/go.test/test/cmp6.go new file mode 100644 index 00000000000..b3ea8ffebfd --- /dev/null +++ b/gcc/testsuite/go.test/test/cmp6.go @@ -0,0 +1,49 @@ +// errchk $G -e $D/$F.go + +// 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 use(bool) {} + +type T1 *int +type T2 *int + +type T3 struct {} + +var t3 T3 + +func main() { + // Arguments to comparison must be + // assignable one to the other (or vice versa) + // so chan int can be compared against + // directional channels but channel of different + // direction cannot be compared against each other. + var c1 chan <-int + var c2 <-chan int + var c3 chan int + + use(c1 == c2) // ERROR "invalid operation|incompatible" + use(c2 == c1) // ERROR "invalid operation|incompatible" + use(c1 == c3) + use(c2 == c2) + use(c3 == c1) + use(c3 == c2) + + // Same applies to named types. + var p1 T1 + var p2 T2 + var p3 *int + + use(p1 == p2) // ERROR "invalid operation|incompatible" + use(p2 == p1) // ERROR "invalid operation|incompatible" + use(p1 == p3) + use(p2 == p2) + use(p3 == p1) + use(p3 == p2) + + // Comparison of structs should have a good message + use(t3 == t3) // ERROR "struct|expected" +} diff --git a/gcc/testsuite/go.test/test/cmplxdivide.c b/gcc/testsuite/go.test/test/cmplxdivide.c index b3c6055ed23..b340f04d887 100644 --- a/gcc/testsuite/go.test/test/cmplxdivide.c +++ b/gcc/testsuite/go.test/test/cmplxdivide.c @@ -72,7 +72,7 @@ main(void) if(iscnan(n) && d == 0) q = (NAN+NAN*I) / zero; - printf("\tTest{cmplx(%s, %s), cmplx(%s, %s), cmplx(%s, %s)},\n", + printf("\tTest{complex(%s, %s), complex(%s, %s), complex(%s, %s)},\n", fmt(creal(n)), fmt(cimag(n)), fmt(creal(d)), fmt(cimag(d)), fmt(creal(q)), fmt(cimag(q))); diff --git a/gcc/testsuite/go.test/test/const1.go b/gcc/testsuite/go.test/test/const1.go index 6cfcb460b50..67f36e4fdc9 100644 --- a/gcc/testsuite/go.test/test/const1.go +++ b/gcc/testsuite/go.test/test/const1.go @@ -78,3 +78,5 @@ func main() { f(String) // ERROR "convert|wrong type|cannot|incompatible" f(Bool) // ERROR "convert|wrong type|cannot|incompatible" } + +const ptr = nil // ERROR "const.*nil" diff --git a/gcc/testsuite/go.test/test/const3.go b/gcc/testsuite/go.test/test/const3.go index dd5c88958d7..9bba6ced0b8 100644 --- a/gcc/testsuite/go.test/test/const3.go +++ b/gcc/testsuite/go.test/test/const3.go @@ -26,4 +26,10 @@ func main() { println("type info didn't propagate in const: got", s) panic("fail") } + x := uint(5) + y := float64(uint64(1)<. The syntax -# is Perl but its best to stick to egrep. +# 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; if(@ARGV < 1) { - print STDERR "Usage: errchk COMPILER [OPTS] SOURCEFILE\n"; + print STDERR "Usage: errchk COMPILER [OPTS] SOURCEFILES\n"; exit 1; } -$file = $ARGV[@ARGV-1]; -open(SRC, $file) || die "BUG: errchk: open $file: $!"; -@src = ; -close(SRC); +# Grab SOURCEFILES +foreach(reverse 0 .. @ARGV-1) { + unless($ARGV[$_] =~ /\.go$/) { + @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); @@ -57,35 +65,46 @@ sub bug() { } } -$line = 0; -foreach $src (@src) { - $line++; - next unless $src =~ m|// (GC_)?ERROR (.*)|; - $regexp = $2; - if($regexp !~ /^"([^"]*)"/) { - print STDERR "$file:$line: malformed regexp\n"; - next; - } - $regexp = $1; - - @errmsg = grep { /$file:$line:/ } @out; - @out = grep { !/$file:$line:/ } @out; - if(@errmsg == 0) { - bug(); - print STDERR "errchk: $file:$line: missing expected error: '$regexp'\n"; - next; - } - @match = grep { /$regexp/ } @errmsg; - if(@match == 0) { - bug(); - print STDERR "errchk: $file:$line: error message does not match '$regexp'\n"; - next; +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 (.*)|; + $regexp = $2; + if($regexp !~ /^"([^"]*)"/) { + print STDERR "$file:$line: malformed regexp\n"; + next; + } + $regexp = $1; + + @errmsg = grep { /$file:$line[:[]/ } @out; + @out = grep { !/$file:$line[:[]/ } @out; + if(@errmsg == 0) { + bug(); + print STDERR "errchk: $file:$line: missing expected error: '$regexp'\n"; + next; + } + @match = grep { /$regexp/ } @errmsg; + if(@match == 0) { + bug(); + print STDERR "errchk: $file:$line: error message does not match '$regexp'\n"; + next; + } } } +foreach $file (@file) { + chk($file) +} + if(@out != 0) { bug(); - print STDERR "errchk: $file: unmatched error messages:\n"; + print STDERR "errchk: unmatched error messages:\n"; print STDERR "==================================================\n"; print STDERR @out; print STDERR "==================================================\n"; diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug016.go b/gcc/testsuite/go.test/test/fixedbugs/bug016.go index 461bcf82ac4..4fbfd48fd97 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug016.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug016.go @@ -1,4 +1,4 @@ -// ! $G $D/$F.go +// errchk $G -e $D/$F.go // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -7,8 +7,8 @@ package main func main() { - var i int = 100; - i = i << -3; // BUG: should not compile (negative shift) + var i int = 100 + i = i << -3 // ERROR "overflows|negative" } /* diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug069.go b/gcc/testsuite/go.test/test/fixedbugs/bug069.go index bf73163134d..9038387ac86 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug069.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug069.go @@ -7,15 +7,14 @@ package main func main() { - //TODO(rsc): uncomment when this syntax is valid for receive+check closed - // c := make(chan int); - // ok := false; - // var i int; - // - // i, ok = <-c; // works - // _, _ = i, ok; - // - // ca := new([2]chan int); - // i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2 - // _, _ = i, ok; + c := make(chan int); + ok := false; + var i int; + + i, ok = <-c; // works + _, _ = i, ok; + + ca := new([2]chan int); + i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2 + _, _ = i, ok; } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug081.go b/gcc/testsuite/go.test/test/fixedbugs/bug081.go index ccb36995343..026ce8002f2 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug081.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug081.go @@ -1,12 +1,12 @@ -// ! $G $D/$F.go +// errchk $G $D/$F.go // 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. -package main - -const x x = 2; +package main + +const x x = 2 // ERROR "loop|type" /* bug081.go:3: first constant must evaluate an expression diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug1515.go b/gcc/testsuite/go.test/test/fixedbugs/bug1515.go new file mode 100644 index 00000000000..7402525164f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug1515.go @@ -0,0 +1,20 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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 + +const ( + joao = "João" + jose = "José" +) + +func main() { + s1 := joao + s2 := jose + if (s1 < s2) != (joao < jose) { + panic("unequal") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug196.go b/gcc/testsuite/go.test/test/fixedbugs/bug196.go index 8cb9c9990d9..ea8ab0dc193 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug196.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug196.go @@ -13,12 +13,11 @@ var i int func multi() (int, int) { return 1, 2 } func xxx() { - //TODO(rsc): uncomment when this syntax is valid for receive+check closed - // var c chan int - // x, ok := <-c + var c chan int + x, ok := <-c var m map[int]int - x, ok := m[1] + x, ok = m[1] var i interface{} var xx int diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug234.go b/gcc/testsuite/go.test/test/fixedbugs/bug234.go index 9affad04302..562109a058b 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug234.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug234.go @@ -7,17 +7,17 @@ package main func main() { - //TODO(rsc): uncomment when this syntax is valid for receive+check closed - // c := make(chan int, 1) - // c <- 100 - // x, ok := <-c - // if x != 100 || !ok { - // println("x=", x, " ok=", ok, " want 100, true") - // panic("fail") - // } - // x, ok = <-c - // if x != 0 || ok { - // println("x=", x, " ok=", ok, " want 0, false") - // panic("fail") - // } + c := make(chan int, 1) + c <- 100 + x, ok := <-c + if x != 100 || !ok { + println("x=", x, " ok=", ok, " want 100, true") + panic("fail") + } + close(c) + x, ok = <-c + if x != 0 || ok { + println("x=", x, " ok=", ok, " want 0, false") + panic("fail") + } } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug242.go b/gcc/testsuite/go.test/test/fixedbugs/bug242.go index ad1cef8df43..839dccd3741 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug242.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug242.go @@ -101,13 +101,11 @@ func main() { c := make(chan byte, 1) c <- 'C' - //TODO(rsc): uncomment when this syntax is valid for receive+check closed // 15 16 - // *f(), p1 = <-e1(c, 16) - *f(), p1 = <-e1(c, 16), true // delete uncommenting above + *f(), p1 = <-e1(c, 16) + close(c) // 17 18 - // *f(), p2 = <-e1(c, 18) - *f(), p2, _ = 0, false, e1(c, 18) // delete when uncommenting above + *f(), p2 = <-e1(c, 18) a[17] += '0' if !p1 || p2 { println("bad chan check", i, p1, p2) diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug243.go b/gcc/testsuite/go.test/test/fixedbugs/bug243.go index 357f22eb274..236c14402f7 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug243.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug243.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # no network // $G $D/$F.go && $L $F.$A && ./$A.out // Copyright 2010 The Go Authors. All rights reserved. diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug252.go b/gcc/testsuite/go.test/test/fixedbugs/bug252.go index 6df94241a0c..a2c1dab9d39 100644 --- a/gcc/testsuite/go.test/test/fixedbugs/bug252.go +++ b/gcc/testsuite/go.test/test/fixedbugs/bug252.go @@ -11,5 +11,5 @@ func f(args ...int) { } func g(args ...interface{}) { - f(args) // ERROR "[.][.][.]|incompatible" + f(args) // ERROR "cannot use|incompatible" } diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug260.go b/gcc/testsuite/go.test/test/fixedbugs/bug260.go new file mode 100644 index 00000000000..34757c70eef --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug260.go @@ -0,0 +1,61 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug260 failed + +// Test that structures pack densely, according to the alignment of the largest field. + +package main + +import ( + "fmt" + "os" + "strconv" +) + +type T1 struct { + x uint8 +} +type T2 struct { + x uint16 +} +type T4 struct { + x uint32 +} + +func main() { + report := len(os.Args) > 1 + status := 0 + var b1 [10]T1 + a0, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[0])[2:], 16) + a1, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[1])[2:], 16) + if a1 != a0+1 { + fmt.Println("FAIL") + if report { + fmt.Println("alignment should be 1, is", a1-a0) + } + status = 1 + } + var b2 [10]T2 + a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[0])[2:], 16) + a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[1])[2:], 16) + if a1 != a0+2 { + if status == 0 { + fmt.Println("FAIL") + status = 1 + } + if report { + fmt.Println("alignment should be 2, is", a1-a0) + } + } + var b4 [10]T4 + a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[0])[2:], 16) + a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[1])[2:], 16) + if a1 != a0+4 { + if status == 0 { + fmt.Println("FAIL") + status = 1 + } + if report { + fmt.Println("alignment should be 4, is", a1-a0) + } + } + os.Exit(status) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug305.go b/gcc/testsuite/go.test/test/fixedbugs/bug305.go new file mode 100644 index 00000000000..758fee2698a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug305.go @@ -0,0 +1,24 @@ +// errchk $G $D/$F.go + +// 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. + +// Use //line to set the line number of the next line to 20. +//line fixedbugs/bug305.go:20 + +package p + +// Introduce an error which should be reported on line 24. +var a int = "bogus" + +// Line 15 of file. +// 16 +// 17 +// 18 +// 19 +// 20 +// 21 +// 22 +// 23 +// ERROR "cannot|incompatible" diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go new file mode 100644 index 00000000000..bf87ea1491d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p1.go @@ -0,0 +1,9 @@ +// 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 p1 + +type T <-chan int +var x = make(chan T) + diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go new file mode 100644 index 00000000000..3f8bd9d49b5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug306.dir/p2.go @@ -0,0 +1,8 @@ +// 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 p2 + +import _ "./p1" + diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug306.go b/gcc/testsuite/go.test/test/fixedbugs/bug306.go new file mode 100644 index 00000000000..a0a43507dcb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug306.go @@ -0,0 +1,7 @@ +// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go + +// 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. + +ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug307.go b/gcc/testsuite/go.test/test/fixedbugs/bug307.go new file mode 100644 index 00000000000..1b42c09ab1e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug307.go @@ -0,0 +1,15 @@ +// $G $D/$F.go + +// 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. + +// Valid program, gccgo reported an error. +// bug307.go:14:6: error: complex arguments must have identical types + +package main + +func main() { + var f float64 + _ = complex(1/f, 0) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug308.go b/gcc/testsuite/go.test/test/fixedbugs/bug308.go new file mode 100644 index 00000000000..c2845f04213 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug308.go @@ -0,0 +1,19 @@ +// $G $D/$F.go + +// 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. + +// issue 1136 + +package main + +import "fmt" + +func log1(f string, argv ...interface{}) { + fmt.Printf("log: %s\n", fmt.Sprintf(f, argv...)) +} + +func main() { + log1("%d", 42) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug309.go b/gcc/testsuite/go.test/test/fixedbugs/bug309.go new file mode 100644 index 00000000000..07bebae74c1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug309.go @@ -0,0 +1,19 @@ +// $G $D/$F.go + +// 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. + +// issue 1016 + +package main + +func foo(t interface{}, c chan int) { + switch v := t.(type) { + case int: + select { + case <-c: + // bug was: internal compiler error: var without type, init: v + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug310.go b/gcc/testsuite/go.test/test/fixedbugs/bug310.go new file mode 100644 index 00000000000..191f3ed2b4e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug310.go @@ -0,0 +1,20 @@ +// errchk $G $D/$F.go + +// 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 p + +import ( + "bytes" + "fmt" +) + +type t int + +func main() { + _ = t.bar // ERROR "no method" + var b bytes.Buffer + fmt.Print(b) // ERROR "implicit assignment" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug311.go b/gcc/testsuite/go.test/test/fixedbugs/bug311.go new file mode 100644 index 00000000000..ed937a67470 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug311.go @@ -0,0 +1,20 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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() { + m := make(map[string][1000]byte) + m["hi"] = [1000]byte{1} + + v := m["hi"] + + for k, vv := range m { + if k != "hi" || string(v[:]) != string(vv[:]) { + panic("bad iter") + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug312.go b/gcc/testsuite/go.test/test/fixedbugs/bug312.go new file mode 100644 index 00000000000..70888dd410f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug312.go @@ -0,0 +1,22 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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. + +// issue 1172 + +package main + +func main() { + var i interface{} + c := make(chan int, 1) + c <- 1 + select { + case i = <-c: // error on this line + } + if i != 1 { + println("bad i", i) + panic("BUG") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go new file mode 100644 index 00000000000..cb4ca7256b9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/a.go @@ -0,0 +1,11 @@ +// 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" + +func a() { + fmt.DoesNotExist() // ERROR "undefined" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go new file mode 100644 index 00000000000..7eda72b4f8b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.dir/b.go @@ -0,0 +1,11 @@ +// 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" + +func b() { + Println() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug313.go b/gcc/testsuite/go.test/test/fixedbugs/bug313.go new file mode 100644 index 00000000000..eb2a0223b6c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug313.go @@ -0,0 +1,19 @@ +// errchk $G -e $D/$F.dir/[ab].go + +// 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. + +// Issue 1284 + +package bug313 + +/* +6g bug313.dir/[ab].go + +Before: +bug313.dir/b.go:7: internal compiler error: fault + +Now: +bug313.dir/a.go:10: undefined: fmt.DoesNotExist +*/ diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug314.go b/gcc/testsuite/go.test/test/fixedbugs/bug314.go new file mode 100644 index 00000000000..95d81d7951e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug314.go @@ -0,0 +1,31 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug314 + +// 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. + +// Used to call wrong methods; issue 1290. + +package main + +type S struct { +} +func (S) a() int{ + return 0 +} +func (S) b() int{ + return 1 +} + +func main() { + var i interface { + b() int + a() int + } = S{} + if i.a() != 0 { + panic("wrong method called") + } + if i.b() != 1 { + panic("wrong method called") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug315.go b/gcc/testsuite/go.test/test/fixedbugs/bug315.go new file mode 100644 index 00000000000..c59ef29e6c0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug315.go @@ -0,0 +1,18 @@ +// $G $D/$F.go || echo BUG: bug315 + +// 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. + +// Issue 1368. + +package main + +func main() { + a := complex(2, 2) + a /= 2 +} + +/* +bug315.go:13: internal compiler error: optoas: no entry DIV-complex +*/ diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug316.go b/gcc/testsuite/go.test/test/fixedbugs/bug316.go new file mode 100644 index 00000000000..2146408a1e2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug316.go @@ -0,0 +1,17 @@ +// $G $D/$F.go || echo BUG: bug316 + +// 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. + +// Issue 1369. + +package main + +const ( + c = complex(1, 2) + r = real(c) // was: const initializer must be constant + i = imag(c) // was: const initializer must be constant +) + +func main() {} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug317.go b/gcc/testsuite/go.test/test/fixedbugs/bug317.go new file mode 100644 index 00000000000..0cb26c29ba1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug317.go @@ -0,0 +1,16 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug317 + +// 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() { + x := []uint{0} + x[0] &^= f() +} + +func f() uint { + return 1<<31 // doesn't panic with 1<<31 - 1 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug318.go b/gcc/testsuite/go.test/test/fixedbugs/bug318.go new file mode 100644 index 00000000000..9c46a04269c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug318.go @@ -0,0 +1,12 @@ +// errchk $G $D/$F.go + +// 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 1411. + +package main + +const ui uint = 0 +const i int = ui // ERROR "type" diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug319.go b/gcc/testsuite/go.test/test/fixedbugs/bug319.go new file mode 100644 index 00000000000..f60eee4fb23 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug319.go @@ -0,0 +1,22 @@ +// $G $D/$F.go + +// 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 + +import "unsafe" + +func main() { + var x int + + a := uint64(uintptr(unsafe.Pointer(&x))) + b := uint32(uintptr(unsafe.Pointer(&x))) + c := uint16(uintptr(unsafe.Pointer(&x))) + d := int64(uintptr(unsafe.Pointer(&x))) + e := int32(uintptr(unsafe.Pointer(&x))) + f := int16(uintptr(unsafe.Pointer(&x))) + + _, _, _, _, _, _ = a, b, c, d, e, f +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug320.go b/gcc/testsuite/go.test/test/fixedbugs/bug320.go new file mode 100644 index 00000000000..06d41f2ed87 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug320.go @@ -0,0 +1,45 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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() { + c := make(chan int, 1) + dummy := make(chan int) + v := 0x12345678 + for i := 0; i < 10; i++ { + // 6g had a bug that caused select to pass &t to + // selectrecv before allocating the memory for t, + // which caused non-deterministic crashes. + // This test looks for the bug by checking that the + // value received actually ends up in t. + // If the allocation happens after storing through + // whatever garbage &t holds, the later reference + // to t in the case body will use the new pointer and + // not see the received value. + v += 0x1020304 + c <- v + select { + case t := <-c: + go func() { + f(t) + }() + escape(&t) + if t != v { + println(i, v, t) + panic("wrong values") + } + case dummy <- 1: + } + } +} + +func escape(*int) { +} + +func f(int) { +} + diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug321.go b/gcc/testsuite/go.test/test/fixedbugs/bug321.go new file mode 100644 index 00000000000..d0595ff59b6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug321.go @@ -0,0 +1,30 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug321 + +// 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. + +// Troublesome floating point constants. Issue 1463. + +package main + +import "fmt" + +func check(test string, got, want float64) bool { + if got != want { + fmt.Println(test, "got", got, "want", want) + return false + } + return true +} + +func main() { + good := true + // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ + good = good && check("2.2250738585072012e-308", 2.2250738585072012e-308, 2.2250738585072014e-308) + // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ + good = good && check("2.2250738585072011e-308", 2.2250738585072011e-308, 2.225073858507201e-308) + if !good { + panic("fail") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug323.go b/gcc/testsuite/go.test/test/fixedbugs/bug323.go new file mode 100644 index 00000000000..23e2be6603a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug323.go @@ -0,0 +1,20 @@ +// errchk $G $D/$F.go + +// 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 + +type T struct{} +type P *T + +func (t *T) Meth() {} +func (t T) Meth2() {} + +func main() { + t := &T{} + p := P(t) + p.Meth() // ERROR "undefined" + p.Meth2() // ERROR "undefined" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug325.go b/gcc/testsuite/go.test/test/fixedbugs/bug325.go new file mode 100644 index 00000000000..b86740fff93 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug325.go @@ -0,0 +1,15 @@ +// errchk $G $D/$F.go + +// 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 + +import "unsafe" + +func main() { + var x unsafe.Pointer + println(*x) // ERROR "invalid indirect.*unsafe.Pointer" + var _ = (unsafe.Pointer)(nil).foo // ERROR "foo" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug326.go b/gcc/testsuite/go.test/test/fixedbugs/bug326.go new file mode 100644 index 00000000000..efdd0ef7131 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/bug326.go @@ -0,0 +1,41 @@ +// errchk $G $D/$F.go + +// 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 p + +import "os" + +func f() (_ int, err os.Error) { + return +} + +func g() (x int, _ os.Error) { + return +} + +func h() (_ int, _ os.Error) { + return +} + +func i() (int, os.Error) { + return // ERROR "not enough arguments to return" +} + +func f1() (_ int, err os.Error) { + return 1, nil +} + +func g1() (x int, _ os.Error) { + return 1, nil +} + +func h1() (_ int, _ os.Error) { + return 1, nil +} + +func ii() (int, os.Error) { + return 1, nil +} diff --git a/gcc/testsuite/go.test/test/float_lit.go b/gcc/testsuite/go.test/test/float_lit.go index 3ffc5c1e4f2..7b91d88e51a 100644 --- a/gcc/testsuite/go.test/test/float_lit.go +++ b/gcc/testsuite/go.test/test/float_lit.go @@ -6,29 +6,19 @@ package main -import "os" - -var deLim float64 var bad bool -func -init() { - if os.Getenv("GOARCH") == "arm" { - deLim = 1.0e-8 - } else { - deLim = 10.e-14 +func pow10(pow int) float64 { + if pow < 0 { + return 1 / pow10(-pow) + } + if pow > 0 { + return pow10(pow-1) * 10 } -} - -func -pow10(pow int) float64 { - if pow < 0 { return 1/pow10(-pow); } - if pow > 0 { return pow10(pow-1)*10; } return 1 } -func -close(da float64, ia, ib int64, pow int) bool { +func close(da float64, ia, ib int64, pow int) bool { db := float64(ia) / float64(ib) db *= pow10(pow) @@ -39,12 +29,12 @@ close(da float64, ia, ib int64, pow int) bool { return false } - de := (da-db) /da + de := (da - db) / da if de < 0 { de = -de } - if de < deLim { + if de < 1e-14 { return true } if !bad { @@ -54,65 +44,154 @@ close(da float64, ia, ib int64, pow int) bool { return false } -func -main() { - if !close(0., 0, 1, 0) { print("0. is ", 0., "\n"); } - if !close(+10., 10, 1, 0) { print("+10. is ", +10., "\n"); } - if !close(-210., -210, 1, 0) { print("-210. is ", -210., "\n"); } +func main() { + if !close(0., 0, 1, 0) { + print("0. is ", 0., "\n") + } + if !close(+10., 10, 1, 0) { + print("+10. is ", +10., "\n") + } + if !close(-210., -210, 1, 0) { + print("-210. is ", -210., "\n") + } - if !close(.0, 0, 1, 0) { print(".0 is ", .0, "\n"); } - if !close(+.01, 1, 100, 0) { print("+.01 is ", +.01, "\n"); } - if !close(-.012, -12, 1000, 0) { print("-.012 is ", -.012, "\n"); } + if !close(.0, 0, 1, 0) { + print(".0 is ", .0, "\n") + } + if !close(+.01, 1, 100, 0) { + print("+.01 is ", +.01, "\n") + } + if !close(-.012, -12, 1000, 0) { + print("-.012 is ", -.012, "\n") + } - if !close(0.0, 0, 1, 0) { print("0.0 is ", 0.0, "\n"); } - if !close(+10.01, 1001, 100, 0) { print("+10.01 is ", +10.01, "\n"); } - if !close(-210.012, -210012, 1000, 0) { print("-210.012 is ", -210.012, "\n"); } + if !close(0.0, 0, 1, 0) { + print("0.0 is ", 0.0, "\n") + } + if !close(+10.01, 1001, 100, 0) { + print("+10.01 is ", +10.01, "\n") + } + if !close(-210.012, -210012, 1000, 0) { + print("-210.012 is ", -210.012, "\n") + } - if !close(0E+1, 0, 1, 0) { print("0E+1 is ", 0E+1, "\n"); } - if !close(+10e2, 10, 1, 2) { print("+10e2 is ", +10e2, "\n"); } - if !close(-210e3, -210, 1, 3) { print("-210e3 is ", -210e3, "\n"); } + if !close(0E+1, 0, 1, 0) { + print("0E+1 is ", 0E+1, "\n") + } + if !close(+10e2, 10, 1, 2) { + print("+10e2 is ", +10e2, "\n") + } + if !close(-210e3, -210, 1, 3) { + print("-210e3 is ", -210e3, "\n") + } - if !close(0E-1, 0, 1, 0) { print("0E-1 is ", 0E-1, "\n"); } - if !close(+0e23, 0, 1, 1) { print("+0e23 is ", +0e23, "\n"); } - if !close(-0e345, 0, 1, 1) { print("-0e345 is ", -0e345, "\n"); } + if !close(0E-1, 0, 1, 0) { + print("0E-1 is ", 0E-1, "\n") + } + if !close(+0e23, 0, 1, 1) { + print("+0e23 is ", +0e23, "\n") + } + if !close(-0e345, 0, 1, 1) { + print("-0e345 is ", -0e345, "\n") + } - if !close(0E1, 0, 1, 1) { print("0E1 is ", 0E1, "\n"); } - if !close(+10e23, 10, 1, 23) { print("+10e23 is ", +10e23, "\n"); } - if !close(-210e34, -210, 1, 34) { print("-210e34 is ", -210e34, "\n"); } + if !close(0E1, 0, 1, 1) { + print("0E1 is ", 0E1, "\n") + } + if !close(+10e23, 10, 1, 23) { + print("+10e23 is ", +10e23, "\n") + } + if !close(-210e34, -210, 1, 34) { + print("-210e34 is ", -210e34, "\n") + } - if !close(0.E1, 0, 1, 1) { print("0.E1 is ", 0.E1, "\n"); } - if !close(+10.e+2, 10, 1, 2) { print("+10.e+2 is ", +10.e+2, "\n"); } - if !close(-210.e-3, -210, 1, -3) { print("-210.e-3 is ", -210.e-3, "\n"); } + if !close(0.E1, 0, 1, 1) { + print("0.E1 is ", 0.E1, "\n") + } + if !close(+10.e+2, 10, 1, 2) { + print("+10.e+2 is ", +10.e+2, "\n") + } + if !close(-210.e-3, -210, 1, -3) { + print("-210.e-3 is ", -210.e-3, "\n") + } - if !close(.0E1, 0, 1, 1) { print(".0E1 is ", .0E1, "\n"); } - if !close(+.01e2, 1, 100, 2) { print("+.01e2 is ", +.01e2, "\n"); } - if !close(-.012e3, -12, 1000, 3) { print("-.012e3 is ", -.012e3, "\n"); } + if !close(.0E1, 0, 1, 1) { + print(".0E1 is ", .0E1, "\n") + } + if !close(+.01e2, 1, 100, 2) { + print("+.01e2 is ", +.01e2, "\n") + } + if !close(-.012e3, -12, 1000, 3) { + print("-.012e3 is ", -.012e3, "\n") + } - if !close(0.0E1, 0, 1, 0) { print("0.0E1 is ", 0.0E1, "\n"); } - if !close(+10.01e2, 1001, 100, 2) { print("+10.01e2 is ", +10.01e2, "\n"); } - if !close(-210.012e3, -210012, 1000, 3) { print("-210.012e3 is ", -210.012e3, "\n"); } + if !close(0.0E1, 0, 1, 0) { + print("0.0E1 is ", 0.0E1, "\n") + } + if !close(+10.01e2, 1001, 100, 2) { + print("+10.01e2 is ", +10.01e2, "\n") + } + if !close(-210.012e3, -210012, 1000, 3) { + print("-210.012e3 is ", -210.012e3, "\n") + } - if !close(0.E+12, 0, 1, 0) { print("0.E+12 is ", 0.E+12, "\n"); } - if !close(+10.e23, 10, 1, 23) { print("+10.e23 is ", +10.e23, "\n"); } - if !close(-210.e33, -210, 1, 33) { print("-210.e33 is ", -210.e33, "\n"); } + if !close(0.E+12, 0, 1, 0) { + print("0.E+12 is ", 0.E+12, "\n") + } + if !close(+10.e23, 10, 1, 23) { + print("+10.e23 is ", +10.e23, "\n") + } + if !close(-210.e33, -210, 1, 33) { + print("-210.e33 is ", -210.e33, "\n") + } - if !close(.0E-12, 0, 1, 0) { print(".0E-12 is ", .0E-12, "\n"); } - if !close(+.01e23, 1, 100, 23) { print("+.01e23 is ", +.01e23, "\n"); } - if !close(-.012e34, -12, 1000, 34) { print("-.012e34 is ", -.012e34, "\n"); } + if !close(.0E-12, 0, 1, 0) { + print(".0E-12 is ", .0E-12, "\n") + } + if !close(+.01e23, 1, 100, 23) { + print("+.01e23 is ", +.01e23, "\n") + } + if !close(-.012e34, -12, 1000, 34) { + print("-.012e34 is ", -.012e34, "\n") + } - if !close(0.0E12, 0, 1, 12) { print("0.0E12 is ", 0.0E12, "\n"); } - if !close(+10.01e23, 1001, 100, 23) { print("+10.01e23 is ", +10.01e23, "\n"); } - if !close(-210.012e33, -210012, 1000, 33) { print("-210.012e33 is ", -210.012e33, "\n"); } + if !close(0.0E12, 0, 1, 12) { + print("0.0E12 is ", 0.0E12, "\n") + } + if !close(+10.01e23, 1001, 100, 23) { + print("+10.01e23 is ", +10.01e23, "\n") + } + if !close(-210.012e33, -210012, 1000, 33) { + print("-210.012e33 is ", -210.012e33, "\n") + } - if !close(0.E123, 0, 1, 123) { print("0.E123 is ", 0.E123, "\n"); } - if !close(+10.e+23, 10, 1, 23) { print("+10.e+234 is ", +10.e+234, "\n"); } - if !close(-210.e-35, -210, 1, -35) { print("-210.e-35 is ", -210.e-35, "\n"); } + if !close(0.E123, 0, 1, 123) { + print("0.E123 is ", 0.E123, "\n") + } + if !close(+10.e+23, 10, 1, 23) { + print("+10.e+234 is ", +10.e+234, "\n") + } + if !close(-210.e-35, -210, 1, -35) { + print("-210.e-35 is ", -210.e-35, "\n") + } - if !close(.0E123, 0, 1, 123) { print(".0E123 is ", .0E123, "\n"); } - if !close(+.01e29, 1, 100, 29) { print("+.01e29 is ", +.01e29, "\n"); } - if !close(-.012e29, -12, 1000, 29) { print("-.012e29 is ", -.012e29, "\n"); } + if !close(.0E123, 0, 1, 123) { + print(".0E123 is ", .0E123, "\n") + } + if !close(+.01e29, 1, 100, 29) { + print("+.01e29 is ", +.01e29, "\n") + } + if !close(-.012e29, -12, 1000, 29) { + print("-.012e29 is ", -.012e29, "\n") + } - if !close(0.0E123, 0, 1, 123) { print("0.0E123 is ", 0.0E123, "\n"); } - if !close(+10.01e31, 1001, 100, 31) { print("+10.01e31 is ", +10.01e31, "\n"); } - if !close(-210.012e19, -210012, 1000, 19) { print("-210.012e19 is ", -210.012e19, "\n"); } + if !close(0.0E123, 0, 1, 123) { + print("0.0E123 is ", 0.0E123, "\n") + } + if !close(+10.01e31, 1001, 100, 31) { + print("+10.01e31 is ", +10.01e31, "\n") + } + if !close(-210.012e19, -210012, 1000, 19) { + print("-210.012e19 is ", -210.012e19, "\n") + } } diff --git a/gcc/testsuite/go.test/test/garbage/Makefile b/gcc/testsuite/go.test/test/garbage/Makefile index ab29e0956c0..e8338438265 100644 --- a/gcc/testsuite/go.test/test/garbage/Makefile +++ b/gcc/testsuite/go.test/test/garbage/Makefile @@ -11,8 +11,8 @@ ALL=\ all: $(addsuffix .out, $(ALL)) -%.$O: %.go - $(GC) $*.go +%.$O: %.go stats.go + $(GC) $*.go stats.go %.out: %.$O $(LD) -o $@ $*.$O diff --git a/gcc/testsuite/go.test/test/garbage/parser.go b/gcc/testsuite/go.test/test/garbage/parser.go index cf68737fb2f..19a96bc63bd 100644 --- a/gcc/testsuite/go.test/test/garbage/parser.go +++ b/gcc/testsuite/go.test/test/garbage/parser.go @@ -11,13 +11,19 @@ import ( "fmt" "go/ast" "go/parser" + "go/token" "os" "path" "runtime" "strings" "time" + "http" + _ "http/pprof" + "log" ) +var serve = flag.String("serve", "", "serve http on this address at end") + func isGoFile(dir *os.FileInfo) bool { return dir.IsRegular() && !strings.HasPrefix(dir.Name, ".") && // ignore .files @@ -30,7 +36,7 @@ func isPkgFile(dir *os.FileInfo) bool { } func pkgName(filename string) string { - file, err := parser.ParseFile(filename, nil, parser.PackageClauseOnly) + file, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.PackageClauseOnly) if err != nil || file == nil { return "" } @@ -58,7 +64,7 @@ func parseDir(dirpath string) map[string]*ast.Package { } // get package AST - pkgs, err := parser.ParseDir(dirpath, filter, parser.ParseComments) + pkgs, err := parser.ParseDir(token.NewFileSet(), dirpath, filter, parser.ParseComments) if err != nil { println("parse", dirpath, err.String()) panic("fail") @@ -67,12 +73,19 @@ func parseDir(dirpath string) map[string]*ast.Package { } func main() { + runtime.GOMAXPROCS(4) + go func() {}() + go func() {}() + go func() {}() st := &runtime.MemStats + packages = append(packages, packages...) + packages = append(packages, packages...) n := flag.Int("n", 4, "iterations") p := flag.Int("p", len(packages), "# of packages to keep in memory") flag.BoolVar(&st.DebugGC, "d", st.DebugGC, "print GC debugging info (pause times)") flag.Parse() + var lastParsed []map[string]*ast.Package var t0 int64 pkgroot := runtime.GOROOT() + "/src/pkg/" for pass := 0; pass < 2; pass++ { @@ -81,7 +94,7 @@ func main() { // than the normal pauses and would otherwise make // the average look much better than it actually is. st.NumGC = 0 - st.PauseNs = 0 + st.PauseTotalNs = 0 t0 = time.Nanoseconds() for i := 0; i < *n; i++ { @@ -89,25 +102,34 @@ func main() { for j := range parsed { parsed[j] = parseDir(pkgroot + packages[j%len(packages)]) } + if i+1 == *n && *serve != "" { + lastParsed = parsed + } } runtime.GC() + runtime.GC() } t1 := time.Nanoseconds() fmt.Printf("Alloc=%d/%d Heap=%d Mallocs=%d PauseTime=%.3f/%d = %.3f\n", st.Alloc, st.TotalAlloc, st.Sys, - st.Mallocs, float64(st.PauseNs)/1e9, - st.NumGC, float64(st.PauseNs)/1e9/float64(st.NumGC)) - - fmt.Printf("%10s %10s %10s\n", "size", "#alloc", "#free") - for _, s := range st.BySize { - fmt.Printf("%10d %10d %10d\n", s.Size, s.Mallocs, s.Frees) - } + st.Mallocs, float64(st.PauseTotalNs)/1e9, + st.NumGC, float64(st.PauseTotalNs)/1e9/float64(st.NumGC)) + /* + fmt.Printf("%10s %10s %10s\n", "size", "#alloc", "#free") + for _, s := range st.BySize { + fmt.Printf("%10d %10d %10d\n", s.Size, s.Mallocs, s.Frees) + } + */ // Standard gotest benchmark output, collected by build dashboard. - fmt.Printf("garbage.BenchmarkParser %d %d ns/op\n", *n, (t1-t0)/int64(*n)) - fmt.Printf("garbage.BenchmarkParserPause %d %d ns/op\n", st.NumGC, int64(st.PauseNs)/int64(st.NumGC)) + gcstats("BenchmarkParser", *n, t1-t0) + + if *serve != "" { + log.Fatal(http.ListenAndServe(*serve, nil)) + println(lastParsed) + } } @@ -183,7 +205,6 @@ var packages = []string{ "math", "mime", "net", - "nntp", "os", "os/signal", "patch", @@ -195,6 +216,7 @@ var packages = []string{ "runtime", "scanner", "sort", + "smtp", "strconv", "strings", "sync", diff --git a/gcc/testsuite/go.test/test/garbage/peano.go b/gcc/testsuite/go.test/test/garbage/peano.go index b026354e8c1..b4d31856126 100644 --- a/gcc/testsuite/go.test/test/garbage/peano.go +++ b/gcc/testsuite/go.test/test/garbage/peano.go @@ -123,7 +123,6 @@ func verify() { func main() { - st := &runtime.MemStats t0 := time.Nanoseconds() verify() for i := 0; i <= 9; i++ { @@ -132,6 +131,5 @@ func main() { runtime.GC() t1 := time.Nanoseconds() - fmt.Printf("garbage.BenchmarkPeano 1 %d ns/op\n", t1-t0) - fmt.Printf("garbage.BenchmarkPeanoPause %d %d ns/op\n", st.NumGC, int64(st.PauseNs)/int64(st.NumGC)) + gcstats("BenchmarkPeano", 1, t1-t0) } diff --git a/gcc/testsuite/go.test/test/garbage/stats.go b/gcc/testsuite/go.test/test/garbage/stats.go new file mode 100644 index 00000000000..474e6ad4abc --- /dev/null +++ b/gcc/testsuite/go.test/test/garbage/stats.go @@ -0,0 +1,44 @@ +// 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" + "runtime" + "sort" +) + +func gcstats(name string, n int, t int64) { + st := &runtime.MemStats + fmt.Printf("garbage.%sMem Alloc=%d/%d Heap=%d NextGC=%d Mallocs=%d\n", name, st.Alloc, st.TotalAlloc, st.Sys, st.NextGC, st.Mallocs) + fmt.Printf("garbage.%s %d %d ns/op\n", name, n, t/int64(n)) + fmt.Printf("garbage.%sLastPause 1 %d ns/op\n", name, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))]) + fmt.Printf("garbage.%sPause %d %d ns/op\n", name, st.NumGC, int64(st.PauseTotalNs)/int64(st.NumGC)) + nn := int(st.NumGC) + if nn >= len(st.PauseNs) { + nn = len(st.PauseNs) + } + t1, t2, t3, t4, t5 := tukey5(st.PauseNs[0:nn]) + fmt.Printf("garbage.%sPause5: %d %d %d %d %d\n", name, t1, t2, t3, t4, t5) + +// fmt.Printf("garbage.%sScan: %v\n", name, st.ScanDist) +} + +type T []uint64 +func (t T) Len() int { return len(t) } +func (t T) Swap(i, j int) { t[i], t[j] = t[j], t[i] } +func (t T) Less(i, j int) bool { return t[i] < t[j] } + +func tukey5(raw []uint64) (lo, q1, q2, q3, hi uint64) { + x := make(T, len(raw)) + copy(x, raw) + sort.Sort(T(x)) + lo = x[0] + q1 = x[len(x)/4] + q2 = x[len(x)/2] + q3 = x[len(x)*3/4] + hi = x[len(x)-1] + return +} diff --git a/gcc/testsuite/go.test/test/garbage/tree.go b/gcc/testsuite/go.test/test/garbage/tree.go index 816693fbebf..c5eae9760f2 100644 --- a/gcc/testsuite/go.test/test/garbage/tree.go +++ b/gcc/testsuite/go.test/test/garbage/tree.go @@ -39,7 +39,6 @@ package main import ( "flag" "fmt" - "runtime" "time" ) @@ -95,10 +94,7 @@ func main() { fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck()) t1 := time.Nanoseconds() - st := &runtime.MemStats // Standard gotest benchmark output, collected by build dashboard. - fmt.Printf("garbage.BenchmarkTree %d %d ns/op\n", *n, (t1-t0)/int64(*n)) - fmt.Printf("garbage.BenchmarkTreePause %d %d ns/op\n", st.NumGC, int64(st.PauseNs)/int64(st.NumGC)) - + gcstats("BenchmarkTree", *n, t1-t0) } diff --git a/gcc/testsuite/go.test/test/golden-arm.out b/gcc/testsuite/go.test/test/golden-arm.out deleted file mode 100644 index 41829fb0360..00000000000 --- a/gcc/testsuite/go.test/test/golden-arm.out +++ /dev/null @@ -1,131 +0,0 @@ - -=========== ./cmp2.go -panic: runtime error: comparing uncomparable type []int - -panic PC=xxx - -=========== ./cmp3.go -panic: runtime error: comparing uncomparable type []int - -panic PC=xxx - -=========== ./cmp4.go -panic: runtime error: hash of unhashable type []int - -panic PC=xxx - -=========== ./cmp5.go -panic: runtime error: hash of unhashable type []int - -panic PC=xxx - -=========== ./deferprint.go -printing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -42 true false true +1.500000e+000 world 0x0 [0/0]0x0 0x0 0x0 255 - -=========== ./helloworld.go -hello, world - -=========== ./peano.go -0! = 1 -1! = 1 -2! = 2 -3! = 6 -4! = 24 -5! = 120 -6! = 720 -7! = 5040 -8! = 40320 -9! = 362880 - -=========== ./printbig.go --9223372036854775808 -9223372036854775807 - -=========== ./sigchld.go -survived SIGCHLD - -=========== ./sinit.go -FAIL - -=========== ./turing.go -Hello World! - -=========== ken/intervar.go - print 1 bio 2 file 3 -- abc - -=========== ken/label.go -100 - -=========== ken/rob1.go -9876543210 - -=========== ken/rob2.go -(defn foo (add 12 34)) - -=========== ken/simpprint.go -hello world - -=========== ken/simpswitch.go -0out01out12out2aout34out4fiveout56out6aout78out89out9 - -=========== ken/string.go -abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz - -=========== chan/doubleselect.go -PASS - -=========== chan/nonblock.go -PASS - -=========== interface/fail.go -panic: interface conversion: *main.S is not main.I: missing method Foo - -panic PC=xxx - -=========== interface/returntype.go -panic: interface conversion: *main.S is not main.I2: missing method Name - -panic PC=xxx - -=========== fixedbugs/bug016.go -fixedbugs/bug016.go:11: constant -3 overflows uint - -=========== fixedbugs/bug027.go -hi -0 44444 -1 3333 -2 222 -3 11 -4 0 -0 44444 -1 3333 -2 222 -3 11 -4 0 - -=========== fixedbugs/bug067.go -ok - -=========== fixedbugs/bug070.go -outer loop top k 0 -inner loop top i 0 -do break -broke - -=========== fixedbugs/bug081.go -fixedbugs/bug081.go:9: typechecking loop - -=========== fixedbugs/bug093.go -M - -=========== fixedbugs/bug113.go -panic: interface conversion: interface is int, not int32 - -panic PC=xxx - -=========== fixedbugs/bug148.go -2 3 -panic: interface conversion: interface is main.T, not main.T - -panic PC=xxx diff --git a/gcc/testsuite/go.test/test/golden.out b/gcc/testsuite/go.test/test/golden.out index 49bca4b874b..cc699d4500e 100644 --- a/gcc/testsuite/go.test/test/golden.out +++ b/gcc/testsuite/go.test/test/golden.out @@ -4,22 +4,18 @@ =========== ./cmp2.go panic: runtime error: comparing uncomparable type []int -panic PC=xxx =========== ./cmp3.go panic: runtime error: comparing uncomparable type []int -panic PC=xxx =========== ./cmp4.go panic: runtime error: hash of unhashable type []int -panic PC=xxx =========== ./cmp5.go panic: runtime error: hash of unhashable type []int -panic PC=xxx =========== ./deferprint.go printing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 @@ -64,7 +60,6 @@ Hello World! =========== ken/cplx3.go (+1.292308e+000-1.384615e-001i) (+1.292308e+000-1.384615e-001i) -64 =========== ken/cplx4.go c = (-5.000000-6.000000i) @@ -117,12 +112,10 @@ PASS =========== interface/fail.go panic: interface conversion: *main.S is not main.I: missing method Foo -panic PC=xxx =========== interface/returntype.go panic: interface conversion: *main.S is not main.I2: missing method Name -panic PC=xxx == nilptr/ @@ -130,9 +123,6 @@ panic PC=xxx == fixedbugs/ -=========== fixedbugs/bug016.go -fixedbugs/bug016.go:11: constant -3 overflows uint - =========== fixedbugs/bug027.go hi 0 44444 @@ -155,25 +145,25 @@ inner loop top i 0 do break broke -=========== fixedbugs/bug081.go -fixedbugs/bug081.go:9: typechecking loop - =========== fixedbugs/bug093.go M =========== fixedbugs/bug113.go panic: interface conversion: interface is int, not int32 -panic PC=xxx =========== fixedbugs/bug148.go 2 3 panic: interface conversion: interface is main.T, not main.T -panic PC=xxx == bugs/ -=========== bugs/bug260.go -FAIL -BUG: bug260 failed +=========== bugs/bug322.go +bugs/bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver +bugs/bug322.dir/main.go:22: implicit assignment of unexported field 'x' of lib.T in assignment +bugs/bug322.dir/main.go:31: implicit assignment of unexported field 'x' of lib.T in method receiver +BUG: fails incorrectly + +=========== bugs/bug324.go +BUG: errchk: command succeeded unexpectedly diff --git a/gcc/testsuite/go.test/test/index.go b/gcc/testsuite/go.test/test/index.go index a91294cffbb..38aa33dd305 100644 --- a/gcc/testsuite/go.test/test/index.go +++ b/gcc/testsuite/go.test/test/index.go @@ -1,8 +1,8 @@ // $G $D/$F.go && $L $F.$A && -// ./$A.out -pass 0 >tmp.go && $G tmp.go && $L -o tmp1.$A tmp.$A && ./tmp1.$A && +// ./$A.out -pass 0 >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1 && // ./$A.out -pass 1 >tmp.go && errchk $G -e tmp.go && // ./$A.out -pass 2 >tmp.go && errchk $G -e tmp.go -// rm -f tmp.go +// rm -f tmp.go $A.out1 // 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/init.go b/gcc/testsuite/go.test/test/init.go new file mode 100644 index 00000000000..74c2d5c2614 --- /dev/null +++ b/gcc/testsuite/go.test/test/init.go @@ -0,0 +1,18 @@ +// errchk $G -e $D/$F.go + +// 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 + +import "runtime" + +func init() { +} + +func main() { + init() // ERROR "undefined.*init" + runtime.init() // ERROR "unexported.*runtime\.init" + var _ = init // ERROR "undefined.*init" +} diff --git a/gcc/testsuite/go.test/test/interface/embed2.go b/gcc/testsuite/go.test/test/interface/embed2.go new file mode 100644 index 00000000000..c18a1fecec2 --- /dev/null +++ b/gcc/testsuite/go.test/test/interface/embed2.go @@ -0,0 +1,70 @@ +// errchk $G -e $D/$F.go + +// 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. + +// Check methods derived from embedded interface and *interface values. + +package main + +import "os" + +const Value = 1e12 + +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 } +var ps = &s + +type SP struct { *Inter } // ERROR "interface" + +var i Inter +var pi = &i + +var ok = true + +func check(s string, v int64) { + if v != Value { + println(s, v) + ok = false + } +} + +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("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" + + i = pt + check("i = pt; i.M()", i.M()) + check("i = pt; pi.M()", pi.M()) // ERROR "method" + + i = s + check("i = s; i.M()", i.M()) + check("i = s; pi.M()", pi.M()) // ERROR "method" + + i = ps + check("i = ps; i.M()", i.M()) + check("i = ps; pi.M()", pi.M()) // ERROR "method" + + if !ok { + println("BUG: interface10") + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/ken/convert.go b/gcc/testsuite/go.test/test/ken/convert.go new file mode 100644 index 00000000000..3780ec886a4 --- /dev/null +++ b/gcc/testsuite/go.test/test/ken/convert.go @@ -0,0 +1,431 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// 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. + +// near-exhaustive test of converting numbers between types. + +package main + +var i8 int8; +var u8 uint8; +var i16 int16; +var u16 uint16; +var i32 int32; +var u32 uint32; +var i64 int64; +var u64 uint64; +var f32 float32; +var f64 float64; + +type big float64 + +type t struct { + from, to int + val big +} + +const ( + ti8 = iota+1 + tu8 + ti16 + tu16 + ti32 + tu32 + ti64 + tu64 + tf32 + tf64 +) + +var x = []t{ + + /* value good in all types (10) */ + { ti8, ti8, 10 }, { ti8, tu8, 10 }, { ti8, ti16, 10 }, { ti8, tu16, 10 }, + { ti8, ti32, 10 }, { ti8, tu32, 10 }, { ti8, ti64, 10 }, { ti8, tu64, 10 }, + { ti8, tf32, 10 }, { ti8, tf64, 10 }, + + { tu8, ti8, 10 }, { tu8, tu8, 10 }, { tu8, ti16, 10 }, { tu8, tu16, 10 }, + { tu8, ti32, 10 }, { tu8, tu32, 10 }, { tu8, ti64, 10 }, { tu8, tu64, 10 }, + { tu8, tf32, 10 }, { tu8, tf64, 10 }, + + { ti16, ti8, 10 }, { ti16, tu8, 10 }, { ti16, ti16, 10 }, { ti16, tu16, 10 }, + { ti16, ti32, 10 }, { ti16, tu32, 10 }, { ti16, ti64, 10 }, { ti16, tu64, 10 }, + { ti16, tf32, 10 }, { ti16, tf64, 10 }, + + { tu16, ti8, 10 }, { tu16, tu8, 10 }, { tu16, ti16, 10 }, { tu16, tu16, 10 }, + { tu16, ti32, 10 }, { tu16, tu32, 10 }, { tu16, ti64, 10 }, { tu16, tu64, 10 }, + { tu16, tf32, 10 }, { tu16, tf64, 10 }, + + { ti32, ti8, 10 }, { ti32, tu8, 10 }, { ti32, ti16, 10 }, { ti32, tu16, 10 }, + { ti32, ti32, 10 }, { ti32, tu32, 10 }, { ti32, ti64, 10 }, { ti32, tu64, 10 }, + { ti32, tf32, 10 }, { ti32, tf64, 10 }, + + { tu32, ti8, 10 }, { tu32, tu8, 10 }, { tu32, ti16, 10 }, { tu32, tu16, 10 }, + { tu32, ti32, 10 }, { tu32, tu32, 10 }, { tu32, ti64, 10 }, { tu32, tu64, 10 }, + { tu32, tf32, 10 }, { tu32, tf64, 10 }, + + { ti64, ti8, 10 }, { ti64, tu8, 10 }, { ti64, ti16, 10 }, { ti64, tu16, 10 }, + { ti64, ti32, 10 }, { ti64, tu32, 10 }, { ti64, ti64, 10 }, { ti64, tu64, 10 }, + { ti64, tf32, 10 }, { ti64, tf64, 10 }, + + { tu64, ti8, 10 }, { tu64, tu8, 10 }, { tu64, ti16, 10 }, { tu64, tu16, 10 }, + { tu64, ti32, 10 }, { tu64, tu32, 10 }, { tu64, ti64, 10 }, { tu64, tu64, 10 }, + { tu64, tf32, 10 }, { tu64, tf64, 10 }, + + { tf32, ti8, 10 }, { tf32, tu8, 10 }, { tf32, ti16, 10 }, { tf32, tu16, 10 }, + { tf32, ti32, 10 }, { tf32, tu32, 10 }, { tf32, ti64, 10 }, { tf32, tu64, 10 }, + { tf32, tf32, 10 }, { tf32, tf64, 10 }, + + { tf64, ti8, 10 }, { tf64, tu8, 10 }, { tf64, ti16, 10 }, { tf64, tu16, 10 }, + { tf64, ti32, 10 }, { tf64, tu32, 10 }, { tf64, ti64, 10 }, { tf64, tu64, 10 }, + { tf64, tf32, 10 }, { tf64, tf64, 10 }, + + /* value good in all signed types (-4) */ + { ti8, ti8, -4 }, { ti8, ti16, -4 }, + { ti8, ti32, -4 }, { ti8, ti64, -4 }, + { ti8, tf32, -4 }, { ti8, tf64, -4 }, + + { ti16, ti8, -4 }, { ti16, ti16, -4 }, + { ti16, ti32, -4 }, { ti16, ti64, -4 }, + { ti16, tf32, -4 }, + + { ti32, ti8, -4 }, { ti32, ti16, -4 }, + { ti32, ti32, -4 }, { ti32, ti64, -4 }, + { ti32, tf32, -4 }, { ti32, tf64, -4 }, + + { ti64, ti8, -4 }, { ti64, ti16, -4 }, + { ti64, ti32, -4 }, { ti64, ti64, -4 }, + { ti64, tf32, -4 }, + + { tf32, ti8, -4 }, { tf32, ti16, -4 }, + { tf32, ti32, -4 }, { tf32, ti64, -4 }, + { tf32, tf32, -4 }, + + { tf64, ti8, -4 }, { tf64, ti16, -4 }, + { tf64, ti32, -4 }, { tf64, ti64, -4 }, + { tf64, tf32, -4 }, { tf64, tf64, -4 }, + + /* value good in u8 and up (175) */ + { tu8, tu8, 175 }, { tu8, ti16, 175 }, { tu8, tu16, 175 }, + { tu8, ti32, 175 }, { tu8, tu32, 175 }, { tu8, ti64, 175 }, { tu8, tu64, 175 }, + { tu8, tf32, 175 }, { tu8, tf64, 175 }, + + { ti16, tu8, 175 }, { ti16, ti16, 175 }, { ti16, tu16, 175 }, + { ti16, ti32, 175 }, { ti16, tu32, 175 }, { ti16, ti64, 175 }, { ti16, tu64, 175 }, + { ti16, tf32, 175 }, { ti16, tf64, 175 }, + + { tu16, tu8, 175 }, { tu16, ti16, 175 }, { tu16, tu16, 175 }, + { tu16, ti32, 175 }, { tu16, tu32, 175 }, { tu16, ti64, 175 }, { tu16, tu64, 175 }, + { tu16, tf32, 175 }, { tu16, tf64, 175 }, + + { ti32, tu8, 175 }, { ti32, ti16, 175 }, { ti32, tu16, 175 }, + { ti32, ti32, 175 }, { ti32, tu32, 175 }, { ti32, ti64, 175 }, { ti32, tu64, 175 }, + { ti32, tf32, 175 }, { ti32, tf64, 175 }, + + { tu32, tu8, 175 }, { tu32, ti16, 175 }, { tu32, tu16, 175 }, + { tu32, ti32, 175 }, { tu32, tu32, 175 }, { tu32, ti64, 175 }, { tu32, tu64, 175 }, + { tu32, tf32, 175 }, { tu32, tf64, 175 }, + + { ti64, tu8, 175 }, { ti64, ti16, 175 }, { ti64, tu16, 175 }, + { ti64, ti32, 175 }, { ti64, tu32, 175 }, { ti64, ti64, 175 }, { ti64, tu64, 175 }, + { ti64, tf32, 175 }, { ti64, tf64, 175 }, + + { tu64, tu8, 175 }, { tu64, ti16, 175 }, { tu64, tu16, 175 }, + { tu64, ti32, 175 }, { tu64, tu32, 175 }, { tu64, ti64, 175 }, { tu64, tu64, 175 }, + { tu64, tf32, 175 }, { tu64, tf64, 175 }, + + { tf32, tu8, 175 }, { tf32, ti16, 175 }, { tf32, tu16, 175 }, + { tf32, ti32, 175 }, { tf32, tu32, 175 }, { tf32, ti64, 175 }, { tf32, tu64, 175 }, + { tf32, tf32, 175 }, { tf32, tf64, 175 }, + + { tf64, tu8, 175 }, { tf64, ti16, 175 }, { tf64, tu16, 175 }, + { tf64, ti32, 175 }, { tf64, tu32, 175 }, { tf64, ti64, 175 }, { tf64, tu64, 175 }, + { tf64, tf32, 175 }, { tf64, tf64, 175 }, + + /* value good in u16 and up (41259) */ + { tu16, tu16, 41259 }, + { tu16, ti32, 41259 }, { tu16, ti64, 41259 }, { tu16, tu64, 41259 }, + { tu16, tf32, 41259 }, { tu16, tf64, 41259 }, + + { ti32, tu16, 41259 }, + { ti32, ti32, 41259 }, { ti32, tu32, 41259 }, { ti32, ti64, 41259 }, { ti32, tu64, 41259 }, + { ti32, tf32, 41259 }, { ti32, tf64, 41259 }, + + { tu32, tu16, 41259 }, + { tu32, ti32, 41259 }, { tu32, tu32, 41259 }, { tu32, ti64, 41259 }, { tu32, tu64, 41259 }, + { tu32, tf32, 41259 }, { tu32, tf64, 41259 }, + + { ti64, tu16, 41259 }, + { ti64, ti32, 41259 }, { ti64, tu32, 41259 }, { ti64, ti64, 41259 }, { ti64, tu64, 41259 }, + { ti64, tf32, 41259 }, { ti64, tf64, 41259 }, + + { tu64, tu16, 41259 }, + { tu64, ti32, 41259 }, { tu64, tu32, 41259 }, { tu64, ti64, 41259 }, { tu64, tu64, 41259 }, + { tu64, tf32, 41259 }, { tu64, tf64, 41259 }, + + { tf32, tu16, 41259 }, + { tf32, ti32, 41259 }, { tf32, tu32, 41259 }, { tf32, ti64, 41259 }, { tf32, tu64, 41259 }, + { tf32, tf32, 41259 }, { tf32, tf64, 41259 }, + + { tf64, tu16, 41259 }, + { tf64, ti32, 41259 }, { tf64, tu32, 41259 }, { tf64, ti64, 41259 }, { tf64, tu64, 41259 }, + { tf64, tf32, 41259 }, { tf64, tf64, 41259 }, + + /* value good in u32 and up (3758096384) */ + { tu32, tu32, 3758096384 }, { tu32, ti64, 3758096384 }, { tu32, tu64, 3758096384 }, + { tu32, tf32, 3758096384 }, { tu32, tf64, 3758096384 }, + + { ti64, tu32, 3758096384 }, { ti64, ti64, 3758096384 }, { ti64, tu64, 3758096384 }, + { ti64, tf32, 3758096384 }, { ti64, tf64, 3758096384 }, + + { tu64, tu32, 3758096384 }, { tu64, ti64, 3758096384 }, { tu64, tu64, 3758096384 }, + { tu64, tf32, 3758096384 }, { tu64, tf64, 3758096384 }, + + { tf32, tu32, 3758096384 }, { tf32, ti64, 3758096384 }, { tf32, tu64, 3758096384 }, + { tf32, tf32, 3758096384 }, { tf32, tf64, 3758096384 }, + + { tf64, tu32, 3758096384 }, { tf64, ti64, 3758096384 }, { tf64, tu64, 3758096384 }, + { tf64, tf32, 3758096384 }, { tf64, tf64, 3758096384 }, + + /* value good in u64 and up (16717361816799281152) */ + { tu64, tu64, 16717361816799281152 }, + { tu64, tf32, 16717361816799281152 }, { tu64, tf64, 16717361816799281152 }, + + { tf32, tu64, 16717361816799281152 }, + { tf32, tf32, 16717361816799281152 }, { tf32, tf64, 16717361816799281152 }, + + { tf64, tu64, 16717361816799281152 }, + { tf64, tf32, 16717361816799281152 }, { tf64, tf64, 16717361816799281152 }, +} + +func main() { + for i:=0; i 10: + if x == 11 { + break L3 + } + if x == 12 { + continue L3 // ERROR "invalid continue label .*L3" + } + goto L3 + } + +L4: + if true { + if x == 13 { + break L4 // ERROR "invalid break label .*L4" + } + if x == 14 { + continue L4 // ERROR "invalid continue label .*L4" + } + if x == 15 { + goto L4 + } + } + +L5: + f() + if x == 16 { + break L5 // ERROR "invalid break label .*L5" + } + if x == 17 { + continue L5 // ERROR "invalid continue label .*L5" + } + if x == 18 { + goto L5 + } + + for { + if x == 19 { + break L1 // ERROR "invalid break label .*L1" + } + if x == 20 { + continue L1 // ERROR "invalid continue label .*L1" + } + if x == 21 { + goto L1 + } + } +} diff --git a/gcc/testsuite/go.test/test/method.go b/gcc/testsuite/go.test/test/method.go index c751c1f1b52..b5a02c6873e 100644 --- a/gcc/testsuite/go.test/test/method.go +++ b/gcc/testsuite/go.test/test/method.go @@ -19,7 +19,7 @@ func (s S) val() int { return 1 } func (s *S1) val() int { return 2 } func (i I) val() int { return 3 } func (i *I1) val() int { return 4 } -//func (t T) val() int { return 7 } +func (t T) val() int { return 7 } func (t *T1) val() int { return 8 } type Val interface { @@ -34,6 +34,8 @@ func main() { var i I var pi *I1 var pt *T1 + var t T + var v Val if s.val() != 1 { println("s.val:", s.val()) @@ -75,7 +77,10 @@ func main() { println("(*I1).val(pi):", (*I1).val(pi)) panic("fail") } - // if t.val() != 7 { prinln("t.val:", t.val()); panic("fail") } + if t.val() != 7 { + println("t.val:", t.val()) + panic("fail") + } if pt.val() != 8 { println("pt.val:", pt.val()) panic("fail") @@ -101,11 +106,22 @@ func main() { println("pi.val:", val(pi)) panic("fail") } - // if val(t) != 7 { println("t.val:", val(t)); panic("fail") } + if val(t) != 7 { + println("t.val:", val(t)) + panic("fail") + } if val(pt) != 8 { println("pt.val:", val(pt)) panic("fail") } - // if Val.val(i) != 3 { println("Val.val(i):", Val.val(i)); panic("fail") } + if Val.val(i) != 3 { + println("Val.val(i):", Val.val(i)) + panic("fail") + } + v = i + if Val.val(v) != 3 { + println("Val.val(v):", Val.val(v)) + panic("fail") + } } diff --git a/gcc/testsuite/go.test/test/method2.go b/gcc/testsuite/go.test/test/method2.go index 3ee0ae1364f..a72536e7b33 100644 --- a/gcc/testsuite/go.test/test/method2.go +++ b/gcc/testsuite/go.test/test/method2.go @@ -6,9 +6,22 @@ package main -type T struct {a int} +type T struct { + a int +} type P *T type P1 *T -func (p P) val() int { return 1 } // ERROR "receiver" -func (p *P1) val() int { return 1 } // ERROR "receiver" +func (p P) val() int { return 1 } // ERROR "receiver" +func (p *P1) val() int { return 1 } // ERROR "receiver" + +type Val interface { + val() int +} + +var _ = (*Val).val // ERROR "method" + +var v Val +var pv = &v + +var _ = pv.val() // ERROR "method" diff --git a/gcc/testsuite/go.test/test/nilptr/arrayindex.go b/gcc/testsuite/go.test/test/nilptr/arrayindex.go index c564bce3404..fa26532c67b 100644 --- a/gcc/testsuite/go.test/test/nilptr/arrayindex.go +++ b/gcc/testsuite/go.test/test/nilptr/arrayindex.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/arrayindex1.go b/gcc/testsuite/go.test/test/nilptr/arrayindex1.go index 701630ed150..64f46e14d19 100644 --- a/gcc/testsuite/go.test/test/nilptr/arrayindex1.go +++ b/gcc/testsuite/go.test/test/nilptr/arrayindex1.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/arraytoslice.go b/gcc/testsuite/go.test/test/nilptr/arraytoslice.go index 38206d50b8e..03879fb42f7 100644 --- a/gcc/testsuite/go.test/test/nilptr/arraytoslice.go +++ b/gcc/testsuite/go.test/test/nilptr/arraytoslice.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/arraytoslice1.go b/gcc/testsuite/go.test/test/nilptr/arraytoslice1.go index 8c9531e1763..c86070fa473 100644 --- a/gcc/testsuite/go.test/test/nilptr/arraytoslice1.go +++ b/gcc/testsuite/go.test/test/nilptr/arraytoslice1.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/arraytoslice2.go b/gcc/testsuite/go.test/test/nilptr/arraytoslice2.go index 1b2651381ef..68ea44083cb 100644 --- a/gcc/testsuite/go.test/test/nilptr/arraytoslice2.go +++ b/gcc/testsuite/go.test/test/nilptr/arraytoslice2.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/slicearray.go b/gcc/testsuite/go.test/test/nilptr/slicearray.go index 544536cc7ce..26ca4277328 100644 --- a/gcc/testsuite/go.test/test/nilptr/slicearray.go +++ b/gcc/testsuite/go.test/test/nilptr/slicearray.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/structfield.go b/gcc/testsuite/go.test/test/nilptr/structfield.go index e081f7a1718..35196bb68dd 100644 --- a/gcc/testsuite/go.test/test/nilptr/structfield.go +++ b/gcc/testsuite/go.test/test/nilptr/structfield.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/structfield1.go b/gcc/testsuite/go.test/test/nilptr/structfield1.go index 02d33a42c24..7c7abed1aa0 100644 --- a/gcc/testsuite/go.test/test/nilptr/structfield1.go +++ b/gcc/testsuite/go.test/test/nilptr/structfield1.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/structfield2.go b/gcc/testsuite/go.test/test/nilptr/structfield2.go index 4323b42b4db..02a44f17318 100644 --- a/gcc/testsuite/go.test/test/nilptr/structfield2.go +++ b/gcc/testsuite/go.test/test/nilptr/structfield2.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nilptr/structfieldaddr.go b/gcc/testsuite/go.test/test/nilptr/structfieldaddr.go index 81551aa3bad..f3177bafbaa 100644 --- a/gcc/testsuite/go.test/test/nilptr/structfieldaddr.go +++ b/gcc/testsuite/go.test/test/nilptr/structfieldaddr.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # do not bother on NaCl // $G $D/$F.go && $L $F.$A && // ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail) diff --git a/gcc/testsuite/go.test/test/nul1.go b/gcc/testsuite/go.test/test/nul1.go index 9d6974f818b..9cf51125bcc 100644 --- a/gcc/testsuite/go.test/test/nul1.go +++ b/gcc/testsuite/go.test/test/nul1.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # NaCl runner elides NUL in output // [ "$GORUN" == "" ] || exit 0 # Android runner gets confused by the NUL output // $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go && // errchk $G -e tmp.go diff --git a/gcc/testsuite/go.test/test/recover3.go b/gcc/testsuite/go.test/test/recover3.go index b982ec8fa54..2aa1df616dc 100644 --- a/gcc/testsuite/go.test/test/recover3.go +++ b/gcc/testsuite/go.test/test/recover3.go @@ -1,4 +1,3 @@ -// [ $GOOS != nacl ] || exit 0 # NaCl cannot recover from signals // $G $D/$F.go && $L $F.$A && ./$A.out // Copyright 2010 The Go Authors. All rights reserved. @@ -10,7 +9,6 @@ package main import ( "runtime" "strings" - "syscall" ) var didbug bool @@ -44,7 +42,7 @@ func check(name string, f func(), err string) { return } }() - + f() } @@ -55,11 +53,8 @@ func main() { var q *[10000]int var i int - // not catching divide by zero on the arm. is that even possible? - if syscall.ARCH != "arm" { - check("int-div-zero", func() { println(1/x) }, "integer divide by zero") - check("int64-div-zero", func() { println(1/x64) }, "integer divide by zero") - } + check("int-div-zero", func() { println(1 / x) }, "integer divide by zero") + check("int64-div-zero", func() { println(1 / x64) }, "integer divide by zero") check("nil-deref", func() { println(p[0]) }, "nil pointer dereference") check("nil-deref-1", func() { println(p[1]) }, "nil pointer dereference") @@ -69,11 +64,13 @@ func main() { var sl []int check("array-bounds", func() { println(p[i]) }, "index out of range") check("slice-bounds", func() { println(sl[i]) }, "index out of range") - + var inter interface{} inter = 1 check("type-concrete", func() { println(inter.(string)) }, "int, not string") check("type-interface", func() { println(inter.(m)) }, "missing method m") } -type m interface{ m() } +type m interface { + m() +} diff --git a/gcc/testsuite/go.test/test/run b/gcc/testsuite/go.test/test/run index 4ca77541409..28d0caa0f68 100755 --- a/gcc/testsuite/go.test/test/run +++ b/gcc/testsuite/go.test/test/run @@ -14,7 +14,7 @@ X386) ;; Xarm) export A=5 - export E=${GORUN:-qemu-arm -cpu cortex-a8} + export E="$GORUN" ;; *) echo 1>&2 run: unsupported '$GOARCH' @@ -49,15 +49,25 @@ ulimit -c 0 true >pass.out >times.out +exclude=false # exclude nothing +golden=golden.out + +filterout() { + grep '^'"$2"'$' $1 >/dev/null +} + for dir in . ken chan interface nilptr syntax fixedbugs bugs do echo echo '==' $dir'/' for i in $(ls $dir/*.go 2>/dev/null) - do + do ( + if $exclude $i; then + exit 0 # continues for loop + fi export F=$(basename $i .go) export D=$dir - sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|' >$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 @@ -87,7 +97,7 @@ do echo $i >>pass.out fi echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out - done + ) 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/ @@ -99,12 +109,13 @@ done | # clean up some stack noise /^Trace\/BPT trap/d /RUNFILE/ s/line 1: *[0-9]*/line 1: PID/ /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d + /Fault in NaCl untrusted code/d /Segmentation fault/d /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out -rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out +rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out diffmsg="" -if ! diff golden.out run.out +if ! diff $golden run.out then diffmsg="; test output differs" failed=1 diff --git a/gcc/testsuite/go.test/test/run-arm b/gcc/testsuite/go.test/test/run-arm deleted file mode 100755 index a62df10ca4b..00000000000 --- a/gcc/testsuite/go.test/test/run-arm +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -# 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. - -export E="" -case X"$GOARCH" in -Xamd64) - export A=6 - ;; -X386) - export A=8 - ;; -Xarm) - export A=5 - export E="${GORUN:-qemu-arm -cpu cortex-a8}" - ;; -*) - echo 1>&2 run: unsupported '$GOARCH' - exit 1 -esac - -export G=${A}g -export L=${A}l -export GOTRACEBACK=0 - -PATH=/bin:/usr/bin:/usr/local/bin:${GOBIN:-$GOROOT/bin}:`pwd` - -RUNFILE=/tmp/gorun-$$-$USER -TMP1FILE=/tmp/gotest1-$$-$USER -TMP2FILE=/tmp/gotest2-$$-$USER -FAILEDFILE=/tmp/gotest3-$$-$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 >times.out - -# TODO(kaib): figure out why the GC makes things so utterly slow. -export GOGC=off -export GOTRACEBACK=0 - -for i in $(cat arm-pass.txt | sed 's/#.*//') -do - export F=$(basename $i .go) - dir=$(dirname $i) - export D=$dir - sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|' >$RUNFILE - if ! { time -p bash -c "bash $RUNFILE >$TMP1FILE 2>&1" ; } 2>$TMP2FILE - then - echo - echo "===========" $i - cat $TMP1FILE - echo >&2 fail: $i - touch $FAILEDFILE - elif test -s $TMP1FILE - then - echo - echo "===========" $i - cat $TMP1FILE - elif [ $dir = "bugs" ] - then - echo $i succeeded with no output. - fi - echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out -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/ - /^Trace\/breakpoint trap/d - /^Trace\/BPT trap/d - s!'$GOROOT'!$GOROOT!g - /Segmentation fault/d - /RUNFILE/ s/line 1: *[0-9]*/line 1: PID/ - /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d - /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out - -failed=0 -rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A $A.out -diffmsg="" -if ! diff -b golden-arm.out 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/sigchld.go b/gcc/testsuite/go.test/test/sigchld.go index 09188fc53ac..1fb2e21bd56 100644 --- a/gcc/testsuite/go.test/test/sigchld.go +++ b/gcc/testsuite/go.test/test/sigchld.go @@ -1,4 +1,3 @@ -// if [ $GOOS == nacl ]; then echo survived SIGCHLD; exit 0; fi # NaCl has no signals. // $G $D/$F.go && $L $F.$A && ./$A.out // Copyright 2009 The Go Authors. All rights reserved. diff --git a/gcc/testsuite/go.test/test/stack.go b/gcc/testsuite/go.test/test/stack.go index 816b555a4c8..1fd57161ff2 100644 --- a/gcc/testsuite/go.test/test/stack.go +++ b/gcc/testsuite/go.test/test/stack.go @@ -30,6 +30,32 @@ func d(t T) { } } +func f0() { + // likely to make a new stack for f0, + // because the call to f1 puts 3000 bytes + // in our frame. + f1() +} + +func f1() [3000]byte { + // likely to make a new stack for f1, + // because 3000 bytes were used by f0 + // and we need 3000 more for the call + // to f2. if the call to morestack in f1 + // does not pass the frame size, the new + // stack (default size 5k) will not be big + // enough for the frame, and the morestack + // check in f2 will die, if we get that far + // without faulting. + f2() + return [3000]byte{} +} + +func f2() [3000]byte { + // just take up space + return [3000]byte{} +} + var c = make(chan int) var t T var b = []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} @@ -40,6 +66,7 @@ func recur(n int) { panic("bad []byte -> string") } go g(c, t) + f0() s := <-c if s != len(t) { println("bad go", s) diff --git a/gcc/testsuite/go.test/test/syntax/chan.go b/gcc/testsuite/go.test/test/syntax/chan.go new file mode 100644 index 00000000000..ff3577502f2 --- /dev/null +++ b/gcc/testsuite/go.test/test/syntax/chan.go @@ -0,0 +1,17 @@ +// errchk $G -e $D/$F.go + +// 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 + +type xyz struct { + ch chan +} // ERROR "unexpected .*}.* in channel type" + +func Foo(y chan) { // ERROR "unexpected .*\).* in channel type" +} + +func Bar(x chan, y int) { // ERROR "unexpected comma in channel type" +} diff --git a/gcc/testsuite/go.test/test/syntax/chan1.go b/gcc/testsuite/go.test/test/syntax/chan1.go new file mode 100644 index 00000000000..9c12e5e6fed --- /dev/null +++ b/gcc/testsuite/go.test/test/syntax/chan1.go @@ -0,0 +1,17 @@ +// errchk $G -e $D/$F.go + +// 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 c chan int +var v int + +func main() { + if c <- v { // ERROR "send statement.*value.*select" + } +} + +var _ = c <- v // ERROR "send statement.*value.*select" diff --git a/gcc/testsuite/go.test/test/syntax/if.go b/gcc/testsuite/go.test/test/syntax/if.go new file mode 100644 index 00000000000..a3b51f0c07b --- /dev/null +++ b/gcc/testsuite/go.test/test/syntax/if.go @@ -0,0 +1,18 @@ +// errchk $G $D/$F.go + +// 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 x() { +} + +func main() { + if { // ERROR "missing condition" + } + + if x(); { // ERROR "missing condition" + } +} diff --git a/gcc/testsuite/go.test/test/syntax/typesw.go b/gcc/testsuite/go.test/test/syntax/typesw.go new file mode 100644 index 00000000000..47f683cdf29 --- /dev/null +++ b/gcc/testsuite/go.test/test/syntax/typesw.go @@ -0,0 +1,13 @@ +// errchk $G -e $D/$F.go + +// 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" + default: + } +}