* go.test/go-test.exp: Update for latest version of Go testsuite.
From-SVN: r191858
+2012-09-29 Ian Lance Taylor <iant@google.com>
+
+ * go.test/go-test.exp: Update for latest version of Go testsuite.
+
2012-09-29 Thomas König <tkoenig@gcc.gnu.org>
PR fortran/52724
# D The directory of the test.
#
# Typical command lines:
+# // compile
+# // run
# // $G $D/$F.go && $L $F.$A && ./$A.out
# // $G $D/$F.go && $L $F.$A || echo BUG: known to fail incorrectly
# // $G $D/$F.go && echo BUG: compilation succeeds incorrectly
# frontend ignores the standard options, it doesn't significantly
# improve testing.
set saved_torture_options $TORTURE_OPTIONS
- set TORTURE_OPTIONS [ list { -O2 -g }]
+ set TORTURE_OPTIONS [list { -O2 -g }]
set saved-dg-do-what-default ${dg-do-what-default}
}
}
- if { [string match "*bug347*" $test] \
- || [string match "*bug348*" $test] } {
- # These bugs rely on runtime.Caller which currently fails.
- untested $name
- continue
- }
-
if { [file tail $test] == "init1.go" } {
# This tests whether GC runs during init, which for gccgo
# it currently does not.
continue
}
+ if { [file tail $test] == "rotate.go" } {
+ # This test produces a temporary file that takes too long
+ # to compile--5 minutes on my laptop without optimization.
+ # When compiling without optimization it tests nothing
+ # useful, since the point of the test is to see whether
+ # the compiler generates rotate instructions.
+ untested $name
+ continue
+ }
+
+ if { [file tail $test] == "bug347.go" \
+ || [file tail $test] == "bug348.go" } {
+ # These tests don't work if the functions are inlined.
+ set TORTURE_OPTIONS [list { -O0 -g }]
+ }
+
set fd [open $test r]
set lines_ok 1
}
}
- if { $test_line == "// \$G \$D/\$F\.go && \$L \$F\.\$A && \./\$A\.out >tmp.go &&" \
- && $test_line2 == "// \$G tmp\.go && \$L tmp\.\$A && \./\$A\.out || echo BUG: 64bit" } {
- # 64bit.go is a special case.
+ if { $test_line == "// compile"
+ || $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
+ # This is a vanilla compile test.
+ set dg-do-what-default "assemble"
+ go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
+ } elseif { $test_line == "// run"
+ || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } {
+ # This is a vanilla execution test.
+ go-torture-execute $test
+ file delete core [glob -nocomplain core.*]
+ } elseif { $test_line == "// build" } {
+ # This is a vanilla compile and link test.
+ set dg-do-what-default "link"
+ go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
+ } elseif { $test_line == "// runoutput" \
+ || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
+ && $test_line2 == "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } {
+ # Run the test to get a .go program to run.
set go_execute_args ""
set hold_runtests $runtests
set runtests "go-test.exp"
} else {
pass "$name execution"
file delete $base-out.x
- # Disable optimizations as this test takes a long time
- # to compile.
- set hold $TORTURE_OPTIONS
- set TORTURE_OPTIONS [ list { -O0 -g }]
+ # Disable optimizations as some of these tests
+ # take a long time to compile.
+ set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }]
go-torture-execute "./$base-out.go"
- set TORTURE_OPTIONS $hold
}
file delete $base-out.go
}
file delete $output_file
set runtests $hold_runtests
- } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
- || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" \
- || $test_line == "// \$G \$F.go && \$L \$F.\$A &&./\$A.out" \
- || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && \$A.out" \
- || [string match \
- "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out || echo BUG*" \
- $test_line]
- || [string match \
- "// \$G \$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
- $test_line]
- || [string match \
- "// \$G \$D/\$F.go && \$L \$F.\$A && (./\$A.out || echo BUG*" \
- $test_line]
- || [string match \
- "// \$G \$F.go && \$L \$F.\$A && GOMAXPROCS=* ./\$A.out" \
- $test_line]
- || [string match \
- "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >* || echo BUG*" \
- $test_line] } {
- # This is a vanilla execution test.
- go-torture-execute $test
- file delete core [glob -nocomplain core.*]
- } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
- || $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
- || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
+ } elseif { $test_line == "// cmpout" \
+ || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
# This is an execution test for which we need to check the
# program output.
set hold_runtests $runtests
regsub "\\.go$" $test ".out" expect
filecmp $expect $base.p "$name compare"
}
- #file delete $base.p
+ file delete $base.p
} else {
untested "$name execution"
untested "$name compare"
}
set runtests $hold_runtests
- } elseif { [string match \
- "// \$G \$D/\$F.go && \$L \$F.\$A || echo BUG*" \
- $test_line] \
- || [string match "// \$G \$F.go && \$L \$F.\$A #*" \
- $test_line]
- || $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A" } {
- # This is a vanilla compile and link test.
- set dg-do-what-default "link"
- go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
- } elseif { [string match "// \$G \$D/\$F.go" $test_line] \
- || [string match "// \$G \$D/\$F.go || echo BUG*" \
- $test_line] \
- || [string match "// \$G \$D/\$F.go || echo \"Bug*" \
- $test_line] \
- || [string match "// \$G \$D/\$F.go || echo \"Issue*" \
- $test_line] \
- || [string match "// \$G \$F.go || echo BUG*" \
- $test_line] \
- || [string match "// ! \$G \$D/\$F.go && echo BUG*" \
- $test_line] \
- || $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } {
- # This is a vanilla compile test.
- set dg-do-what-default "assemble"
- go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
- } elseif { [string match "// \$G \$D/\$F.go && echo BUG*" \
- $test_line] \
- || $test_line == "// ! \$G \$D/\$F.go >/dev/null" \
- || $test_line == "// ! \$G \$D/\$F.go" \
- || $test_line == "// ! \$G \$F.go" \
- || [string match "// ! \$G \$D/\$F.go || echo BUG*" \
- $test_line] } {
- # This is a compile test which should fail.
- set dg-do-what-default "assemble"
- setup_xfail "*-*-*"
- go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
- } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out" \
- $test_line] \
- || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
- $test_line] \
- || [string match "// \$G \$D/\$F.go && \$L \$F.\$A && (! ./\$A.out || echo BUG: *" \
- $test_line] \
- || ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&"
- && $test_line2 == "// ((! sh -c ./\$A.out) >/dev/null 2>&1 || echo BUG: should fail)") } {
+ } elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \
+ $test_line] } {
go-execute-xfail $test
- } elseif { [string match "// errchk \$G \$F.go" $test_line] \
- || [string match "// errchk \$G -e \$F.go" $test_line] \
- || [string match "// errchk \$G \$D/\$F.go" $test_line] \
- || [string match "//errchk \$G \$D/\$F.go" $test_line] \
- || [string match "// errchk \$G -e \$D/\$F.go" \
- $test_line] \
- || [string match "// ! errchk \$G \$D/\$F.go" $test_line] \
- || [string match "// ! errchk \$G -e \$D/\$F.go" \
- $test_line] \
- || [string match "// errchk \$G \$F.go || true" \
- $test_line] \
- || [string match "// errchk \$G \$D/\$F.go || true" \
- $test_line] \
- || [string match "// errchk \$G -e \$D/\$F.go || true" \
- $test_line] \
- || [string match "// errchk \$G \$D/\$F.go || echo BUG*" \
- $test_line] } {
+ } elseif { $test_line == "// errorcheck" } {
errchk $test ""
- } elseif { [string match \
- "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
- $test_line] \
- || [string match \
- "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
- $test_line] } {
- if { [string match \
- "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go || echo BUG*" \
- $test_line] } {
- set name1 "bug0.go"
- set name2 "bug1.go"
- } elseif { [string match \
- "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go" \
- $test_line] } {
- set name1 "one.go"
- set name2 "two.go"
- }
+ } elseif { $test_line == "// compiledir" } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/$name1" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/$name2" file2
- dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
- file delete "[file rootname [file tail $file1]].o"
+ set dir "[file rootname $test].dir"
+ set del {}
+ foreach f [lsort [glob "$dir/*.go"]] {
+ dg-test -keep-output $f "-O" "-w $DEFAULT_GOCFLAGS"
+ lappend del "[file rootname [file tail $f]].o"
+ }
+ foreach f $del {
+ file delete $f
+ }
set runtests $hold_runtests
+ } elseif { "$test_line" == ""
+ || [string match "// true*" $test_line]
+ || [string match "// skip*" $test_line] } {
+ # Not a real test, just ignore.
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \
$test_line] \
- || [string match \
- "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
- $test_line] \
- || [string match \
- "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
- $test_line] \
|| [string match \
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
$test_line] } {
$test_line] } {
set name1 "bug0.go"
set name2 "bug1.go"
- } elseif { [string match \
- "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/p2.go" \
- $test_line] } {
- set name1 "p1.go"
- set name2 "p2.go"
- } elseif { [string match \
- "// \$G \$D/\$F.dir/b.go && \$G \$D/\$F.dir/a.go" \
- $test_line] } {
- set name1 "b.go"
- set name2 "a.go"
} elseif { [string match \
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \
$test_line] } {
errchk $test ""
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
- } elseif { [string match \
- "// \$G \$D/\$F.dir/bug0.go && (! \$G \$D/\$F.dir/bug1.go || echo BUG*" \
- $test_line] } {
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/bug0.go" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/bug1.go" file2
- setup_xfail "*-*-*"
- dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
- file delete "[file rootname [file tail $file1]].o"
- set runtests $hold_runtests
- } elseif { [string match \
- "// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && (! \$G \$D/\$F.dir/bug2.go || echo BUG*" \
- $test_line] } {
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/bug0.go" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/bug1.go" file2
- dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/bug2.go" file3
- setup_xfail "*-*-*"
- dg-test $file3 "-O" "-w $DEFAULT_GOCFLAGS"
- file delete "[file rootname [file tail $file1]].o"
- file delete "[file rootname [file tail $file2]].o"
- set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \
$test_line] } {
$test_line] \
|| [string match \
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
- $test_line] } {
+ $test_line] \
+ || $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \
+ || $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \
+ || $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
if { [string match \
"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \
$test_line] } {
$test_line] } {
set name1 "p.go"
set name2 "main.go"
+ } elseif { $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } {
+ set name1 "p1.go"
+ set name2 "main.go"
+ } elseif { $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
+ set name1 "lib.go"
+ set name2 ""
+ } elseif { $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } {
+ set name1 "method4a.go"
+ set name2 ""
}
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
regsub "\\.go$" $test ".dir/$name1" file1
+ if { $name1 == "method4a.go" } {
+ set file1 "[file dirname $test]/method4a.go"
+ }
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile1 "[file rootname [file tail $file1]].o"
regsub "\\.go$" $test ".dir/$name2" file2
+ if { $name2 == "" } {
+ set file2 $test
+ }
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
set ofile2 "[file rootname [file tail $file2]].o"
set dg-do-what-default "link"
$status $name
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
+ } elseif { $test_line == "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
+ set hold_runtests $runtests
+ set runtests "go-test.exp"
+ set dg-do-what-default "assemble"
+ regsub "\\.go$" $test ".dir/one.go" file1
+ dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
+ set ofile1 "[file rootname [file tail $file1]].o"
+ regsub "\\.go$" $test ".dir/two.go" file2
+ dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
+ set ofile2 "[file rootname [file tail $file2]].o"
+ dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
+ set ofile3 "[file rootname [file tail $test]].o"
+ set dg-do-what-default "link"
+ set output_file "./[file rootname [file tail $test]].exe"
+ set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \
+ $output_file "executable" "$options"]
+ set comp_output [go-dg-prune $target_triplet $comp_output]
+ verbose -log $comp_output
+ set result [go_load "$output_file" "" ""]
+ set status [lindex $result 0]
+ $status $name
+ file delete $ofile1 $ofile2 $ofile3 $output_file
+ set runtests $hold_runtests
} elseif { [string match \
"// \$G \$D/bug191.dir/a.go && \$G \$D/bug191.dir/b.go && \$G \$D/\$F.go && \$L \$F.\$A" \
$test_line] } {
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
- } elseif { [string match \
- "// \$G \$D/\$F.dir/chanbug.go && \$G -I. \$D/\$F.dir/chanbug2.go" \
- $test_line] } {
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/chanbug.go" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/chanbug2.go" file2
- dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
- file delete "[file rootname [file tail $file1]].o"
- set runtests $hold_runtests
- } elseif { [string match \
- "// (! \$G \$D/\$F.go) | grep 'initialization loop' *" \
- $test_line] } {
- set dg-do-what-default "assemble"
- setup_xfail "*-*-*"
- go-dg-runtest $test "-w $DEFAULT_GOCFLAGS"
- } elseif { [string match \
- "// \$G \$D/\$F.dir/x.go && errchk \$G \$D/\$F.dir/y.go" \
- $test_line] } {
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/x.go" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- regsub "\\.go$" $test ".dir/y.go" file2
- errchk $file2 ""
- file delete "[file rootname [file tail $file1]].o"
- set runtests $hold_runtests
- } elseif { "$test_line" == "" || [string match "// true*" $test_line] } {
- # Not a real test, just ignore.
} elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \
&& $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \
&& $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \
}
file delete $ofile1 $ofile2 $output_file
set runtests $hold_runtests
- } elseif { $test_line == "// \$G \$D/\$F.go \$D/cmplxdivide1.go && \$L \$D/\$F.\$A && ./\$A.out" } {
+ } elseif { $test_line == "// run cmplxdivide1.go" } {
regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2
set output_file "./[file rootname [file tail $test]].o"
set comp_output [go_target_compile "$test $test2" \
file delete tmp.x
# Disable optimizations as this test takes a long time
# to compile.
- set hold $TORTURE_OPTIONS
- set TORTURE_OPTIONS [ list { -O0 -g }]
+ set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }]
go-torture-execute "./tmp.go"
- set TORTURE_OPTIONS $hold
}
if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } {
fail "$name execution 1"
}
file delete $output_file
set runtests $hold_runtests
- } elseif { [string match \
- "// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ! ./\$A.out || echo BUG*" \
- $test_line] } {
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "assemble"
- regsub "\\.go$" $test ".dir/p.go" file1
- dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
- set ofile1 "[file rootname [file tail $file1]].o"
- regsub "\\.go$" $test ".dir/main.go" file2
- dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS"
- set ofile2 "[file rootname [file tail $file2]].o"
- set output_file "./[file rootname [file tail $test]].exe"
- set comp_output [go_target_compile "$ofile1 $ofile2" \
- $output_file "executable" "$options"]
- set comp_output [go-dg-prune $target_triplet $comp_output]
- if [string match "" $comp_output] {
- setup_xfail "*-*-*"
- set result [go_load "$output_file" "" ""]
- set status [lindex $result 0]
- $status $name
- } else {
- verbose -log $comp_output
- fail $name
- }
- file delete $ofile1 $ofile2 $output_file
- set runtests $hold_runtests
- } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
- && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out || echo BUG: select5" } {
- set go_execute_args ""
- set hold_runtests $runtests
- set runtests "go-test.exp"
- set dg-do-what-default "link"
- dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
- set output_file "./[file rootname [file tail $test]].exe"
- set base "[file rootname [file tail $test]]"
- if [isnative] {
- if { [catch "exec $output_file > $base-out.go"] != 0 } {
- fail "$name execution"
- } else {
- pass "$name execution"
- file delete $base-out.x
- # Disable optimizations as this test takes a long time
- # to compile.
- set hold $TORTURE_OPTIONS
- set TORTURE_OPTIONS [ list { -O0 -g }]
- go-torture-execute "./$base-out.go"
- set TORTURE_OPTIONS $hold
- }
- file delete $base-out.go
- }
- file delete $output_file
- set runtests $hold_runtests
} elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } {
regsub "\\.go$" $test ".dir/a.go" file1
regsub "\\.go$" $test ".dir/b.go" file2
go-torture-execute $test
} elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \
&& $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \
- && $test_line3 == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } {
+ && $test_line3 == "// run" } {
set hold_runtests $runtests
set runtests "go-test.exp"
set dg-do-what-default "assemble"
dg-test $test "-O" "-w $DEFAULT_GOCFLAGS"
file delete "[file rootname [file tail $file1]].o"
set runtests $hold_runtests
- } elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&"
- && $test_line2 == "// \$G tmp.go && \$L tmp.\$A && ./\$A.out" } {
- set go_execute_args ""
+ } elseif { [string match "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \
+ $test_line ] } {
set hold_runtests $runtests
set runtests "go-test.exp"
- set dg-do-what-default "link"
- dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
- set output_file "./[file rootname [file tail $test]].exe"
- set base "[file rootname [file tail $test]]"
- if [isnative] {
- if { [catch "exec $output_file >$base-out.go"] != 0 } {
- fail "$name execution"
- } else {
- pass "$name execution"
- file delete $base-out.x
- go-torture-execute "./$base-out.go"
- }
- file delete $base-out.go
- }
- file delete $output_file
+ set dg-do-what-default "assemble"
+ regsub "\\.go$" $test ".dir/one.go" file1
+ dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS"
+ set ofile1 "[file rootname [file tail $file1]].o"
+ regsub "\\.go$" $test ".dir/two.go" file2
+ dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS"
+ file delete $ofile1
set runtests $hold_runtests
- } elseif { $test_line == "// # generated by cmplxdivide.c" } {
- # Ignore.
- } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && gopack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
+ } elseif { $test_line == "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \
|| $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
# These tests import the same package under two different
# names, which gccgo does not support.
# as an initializer will be generated for any code which
# has global variables which need to be registered as GC
# roots.
- } elseif { $test_line == "// errchk -0 \$G -m -l \$D/\$F.go" } {
+ } elseif { $test_line == "// errorcheck -0 -m"
+ || $test_line == "// errorcheck -0 -m -l" } {
# This tests debug output of the gc compiler, which is
# meaningless for gccgo.
- } elseif { $test_line == "// \[ \$O == 6 \] || errchk \$G -e \$D/\$F.go" \
- || $test_line == "// \[ \$O != 6 \] || errchk \$G -e \$D/\$F.go" } {
+ } elseif { $test_line == "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \
+ || $test_line == "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } {
# This tests specific handling of the gc compiler on types
# that are too large. It is target specific in a way I
# haven't bothered to check for here.
+ } elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } {
+ # This tests the gc ld -X option, which gccgo does not
+ # support.
+ } elseif { $test_line == "// \$G \$D/pkg.go && pack grc pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && errchk \$G -I. -u \$D/main.go"
+ || $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } {
+ # This tests the gc -u option, which gccgo does not
+ # support.
} else {
clone_output "$name: unrecognized test line: $test_line"
unsupported $name
set go_compile_args ""
set go_execute_args ""
+ set TORTURE_OPTIONS [list { -O2 -g }]
}
set dg-do-what-default ${saved-dg-do-what-default}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Solve the 2,3,5 problem (print all numbers with 2, 3, or 5 as factor) using channels.
+// Test the solution, silently.
+
package main
type T chan uint64
-// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
-// $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: 64bit
-// rm -f tmp.go
+// runoutput
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// 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
-
// Test that error messages say what the source file says
// (uint8 vs byte, int32 vs. rune).
+// Does not compile.
+
+package main
import (
"fmt"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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
-
// Test that dynamic interface checks treat byte=uint8
// and rune=int or rune=int32.
+package main
+
func main() {
var x interface{}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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()
+// Semi-exhaustive test for the append predeclared function.
package main
}
verifyStruct()
verifyInterface()
+ verifyType()
}
verify("interface l", append(s), s)
verify("interface m", append(s, e...), r)
}
+
+type T1 []int
+type T2 []int
+
+func verifyType() {
+ // The second argument to append has type []E where E is the
+ // element type of the first argument. Test that the compiler
+ // accepts two slice types that meet that requirement but are
+ // not assignment compatible. The return type of append is
+ // the type of the first argument.
+ t1 := T1{1}
+ t2 := T2{2}
+ verify("T1", append(t1, t2...), T1{1, 2})
+}
// $G $F.go && $L $F.$A && ./$A.out arg1 arg2
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
+// Test os.Args.
+
package main
import "os"
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify simple assignment errors are caught by the compiler.
+// Does not compile.
+
package main
import "sync"
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify assignment rules are enforced by the compiler.
+// Does not compile.
+
package main
type (
# 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=\
parser\
peano\
tree\
tree2\
-all: $(addsuffix .out, $(ALL))
-
-%.$O: %.go stats.go
- $(GC) $(GCFLAGS) $(GCIMPORTS) $*.go stats.go
+all: $(ALL)
-%.out: %.$O
- $(LD) -o $@ $*.$O
+%: %.go
+ go build $*.go stats.go
-%.bench: %.out
- time ./$*.out
+%.bench: %
+ time ./$*
bench: $(addsuffix .bench, $(ALL))
clean:
- rm -f *.[$(OS)] $(addsuffix .out, $(ALL))
+ rm -f $(ALL)
}
func main() {
- st := &runtime.MemStats
+ st := new(runtime.MemStats)
packages = append(packages, packages...)
packages = append(packages, packages...)
n := flag.Int("n", 4, "iterations")
var lastParsed []map[string]*ast.Package
var t0 time.Time
+ var numGC uint32
+ var pauseTotalNs uint64
pkgroot := runtime.GOROOT() + "/src/pkg/"
for pass := 0; pass < 2; pass++ {
// Once the heap is grown to full size, reset counters.
// This hides the start-up pauses, which are much smaller
// than the normal pauses and would otherwise make
// the average look much better than it actually is.
- st.NumGC = 0
- st.PauseTotalNs = 0
+ runtime.ReadMemStats(st)
+ numGC = st.NumGC
+ pauseTotalNs = st.PauseTotalNs
t0 = time.Now()
for i := 0; i < *n; i++ {
}
t1 := time.Now()
+ runtime.ReadMemStats(st)
+ st.NumGC -= numGC
+ st.PauseTotalNs -= pauseTotalNs
fmt.Printf("Alloc=%d/%d Heap=%d Mallocs=%d PauseTime=%.3f/%d = %.3f\n",
st.Alloc, st.TotalAlloc,
st.Sys,
"container/list",
"container/ring",
"crypto/aes",
- "crypto/blowfish",
"crypto/hmac",
- "crypto/md4",
"crypto/md5",
"crypto/rand",
"crypto/rc4",
"crypto/subtle",
"crypto/tls",
"crypto/x509",
- "crypto/xtea",
"debug/dwarf",
"debug/macho",
"debug/elf",
"encoding/ascii85",
"encoding/base64",
"encoding/binary",
- "encoding/git85",
"encoding/hex",
"encoding/pem",
"os/exec",
"mime",
"net",
"os",
- "os/signal",
- "patch",
"path",
"math/rand",
"reflect",
"testing",
"testing/iotest",
"testing/quick",
- "testing/script",
"time",
"unicode",
"unicode/utf8",
"unicode/utf16",
- "websocket",
"encoding/xml",
}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
)
func gcstats(name string, n int, t time.Duration) {
- 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.Nanoseconds()/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))
+ st := new(runtime.MemStats)
+ runtime.ReadMemStats(st)
+ nprocs := runtime.GOMAXPROCS(-1)
+ cpus := ""
+ if nprocs != 1 {
+ cpus = fmt.Sprintf("-%d", nprocs)
+ }
+ fmt.Printf("garbage.%sMem%s Alloc=%d/%d Heap=%d NextGC=%d Mallocs=%d\n", name, cpus, st.Alloc, st.TotalAlloc, st.Sys, st.NextGC, st.Mallocs)
+ fmt.Printf("garbage.%s%s %d %d ns/op\n", name, cpus, n, t.Nanoseconds()/int64(n))
+ fmt.Printf("garbage.%sLastPause%s 1 %d ns/op\n", name, cpus, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))])
+ fmt.Printf("garbage.%sPause%s %d %d ns/op\n", name, cpus, 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.%sPause5%s: %d %d %d %d %d\n", name, cpus, t1, t2, t3, t4, t5)
// fmt.Printf("garbage.%sScan: %v\n", name, st.ScanDist)
}
"os"
"runtime"
"runtime/pprof"
+ "time"
"unsafe"
)
heap *Object
calls [20]int
numobjects int64
+ memstats runtime.MemStats
)
func buildHeap() {
func gc() {
runtime.GC()
- runtime.UpdateMemStats()
- pause := runtime.MemStats.PauseTotalNs
- inuse := runtime.MemStats.Alloc
- free := runtime.MemStats.TotalAlloc - inuse
+ runtime.ReadMemStats(&memstats)
+ pause := memstats.PauseTotalNs
+ inuse := memstats.Alloc
+ free := memstats.TotalAlloc - inuse
fmt.Printf("gc pause: %8.3f ms; collect: %8.0f MB; heapsize: %8.0f MB\n",
float64(pause-lastPauseNs)/1e6,
float64(free-lastFree)/1048576,
flag.Parse()
buildHeap()
runtime.GOMAXPROCS(*cpus)
- runtime.UpdateMemStats()
- lastPauseNs = runtime.MemStats.PauseTotalNs
- lastFree = runtime.MemStats.TotalAlloc - runtime.MemStats.Alloc
+ runtime.ReadMemStats(&memstats)
+ lastPauseNs = memstats.PauseTotalNs
+ lastFree = memstats.TotalAlloc - memstats.Alloc
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
- for i := 0; i < 10; i++ {
+ const N = 10
+ var t0 time.Time
+ for i := 0; i < N; i++ {
+ t0 = time.Now()
gc()
}
+ // Standard gotest benchmark output, collected by build dashboard.
+ gcstats("BenchmarkTree2", N, time.Now().Sub(t0))
}
+++ /dev/null
-include $(GOROOT)/src/Make.inc
-
-TARG=go1
-GOFILES=\
- dummy.go\
-
-include $(GOROOT)/src/Make.pkg
+++ /dev/null
-package main
-
-import target "go1"
-import "testing"
-import "regexp"
-
-var tests = []testing.InternalTest{
-}
-
-var benchmarks = []testing.InternalBenchmark{
- {"go1.BenchmarkBinaryTree17", target.BenchmarkBinaryTree17},
- {"go1.BenchmarkFannkuch11", target.BenchmarkFannkuch11},
- {"go1.BenchmarkGobDecode", target.BenchmarkGobDecode},
- {"go1.BenchmarkGobEncode", target.BenchmarkGobEncode},
- {"go1.BenchmarkGzip", target.BenchmarkGzip},
- {"go1.BenchmarkGunzip", target.BenchmarkGunzip},
- {"go1.BenchmarkJSONEncode", target.BenchmarkJSONEncode},
- {"go1.BenchmarkJSONDecode", target.BenchmarkJSONDecode},
- {"go1.BenchmarkRevcomp25M", target.BenchmarkRevcomp25M},
- {"go1.BenchmarkTemplate", target.BenchmarkTemplate},
-}
-var examples = []testing.InternalExample{}
-
-var matchPat string
-var matchRe *regexp.Regexp
-
-func matchString(pat, str string) (result bool, err error) {
- if matchRe == nil || matchPat != pat {
- matchPat = pat
- matchRe, err = regexp.Compile(matchPat)
- if err != nil {
- return
- }
- }
- return matchRe.MatchString(str), nil
-}
-
-func main() {
- testing.Main(matchString, tests, benchmarks, examples)
-}
+++ /dev/null
-package go1
-
-// Nothing to see here: everything is in the _test files.
package go1
+import "runtime"
+
// Not a benchmark; input for revcomp.
-var fasta25m = fasta(25e6)
+var fastabytes = makefasta()
+
+func makefasta() []byte {
+ var n int = 25e6
+ if runtime.GOARCH == "arm" {
+ // TODO(dfc) remove this limitation after precise gc.
+ // A value of 25e6 consumes 465mb of heap on 32bit
+ // platforms, which is too much for most ARM systems.
+ // A value of 25e5 produces a memory layout that
+ // confuses the gc on 32bit platforms. So 25e4 it is.
+ n = 25e4
+ }
+ return fasta(n)
+}
func fasta(n int) []byte {
out := make(fastaBuffer, 0, 11*n)
gobdata *JSONResponse
)
-func gobinit() {
- // gobinit is called after json's init,
- // because it uses jsondata.
+func init() {
gobdata = gobResponse(&jsondata)
var buf bytes.Buffer
func init() {
var buf bytes.Buffer
- c, err := gz.NewWriter(&buf)
- if err != nil {
- panic(err)
- }
+ c := gz.NewWriter(&buf)
c.Write(jsongunz)
c.Close()
jsongz = buf.Bytes()
}
func gzip() {
- c, err := gz.NewWriter(ioutil.Discard)
- if err != nil {
- panic(err)
- }
+ c := gz.NewWriter(ioutil.Discard)
if _, err := c.Write(jsongunz); err != nil {
panic(err)
}
)
var (
- jsonbytes []byte
- jsondata JSONResponse
+ jsonbytes = makeJsonBytes()
+ jsondata = makeJsonData()
)
-func init() {
+func makeJsonBytes() []byte {
var r io.Reader
r = strings.NewReader(jsonbz2_base64)
r = base64.NewDecoder(base64.StdEncoding, r)
if err != nil {
panic(err)
}
- jsonbytes = b
+ return b
+}
- if err := json.Unmarshal(jsonbytes, &jsondata); err != nil {
+func makeJsonData() JSONResponse {
+ var v JSONResponse
+ if err := json.Unmarshal(jsonbytes, &v); err != nil {
panic(err)
}
- gobinit()
+ return v
}
type JSONResponse struct {
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This benchmark, taken from the shootuot, tests floating point performance.
+
+package go1
+
+import "testing"
+
+func mandelbrot(n int) int {
+ const Iter = 50
+ const Zero float64 = 0
+ const Limit = 2.0
+ ok := 0
+ for y := 0; y < n; y++ {
+ for x := 0; x < n; x++ {
+ Zr, Zi, Tr, Ti := Zero, Zero, Zero, Zero
+ Cr := (2*float64(x)/float64(n) - 1.5)
+ Ci := (2*float64(y)/float64(n) - 1.0)
+
+ for i := 0; i < Iter && (Tr+Ti <= Limit*Limit); i++ {
+ Zi = 2*Zr*Zi + Ci
+ Zr = Tr - Ti + Cr
+ Tr = Zr * Zr
+ Ti = Zi * Zi
+ }
+
+ if Tr+Ti <= Limit*Limit {
+ ok++
+ }
+ }
+ }
+ return ok
+}
+
+func BenchmarkMandelbrot200(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ mandelbrot(200)
+ }
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package go1
+
+// go parser benchmark based on go/parser/performance_test.go
+
+import (
+ "compress/bzip2"
+ "encoding/base64"
+ "go/parser"
+ "go/token"
+ "io"
+ "io/ioutil"
+ "strings"
+ "testing"
+)
+
+var (
+ parserbytes = makeParserBytes()
+)
+
+func makeParserBytes() []byte {
+ var r io.Reader
+ r = strings.NewReader(parserbz2_base64)
+ r = base64.NewDecoder(base64.StdEncoding, r)
+ r = bzip2.NewReader(r)
+ b, err := ioutil.ReadAll(r)
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
+
+func BenchmarkParse(b *testing.B) {
+ b.SetBytes(int64(len(parserbytes)))
+ for i := 0; i < b.N; i++ {
+ if _, err := parser.ParseFile(token.NewFileSet(), "", parserbytes, parser.ParseComments); err != nil {
+ b.Fatalf("benchmark failed due to parse error: %s", err)
+ }
+ }
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Input for parser benchmark.
+// This was generated by starting with a the contents of
+// src/pkg/go/parser/parser.go at rev 9b455eb64690, then
+// compressing with bzip2 -9, then encoding to base64.
+// We compile the data into the binary so that the benchmark is
+// a stand-alone binary that can be copied easily from machine to
+// machine. parser_test.go decodes this during init.
+
+package go1
+
+var parserbz2_base64 = "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" +
+ "v9hdyRThQkN3QmOE"
}
}
-func BenchmarkRevcomp25M(b *testing.B) {
- b.SetBytes(int64(len(fasta25m)))
+func BenchmarkRevcomp(b *testing.B) {
+ b.SetBytes(int64(len(fastabytes)))
for i := 0; i < b.N; i++ {
- revcomp(fasta25m)
+ revcomp(fastabytes)
}
}
+++ /dev/null
-# 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]
icc -O3 -ip -unroll -static binary-trees.c -lm
*/
-#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
free(s);
- g_ptr_array_foreach(roots, free, NULL);
+ g_ptr_array_foreach(roots, (GFunc)free, NULL);
g_ptr_array_free(roots, TRUE);
return 0;
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
- w := *n
- h := *n
+ w := float64(*n)
+ h := float64(*n)
bit_num := 0
byte_acc := byte(0)
const Iter = 50
const Zero float64 = 0
const Limit = 2.0
- fmt.Fprintf(out, "P4\n%d %d\n", w, h)
+ fmt.Fprintf(out, "P4\n%d %d\n", *n, *n)
- for y := 0; y < h; y++ {
- for x := 0; x < w; x++ {
+ for y := 0.0; y < h; y++ {
+ for x := 0.0; x < w; x++ {
Zr, Zi, Tr, Ti := Zero, Zero, Zero, Zero
- Cr := (2*float64(x)/float64(w) - 1.5)
- Ci := (2*float64(y)/float64(h) - 1.0)
+ Cr := (2*x/w - 1.5)
+ Ci := (2*y/h - 1.0)
for i := 0; i < Iter && (Tr+Ti <= Limit*Limit); i++ {
Zi = 2*Zr*Zi + Ci
byte_acc = 0
bit_num = 0
} else if x == w-1 {
- byte_acc <<= uint(8 - w%8)
+ byte_acc <<= uint(8 - uint(*n)%8)
out.WriteByte(byte_acc)
byte_acc = 0
bit_num = 0
* contributed by Premysl Hruby
*/
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
static void* thread(void *num)
{
- int l = (int)num;
+ int l = (int)(uintptr_t)num;
int r = (l+1) % THREADS;
int token;
pthread_mutex_lock(mutex + i);
pthread_attr_setstack(&stack_attr, &stacks[i], sizeof(struct stack));
- pthread_create(&cthread, &stack_attr, thread, (void*)i);
+ pthread_create(&cthread, &stack_attr, thread, (void*)(uintptr_t)i);
}
pthread_mutex_unlock(mutex + 0);
chameneos 6000000
gc chameneosredux 7.41u 0.00s 7.42r # -3%
+
+# A complete run at the Go 1 release.
+# Significant changes:
+# - gccgo is now enabled for all tests (goroutines are cheap enough)
+# - threadring and chameneos are 14% faster, probably due to runtime changes
+# - regex-dna 36% faster
+# - fannkuch-parallel (only) slowed down 40%
+# - gccgo on binary-tree-freelist is still optimized to nothing
+# Other changes are modest.
+
+fasta -n 25000000
+ gcc -O2 fasta.c 1.45u 0.02s 1.48r
+ gccgo -O2 fasta.go 1.46u 0.00s 1.47r
+ gc fasta 1.99u 0.01s 2.00r
+ gc_B fasta 1.99u 0.01s 2.01r
+
+reverse-complement < output-of-fasta-25000000
+ gcc -O2 reverse-complement.c 0.95u 0.48s 4.99r
+ gccgo -O2 reverse-complement.go 0.93u 0.16s 1.09r
+ gc reverse-complement 1.20u 0.19s 1.39r
+ gc_B reverse-complement 1.04u 0.16s 1.20r
+
+nbody -n 50000000
+ gcc -O2 -lm nbody.c 13.02u 0.00s 13.05r
+ gccgo -O2 nbody.go 14.46u 0.00s 14.49r
+ gc nbody 21.79u 0.00s 21.84r
+ gc_B nbody 21.74u 0.00s 21.79r
+
+binary-tree 15 # too slow to use 20
+ gcc -O2 binary-tree.c -lm 0.60u 0.01s 0.61r
+ gccgo -O2 binary-tree.go 1.30u 0.01s 1.32r
+ gccgo -O2 binary-tree-freelist.go 0.00u 0.00s 0.00r
+ gc binary-tree 1.84u 0.01s 1.86r
+ gc binary-tree-freelist 0.33u 0.00s 0.33r
+
+fannkuch 12
+ gcc -O2 fannkuch.c 45.24u 0.00s 45.34r
+ gccgo -O2 fannkuch.go 59.76u 0.01s 59.90r
+ gccgo -O2 fannkuch-parallel.go 218.20u 0.01s 61.60r
+ gc fannkuch 103.92u 0.00s 104.16r
+ gc fannkuch-parallel 221.61u 0.00s 60.49r
+ gc_B fannkuch 53.17u 0.00s 53.30r
+
+regex-dna 100000
+ gcc -O2 regex-dna.c -lpcre 0.47u 0.00s 0.48r
+ gccgo -O2 regex-dna.go 6.52u 0.00s 6.54r
+ gccgo -O2 regex-dna-parallel.go 14.40u 0.73s 4.35r
+ gc regex-dna 2.63u 0.02s 2.66r # -36%
+ gc regex-dna-parallel 2.87u 0.01s 1.11r
+ gc_B regex-dna 2.65u 0.00s 2.66r
+
+spectral-norm 5500
+ gcc -O2 spectral-norm.c -lm 15.78u 0.00s 15.82r
+ gccgo -O2 spectral-norm.go 15.79u 0.00s 15.83r
+ gc spectral-norm 19.76u 0.00s 19.80r
+ gc_B spectral-norm 19.73u 0.01s 19.78r
+
+k-nucleotide 1000000
+ gcc -O2 k-nucleotide.c 5.59u 0.03s 5.63r
+ gccgo -O2 k-nucleotide.go 4.09u 0.03s 4.13r
+ gccgo -O2 k-nucleotide-parallel.go 4.50u 0.06s 1.63r
+ gc k-nucleotide 9.23u 0.02s 9.27r
+ gc k-nucleotide-parallel 9.87u 0.03s 3.55r
+ gc_B k-nucleotide 9.20u 0.00s 9.22r
+
+mandelbrot 16000
+ gcc -O2 mandelbrot.c 36.09u 0.00s 36.18r
+ gccgo -O2 mandelbrot.go 41.69u 0.01s 41.80r
+ gc mandelbrot 60.91u 0.02s 61.07r
+ gc_B mandelbrot 60.90u 0.00s 61.04r
+
+meteor 2098
+ gcc -O2 meteor-contest.c 0.09u 0.00s 0.09r
+ gccgo -O2 meteor-contest.go 0.09u 0.00s 0.09r
+ gc meteor-contest 0.14u 0.00s 0.15r
+ gc_B meteor-contest 0.14u 0.00s 0.14r
+
+pidigits 10000
+ gcc -O2 pidigits.c -lgmp 2.27u 0.00s 2.27r
+ gccgo -O2 pidigits.go 8.65u 0.00s 8.67r
+ gc pidigits 3.70u 0.04s 3.75r
+ gc_B pidigits 3.72u 0.02s 3.75r
+
+threadring 50000000
+ gcc -O2 threadring.c 40.91u 369.85s 323.31r
+ gccgo -O2 threadring.go 26.97u 30.82s 57.93r
+ gc threadring 12.81u 0.01s 12.85r # -13%
+
+chameneos 6000000
+ gcc -O2 chameneosredux.c -lpthread 9.44u 72.90s 12.65r
+ gccgo -O2 chameneosredux.go 7.73u 7.53s 15.30r
+ gc chameneosredux 6.51u 0.00s 6.53r # - 14%
+
+# After http://codereview.appspot.com/6248049, moving panicindex
+# calls out of line (putting the likely code into a single path and shortening
+# loops). Significant changes since the last run (note: some are slower for
+# unrelated and as yet undiagnosed reasons):
+
+nbody -n 50000000
+ gc nbody 19.10u 0.01s 19.19r # -12%
+ gc_B nbody 19.19u 0.00s 19.23r # -12%
+
+binary-tree 15 # too slow to use 20
+ gc binary-tree 1.49u 0.01s 1.51r # -19%
+
+fannkuch 12
+ gc fannkuch 60.79u 0.00s 60.92r # -41%
+ gc fannkuch-parallel 183.51u 0.01s 51.75r # -14%
+ gc_B fannkuch 51.68u 0.00s 51.79r # -3%
+
+k-nucleotide 1000000
+ gc k-nucleotide 9.74u 0.04s 9.80r # +6%
+ gc k-nucleotide-parallel 9.89u 0.05s 3.59r # +1%
+ gc_B k-nucleotide 9.39u 0.02s 9.43r # +2%
+
+mandelbrot (much slower, due to unrelated http://codereview.appspot.com/6209077)
+ gc mandelbrot 100.98u 0.00s 101.20r # +65%
+ gc_B mandelbrot 100.90u 0.01s 101.17r # +65%
+
+meteor 2098
+ gc meteor-contest 0.13u 0.00s 0.13r # -13%
+ gc_B meteor-contest 0.13u 0.00s 0.13r # -7%
+
+# May 30, 2012.
+# After http://codereview.appspot.com/6261051, restoring old code generated
+# for floating-point constants. Mandelbrot is back to its previous numbers.
+
+mandelbrot 16000
+ gcc -O2 mandelbrot.c 36.07u 0.00s 36.16r
+ gccgo -O2 mandelbrot.go 41.72u 0.01s 41.90r
+ gc mandelbrot 60.62u 0.00s 60.76r
+ gc_B mandelbrot 60.68u 0.00s 60.82r
+
+# May 30, 2012.
+# After http://codereview.appspot.com/6248068, better FP code
+# by avoiding MOVSD between registers.
+# Plus some other timing changes that have crept in from other speedups,
+# from garbage collection to Printf.
+
+fasta -n 25000000
+ gc fasta 1.76u 0.00s 1.76r # -12%
+ gc_B fasta 1.71u 0.00s 1.72r # -12%
+
+nbody -n 50000000
+ gc nbody 17.56u 0.00s 17.60r # -8%
+ gc_B nbody 17.30u 0.00s 17.34r # -10%
+
+fannkuch 12
+ gc fannkuch-parallel 155.92u 0.01s 44.05r # -15%
+
+k-nucleotide 1000000
+ gc k-nucleotide 9.22u 0.01s 9.26r # -5%
+ gc k-nucleotide-parallel 9.23u 0.03s 3.26r # -9%
+ gc_B k-nucleotide 9.22u 0.03s 9.28r # -2%
+
+mandelbrot 16000
+ gc mandelbrot 44.80u 0.00s 44.90r # -27%
+ gc_B mandelbrot 44.81u 0.00s 44.92r # -26%
+
+pidigits 10000
+ gc pidigits 3.51u 0.00s 3.52r # -6%
+ gc_B pidigits 3.51u 0.00s 3.52r # -6%
+
+# Aug 28, 2012
+# After some assembler work in package big.
+pidigits 10000
+ gc pidigits 2.85u 0.02s 2.88r # -22%
+ gc_B pidigits 2.88u 0.01s 2.90r # -21%
+
+# Sep 26, 2012
+# 64-bit ints, plus significantly better floating-point code.
+# Interesting details:
+# Generally something in the 0-10% slower range, some (binary tree) more
+# Floating-point noticeably faster:
+# nbody -25%
+# mandelbrot -37% relative to Go 1.
+# Other:
+# regex-dna +47%
+fasta -n 25000000
+ gcc -O2 fasta.c 1.43u 0.03s 1.46r
+ gccgo -O2 fasta.go 1.47u 0.00s 1.47r
+ gc fasta 1.78u 0.01s 1.80r
+ gc_B fasta 1.76u 0.00s 1.76r
+
+reverse-complement < output-of-fasta-25000000
+ gcc -O2 reverse-complement.c 1.14u 0.39s 11.19r
+ gccgo -O2 reverse-complement.go 0.91u 0.17s 1.09r
+ gc reverse-complement 1.12u 0.18s 1.31r
+ gc_B reverse-complement 1.12u 0.15s 1.28r
+
+nbody -n 50000000
+ gcc -O2 nbody.c -lm 13.02u 0.00s 13.05r
+ gccgo -O2 nbody.go 13.90u 0.00s 13.93r
+ gc nbody 17.05u 0.00s 17.09r
+ gc_B nbody 16.30u 0.00s 16.34r
+
+binary-tree 15 # too slow to use 20
+ gcc -O2 binary-tree.c -lm 0.61u 0.00s 0.61r
+ gccgo -O2 binary-tree.go 1.24u 0.04s 1.29r
+ gccgo -O2 binary-tree-freelist.go 0.21u 0.01s 0.22r
+ gc binary-tree 1.93u 0.02s 1.96r
+ gc binary-tree-freelist 0.32u 0.00s 0.33r
+
+fannkuch 12
+ gcc -O2 fannkuch.c 45.19u 0.00s 45.29r
+ gccgo -O2 fannkuch.go 60.32u 0.00s 60.45r
+ gccgo -O2 fannkuch-parallel.go 185.59u 0.00s 59.49r
+ gc fannkuch 72.14u 0.00s 72.30r
+ gc fannkuch-parallel 172.54u 0.00s 43.59r
+ gc_B fannkuch 53.55u 0.00s 53.67r
+
+regex-dna 100000
+ gcc -O2 regex-dna.c -lpcre 0.47u 0.00s 0.47r
+ gccgo -O2 regex-dna.go 6.49u 0.05s 6.56r
+ gccgo -O2 regex-dna-parallel.go 14.60u 0.67s 4.42r
+ gc regex-dna 3.91u 0.00s 3.92r
+ gc regex-dna-parallel 4.01u 0.03s 1.56r
+ gc_B regex-dna 3.91u 0.00s 3.92r
+
+spectral-norm 5500
+ gcc -O2 spectral-norm.c -lm 15.85u 0.00s 15.89r
+ gccgo -O2 spectral-norm.go 15.86u 0.00s 15.89r
+ gc spectral-norm 19.72u 0.00s 19.76r
+ gc_B spectral-norm 19.68u 0.01s 19.74r
+
+k-nucleotide 1000000
+ gcc -O2 k-nucleotide.c -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 4.90u 0.01s 4.93r
+ gccgo -O2 k-nucleotide.go 4.78u 0.01s 4.80r
+ gccgo -O2 k-nucleotide-parallel.go 6.49u 0.02s 2.18r
+ gc k-nucleotide 9.05u 0.02s 9.09r
+ gc k-nucleotide-parallel 9.27u 0.01s 3.29r
+ gc_B k-nucleotide 8.95u 0.03s 9.00r
+
+mandelbrot 16000
+ gcc -O2 mandelbrot.c 36.11u 0.00s 36.19r
+ gccgo -O2 mandelbrot.go 43.67u 0.00s 43.77r
+ gc mandelbrot 38.57u 0.00s 38.66r
+ gc_B mandelbrot 38.59u 0.00s 38.68r
+
+meteor 2098
+ gcc -O2 meteor-contest.c 0.09u 0.00s 0.09r
+ gccgo -O2 meteor-contest.go 0.09u 0.00s 0.09r
+ gc meteor-contest 0.13u 0.00s 0.14r
+ gc_B meteor-contest 0.12u 0.00s 0.13r
+
+pidigits 10000
+ gcc -O2 pidigits.c -lgmp 2.26u 0.00s 2.27r
+ gccgo -O2 pidigits.go 9.05u 0.00s 9.07r
+ gc pidigits 2.88u 0.02s 2.90r
+ gc_B pidigits 2.89u 0.00s 2.90r
+
+threadring 50000000
+ gcc -O2 threadring.c -lpthread 37.30u 327.81s 289.28r
+ gccgo -O2 threadring.go 42.83u 26.15s 69.14r
+ gc threadring 13.00u 0.00s 13.03r
+
+chameneos 6000000
+ gcc -O2 chameneosredux.c -lpthread 8.80u 71.67s 12.19r
+ gccgo -O2 chameneosredux.go 11.28u 6.68s 18.00r
+ gc chameneosredux 6.94u 0.00s 6.96r
+
set -e
-eval $(gomake --no-print-directory -f ../../../src/Make.inc go-env)
+eval $(go tool dist env)
+O=$GOCHAR
+GC="go tool ${O}g"
+LD="go tool ${O}l"
+
PATH=.:$PATH
havegccgo=false
nbody() {
runonly echo 'nbody -n 50000000'
- run 'gcc -O2 -lm nbody.c' a.out 50000000
+ run 'gcc -O2 nbody.c -lm' a.out 50000000
run 'gccgo -O2 nbody.go' a.out -n 50000000
run 'gc nbody' $O.out -n 50000000
run 'gc_B nbody' $O.out -n 50000000
runonly echo 'binary-tree 15 # too slow to use 20'
run 'gcc -O2 binary-tree.c -lm' a.out 15
run 'gccgo -O2 binary-tree.go' a.out -n 15
- run 'gccgo -O2 binary-tree-freelist.go' $O.out -n 15
+ run 'gccgo -O2 binary-tree-freelist.go' a.out -n 15
run 'gc binary-tree' $O.out -n 15
run 'gc binary-tree-freelist' $O.out -n 15
}
runonly gcc -O2 fasta.c
runonly a.out 1000000 > 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 <x
+ if [ $mode = run ]; then
+ run "gcc -O2 k-nucleotide.c $(pkg-config glib-2.0 --cflags --libs)" a.out <x
+ fi
run 'gccgo -O2 k-nucleotide.go' a.out <x
run 'gccgo -O2 k-nucleotide-parallel.go' a.out <x
run 'gc k-nucleotide' $O.out <x
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test the internal "algorithms" for objects larger than a word: hashing, equality etc.
+
package main
type T struct {
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Internally a map holds elements in up to 255 bytes of key+value.
+// When key or value or both are too large, it uses pointers to key+value
+// instead. Test all the combinations.
+
package main
func seq(x, y int) [1000]byte {
cmp(m[1], seq(11, 13))
cmp(m[2], seq(2, 9))
cmp(m[3], seq(3, 17))
+
+
+ {
+ type T [1]byte
+ type V [1]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [100]byte
+ type V [1]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [1]byte
+ type V [100]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [1000]byte
+ type V [1]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [1]byte
+ type V [1000]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [1000]byte
+ type V [1000]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [200]byte
+ type V [1]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [1]byte
+ type V [200]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
+ {
+ type T [200]byte
+ type V [200]byte
+ m := make(map[T]V)
+ m[T{}] = V{1}
+ m[T{1}] = V{2}
+ if x, y := m[T{}][0], m[T{1}][0]; x != 1 || y != 2 {
+ println(x, y)
+ panic("bad map")
+ }
+ }
}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test behavior of the blank identifier (_).
+
package main
import _ "fmt"
type TI struct{}
-func (TI) M(x int, y int) {
+func (_ TI) M(x int, y int) {
if x != y {
println("invalid M call:", x, y)
panic("bad M")
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Test that incorrect uses of the blank identifer are caught.
+// Does not compile.
+
package _ // ERROR "invalid package name _"
func main() {
--- /dev/null
+// runoutput
+
+// 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 source file beginning with a byte order mark.
+
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+func main() {
+ prog = strings.Replace(prog, "BOM", "\uFEFF", -1)
+ fmt.Print(prog)
+}
+
+var prog = `BOM
+package main
+
+func main() {
+}
+`
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Here for reference, but hard to test automatically
+// because the BOM muddles the
+// processing done by ../run.
+
+package main
+
+func main() {
+ // There's a bom here. // ERROR "BOM"
+ // And here. // ERROR "BOM"
+ /* And here.*/ // ERROR "BOM"
+ println("hi there") // and here // ERROR "BOM"
+}
--- /dev/null
+// errorcheck -0 -m -l
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test, using compiler diagnostic flags, that bounds check elimination
+// is eliminating the correct checks.
+
+package foo
+
+var (
+ s []int
+
+ a1 [1]int
+ a1k [1000]int
+ a100k [100000]int
+
+ p1 *[1]int
+ p1k *[1000]int
+ p100k *[100000]int
+
+ i int
+ ui uint
+ i8 int8
+ ui8 uint8
+ i16 int16
+ ui16 uint16
+ i32 int32
+ ui32 uint32
+ i64 int64
+ ui64 uint64
+)
+
+func main() {
+ // Most things need checks.
+ use(s[i])
+ use(a1[i])
+ use(a1k[i])
+ use(a100k[i])
+ use(p1[i])
+ use(p1k[i])
+ use(p100k[i])
+
+ use(s[ui])
+ use(a1[ui])
+ use(a1k[ui])
+ use(a100k[ui])
+ use(p1[ui])
+ use(p1k[ui])
+ use(p100k[ui])
+
+ use(s[i8])
+ use(a1[i8])
+ use(a1k[i8])
+ use(a100k[i8])
+ use(p1[i8])
+ use(p1k[i8])
+ use(p100k[i8])
+
+ // Unsigned 8-bit numbers don't need checks for len >= 2⁸.
+ use(s[ui8])
+ use(a1[ui8])
+ use(a1k[ui8]) // ERROR "index bounds check elided"
+ use(a100k[ui8]) // ERROR "index bounds check elided"
+ use(p1[ui8])
+ use(p1k[ui8]) // ERROR "index bounds check elided"
+ use(p100k[ui8]) // ERROR "index bounds check elided"
+
+ use(s[i16])
+ use(a1[i16])
+ use(a1k[i16])
+ use(a100k[i16])
+ use(p1[i16])
+ use(p1k[i16])
+ use(p100k[i16])
+
+ // Unsigned 16-bit numbers don't need checks for len >= 2¹⁶.
+ use(s[ui16])
+ use(a1[ui16])
+ use(a1k[ui16])
+ use(a100k[ui16]) // ERROR "index bounds check elided"
+ use(p1[ui16])
+ use(p1k[ui16])
+ use(p100k[ui16]) // ERROR "index bounds check elided"
+
+ use(s[i32])
+ use(a1[i32])
+ use(a1k[i32])
+ use(a100k[i32])
+ use(p1[i32])
+ use(p1k[i32])
+ use(p100k[i32])
+
+ use(s[ui32])
+ use(a1[ui32])
+ use(a1k[ui32])
+ use(a100k[ui32])
+ use(p1[ui32])
+ use(p1k[ui32])
+ use(p100k[ui32])
+
+ use(s[i64])
+ use(a1[i64])
+ use(a1k[i64])
+ use(a100k[i64])
+ use(p1[i64])
+ use(p1k[i64])
+ use(p100k[i64])
+
+ use(s[ui64])
+ use(a1[ui64])
+ use(a1k[ui64])
+ use(a100k[ui64])
+ use(p1[ui64])
+ use(p1k[ui64])
+ use(p100k[ui64])
+
+ // Mod truncates the maximum value to one less than the argument,
+ // but signed mod can be negative, so only unsigned mod counts.
+ use(s[i%999])
+ use(a1[i%999])
+ use(a1k[i%999])
+ use(a100k[i%999])
+ use(p1[i%999])
+ use(p1k[i%999])
+ use(p100k[i%999])
+
+ use(s[ui%999])
+ use(a1[ui%999])
+ use(a1k[ui%999]) // ERROR "index bounds check elided"
+ use(a100k[ui%999]) // ERROR "index bounds check elided"
+ use(p1[ui%999])
+ use(p1k[ui%999]) // ERROR "index bounds check elided"
+ use(p100k[ui%999]) // ERROR "index bounds check elided"
+
+ use(s[i%1000])
+ use(a1[i%1000])
+ use(a1k[i%1000])
+ use(a100k[i%1000])
+ use(p1[i%1000])
+ use(p1k[i%1000])
+ use(p100k[i%1000])
+
+ use(s[ui%1000])
+ use(a1[ui%1000])
+ use(a1k[ui%1000]) // ERROR "index bounds check elided"
+ use(a100k[ui%1000]) // ERROR "index bounds check elided"
+ use(p1[ui%1000])
+ use(p1k[ui%1000]) // ERROR "index bounds check elided"
+ use(p100k[ui%1000]) // ERROR "index bounds check elided"
+
+ use(s[i%1001])
+ use(a1[i%1001])
+ use(a1k[i%1001])
+ use(a100k[i%1001])
+ use(p1[i%1001])
+ use(p1k[i%1001])
+ use(p100k[i%1001])
+
+ use(s[ui%1001])
+ use(a1[ui%1001])
+ use(a1k[ui%1001])
+ use(a100k[ui%1001]) // ERROR "index bounds check elided"
+ use(p1[ui%1001])
+ use(p1k[ui%1001])
+ use(p100k[ui%1001]) // ERROR "index bounds check elided"
+
+ // Bitwise and truncates the maximum value to the mask value.
+ // The result (for a positive mask) cannot be negative, so elision
+ // applies to both signed and unsigned indexes.
+ use(s[i&999])
+ use(a1[i&999])
+ use(a1k[i&999]) // ERROR "index bounds check elided"
+ use(a100k[i&999]) // ERROR "index bounds check elided"
+ use(p1[i&999])
+ use(p1k[i&999]) // ERROR "index bounds check elided"
+ use(p100k[i&999]) // ERROR "index bounds check elided"
+
+ use(s[ui&999])
+ use(a1[ui&999])
+ use(a1k[ui&999]) // ERROR "index bounds check elided"
+ use(a100k[ui&999]) // ERROR "index bounds check elided"
+ use(p1[ui&999])
+ use(p1k[ui&999]) // ERROR "index bounds check elided"
+ use(p100k[ui&999]) // ERROR "index bounds check elided"
+
+ use(s[i&1000])
+ use(a1[i&1000])
+ use(a1k[i&1000])
+ use(a100k[i&1000]) // ERROR "index bounds check elided"
+ use(p1[i&1000])
+ use(p1k[i&1000])
+ use(p100k[i&1000]) // ERROR "index bounds check elided"
+
+ use(s[ui&1000])
+ use(a1[ui&1000])
+ use(a1k[ui&1000])
+ use(a100k[ui&1000]) // ERROR "index bounds check elided"
+ use(p1[ui&1000])
+ use(p1k[ui&1000])
+ use(p100k[ui&1000]) // ERROR "index bounds check elided"
+
+ // Right shift cuts the effective number of bits in the index,
+ // but only for unsigned (signed stays negative).
+ use(s[i32>>22])
+ use(a1[i32>>22])
+ use(a1k[i32>>22])
+ use(a100k[i32>>22])
+ use(p1[i32>>22])
+ use(p1k[i32>>22])
+ use(p100k[i32>>22])
+
+ use(s[ui32>>22])
+ use(a1[ui32>>22])
+ use(a1k[ui32>>22])
+ use(a100k[ui32>>22]) // ERROR "index bounds check elided"
+ use(p1[ui32>>22])
+ use(p1k[ui32>>22])
+ use(p100k[ui32>>22]) // ERROR "index bounds check elided"
+
+ use(s[i32>>23])
+ use(a1[i32>>23])
+ use(a1k[i32>>23])
+ use(a100k[i32>>23])
+ use(p1[i32>>23])
+ use(p1k[i32>>23])
+ use(p100k[i32>>23])
+
+ use(s[ui32>>23])
+ use(a1[ui32>>23])
+ use(a1k[ui32>>23]) // ERROR "index bounds check elided"
+ use(a100k[ui32>>23]) // ERROR "index bounds check elided"
+ use(p1[ui32>>23])
+ use(p1k[ui32>>23]) // ERROR "index bounds check elided"
+ use(p100k[ui32>>23]) // ERROR "index bounds check elided"
+
+ // Division cuts the range like right shift does.
+ use(s[i/1e6])
+ use(a1[i/1e6])
+ use(a1k[i/1e6])
+ use(a100k[i/1e6])
+ use(p1[i/1e6])
+ use(p1k[i/1e6])
+ use(p100k[i/1e6])
+
+ use(s[ui/1e6])
+ use(a1[ui/1e6])
+ use(a1k[ui/1e6])
+ use(p1[ui/1e6])
+ use(p1k[ui/1e6])
+
+ use(s[i/1e7])
+ use(a1[i/1e7])
+ use(a1k[i/1e7])
+ use(a100k[i/1e7])
+ use(p1[i/1e7])
+ use(p1k[i/1e7])
+ use(p100k[i/1e7])
+
+ use(s[ui/1e7])
+ use(a1[ui/1e7])
+ use(p1[ui/1e7])
+}
+
+var sum int
+
+func use(x int) {
+ sum += x
+}
// echo bug395 is broken # takes 90+ seconds to break
// # $G $D/$F.go || echo bug395
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package one
+
+// Issue 3552
+
+type T struct { int }
+
+func (t T) F() int { return t.int }
+
+type U struct { int int }
+
+func (u U) F() int { return u.int }
+
+type lint int
+
+type V struct { lint }
+
+func (v V) F() int { return int(v.lint) }
+
+type W struct { lint lint }
+
+func (w W) F() int { return int(w.lint) }
+
+
+
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Use the functions in one.go so that the inlined
+// forms get type-checked.
+
+package two
+
+import "./one"
+
+func use() {
+ var t one.T
+ var u one.U
+ var v one.V
+ var w one.W
+
+ _ = t.F()
+ _ = u.F()
+ _ = v.F()
+ _ = w.F()
+}
--- /dev/null
+// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go || echo BUG:bug434
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This test is designed to flush out the case where two cases of a select can
+// Test the situation in which two cases of a select can
// both end up running. See http://codereview.appspot.com/180068.
+
package main
import (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Verify that unbuffered channels act as pure fifos.
+// Test that unbuffered channels act as pure fifos.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// make a lot of goroutines, threaded together.
-// tear them down cleanly.
+// Torture test for goroutines.
+// Make a lot of goroutines, threaded together, and tear them down cleanly.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Verify channel operations that test for blocking
-// Use several sizes and types of operands
+// Test channel operations that test for blocking.
+// Use several sizes and types of operands.
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Test various correct and incorrect permutations of send-only,
+// receive-only, and bidirectional channels.
+// Does not compile.
+
package main
var (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test concurrency primitives: power series.
+
// Power series package
// A power series is a channel, along which flow rational
// coefficients. A denominator of zero signifies the end.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test concurrency primitives: power series.
+
+// Like powser1.go but uses channels of interfaces.
+// Has not been cleaned up as much as powser1.go, to keep
+// it distinct and therefore a different test.
+
// Power series package
// A power series is a channel, along which flow rational
// coefficients. A denominator of zero signifies the end.
// Original code in Newsqueak by Doug McIlroy.
// See Squinting at Power Series by Doug McIlroy,
// http://www.cs.bell-labs.com/who/rsc/thread/squint.pdf
-// Like powser1.go but uses channels of interfaces.
-// Has not been cleaned up as much as powser1.go, to keep
-// it distinct and therefore a different test.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple select.
+
package main
var counter uint
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that selects do not consume undue memory.
+
package main
import "runtime"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Tests verifying the semantics of the select statement
+// Test the semantics of the select statement
// for basic empty/non-empty cases.
package main
})
testBlock(never, func() {
select {
- case x := <-closedch:
+ case x := (<-closedch):
_ = x
}
})
testBlock(never, func() {
select {
- case x, ok := <-closedch:
+ case x, ok := (<-closedch):
_, _ = x, ok
}
})
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file
+
+// Test that a select statement proceeds when a value is ready.
package main
-// $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
+// runoutput
// 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
+// The output of this program is compiled and run to do the
+// actual test.
+
+// Each test does only one real send or receive at a time, but phrased
// in various ways that the compiler may or may not rewrite
// into simpler expressions.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 2075
+// Test for select: Issue 2075
// A bug in select corrupts channel queues of failed cases
// if there are multiple waiters on those channels and the
// select is the last in the queue. If further waits are made
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test concurrency primitives: classical inefficient concurrent prime sieve.
+
// Generate primes up to 100 using channels, checking the results.
// This sieve consists of a linear chain of divisibility filters,
// equivalent to trial-dividing each n by all primes p ≤ n.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test concurrency primitives: prime sieve of Eratosthenes.
+
// Generate primes up to 100 using channels, checking the results.
// This sieve is Eratosthenesque and only considers odd candidates.
// See discussion at <http://blog.onideas.ws/eratosthenes.go>.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Making channels of a zero-sized type should not panic.
+// Test making channels of a zero-sized type.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test the cap predeclared function applied to channels.
+
package main
func main() {
-// $G $F.go && $L $F.$A &&./$A.out
+// run
// 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.
+// Test character literal syntax.
+
package main
import "os"
-// errchk $G -e $F.go
+// errorcheck
// 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.
+// Verify that illegal character literals are detected.
+// Does not compile.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test the behavior of closures.
+
package main
import "runtime"
func newfunc() func(int) int { return func(x int) int { return x } }
func main() {
+ runtime.GOMAXPROCS(1)
var fail bool
go f()
go h()
check([]int{100, 200, 101, 201, 500, 101, 201, 500})
- runtime.UpdateMemStats()
- n0 := runtime.MemStats.Mallocs
+ memstats := new(runtime.MemStats)
+ runtime.ReadMemStats(memstats)
+ n0 := memstats.Mallocs
x, y := newfunc(), newfunc()
if x(1) != 1 || y(2) != 2 {
fail = true
}
- runtime.UpdateMemStats()
- if n0 != runtime.MemStats.Mallocs {
+ runtime.ReadMemStats(memstats)
+ if n0 != memstats.Mallocs {
println("newfunc allocated unexpectedly")
fail = true
}
ff(1)
if fail {
- panic("fail")
+ panic("fail")
}
}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test equality and inequality operations.
+
package main
import "unsafe"
isfalse(ix != z)
isfalse(iz != x)
}
+
+ // structs with _ fields
+ {
+ var x = struct {
+ x int
+ _ []int
+ y float64
+ _ float64
+ z int
+ }{
+ x: 1, y: 2, z: 3,
+ }
+ var ix interface{} = x
+
+ istrue(x == x)
+ istrue(x == ix)
+ istrue(ix == x)
+ istrue(ix == ix)
+ }
// arrays
{
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that incorrect comparisons are detected.
+// Does not compile.
+
package main
func use(bool) {}
var t3 T3
+type T4 struct { _ []int; a float64 }
+
+var t4 T4
+
func main() {
// Arguments to comparison must be
// assignable one to the other (or vice versa)
// Comparison of structs should have a good message
use(t3 == t3) // ERROR "struct|expected"
+ use(t4 == t4) // ok; the []int is a blank field
// Slices, functions, and maps too.
var x []int
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that incorrect invocations of the complex predeclared function are detected.
+// Does not compile.
+
package main
var (
int i, j, k, l;
double complex n, d, q;
+ printf("// skip\n");
printf("// # generated by cmplxdivide.c\n");
printf("\n");
printf("package main\n");
-// $G $D/$F.go $D/cmplxdivide1.go && $L $D/$F.$A && ./$A.out
+// run cmplxdivide1.go
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+// skip
// # generated by cmplxdivide.c
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test composite literals.
+
package main
type T struct {
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that illegal composite literals are detected.
+// Does not compile.
+
package main
var m map[int][3]int
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: compos
+// run
// 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.
+// Test that returning &T{} from a function causes an allocation.
+
package main
type T struct {
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple boolean and numeric constants.
+
package main
const (
-// errchk $G -e $F.go
+// errorcheck
// 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.
+// Verify overflow is detected when using numeric constants.
+// Does not compile.
+
package main
type I interface{}
Int8 int8 = 101
Minus1 int8 = -1
Uint8 uint8 = 102
- Const = 103
+ Const = 103
Float32 float32 = 104.5
Float64 float64 = 105.5
- ConstFloat = 106.5
+ ConstFloat = 106.5
Big float64 = 1e300
String = "abc"
a8 = Int8 * Const / 100 // ERROR "overflow"
a9 = Int8 * (Const / 100) // OK
- b1 = Uint8 * Uint8 // ERROR "overflow"
- b2 = Uint8 * -1 // ERROR "overflow"
- b3 = Uint8 - Uint8 // OK
- b4 = Uint8 - Uint8 - Uint8 // ERROR "overflow"
- b5 = uint8(^0) // ERROR "overflow"
- b6 = ^uint8(0) // OK
- b7 = uint8(Minus1) // ERROR "overflow"
- b8 = uint8(int8(-1)) // ERROR "overflow"
- b8a = uint8(-1) // ERROR "overflow"
- b9 byte = (1 << 10) >> 8 // OK
- b10 byte = (1 << 10) // ERROR "overflow"
- b11 byte = (byte(1) << 10) >> 8 // ERROR "overflow"
- b12 byte = 1000 // ERROR "overflow"
- b13 byte = byte(1000) // ERROR "overflow"
- b14 byte = byte(100) * byte(100) // ERROR "overflow"
- b15 byte = byte(100) * 100 // ERROR "overflow"
- b16 byte = byte(0) * 1000 // ERROR "overflow"
- b16a byte = 0 * 1000 // OK
- b17 byte = byte(0) * byte(1000) // ERROR "overflow"
- b18 byte = Uint8 / 0 // ERROR "division by zero"
+ b1 = Uint8 * Uint8 // ERROR "overflow"
+ b2 = Uint8 * -1 // ERROR "overflow"
+ b3 = Uint8 - Uint8 // OK
+ b4 = Uint8 - Uint8 - Uint8 // ERROR "overflow"
+ b5 = uint8(^0) // ERROR "overflow"
+ b5a = int64(^0) // OK
+ b6 = ^uint8(0) // OK
+ b6a = ^int64(0) // OK
+ b7 = uint8(Minus1) // ERROR "overflow"
+ b8 = uint8(int8(-1)) // ERROR "overflow"
+ b8a = uint8(-1) // ERROR "overflow"
+ b9 byte = (1 << 10) >> 8 // OK
+ b10 byte = (1 << 10) // ERROR "overflow"
+ b11 byte = (byte(1) << 10) >> 8 // ERROR "overflow"
+ b12 byte = 1000 // ERROR "overflow"
+ b13 byte = byte(1000) // ERROR "overflow"
+ b14 byte = byte(100) * byte(100) // ERROR "overflow"
+ b15 byte = byte(100) * 100 // ERROR "overflow"
+ b16 byte = byte(0) * 1000 // ERROR "overflow"
+ b16a byte = 0 * 1000 // OK
+ b17 byte = byte(0) * byte(1000) // ERROR "overflow"
+ b18 byte = Uint8 / 0 // ERROR "division by zero"
- c1 float64 = Big
- c2 float64 = Big * Big // ERROR "overflow"
- c3 float64 = float64(Big) * Big // ERROR "overflow"
- c4 = Big * Big // ERROR "overflow"
- c5 = Big / 0 // ERROR "division by zero"
+ c1 float64 = Big
+ c2 float64 = Big * Big // ERROR "overflow"
+ c3 float64 = float64(Big) * Big // ERROR "overflow"
+ c4 = Big * Big // ERROR "overflow"
+ c5 = Big / 0 // ERROR "division by zero"
+ c6 = 1000 % 1e3 // ERROR "floating-point % operation|expected integer type"
)
func f(int)
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify that large integer constant expressions cause overflow.
+// Does not compile.
+
package main
const (
A int = 1
B byte; // ERROR "type without expr|expected .=."
)
+
+const LargeA = 1000000000000000000
+const LargeB = LargeA * LargeA * LargeA
+const LargeC = LargeB * LargeB * LargeB // GC_ERROR "constant multiplication overflow"
+
+const AlsoLargeA = LargeA << 400 << 400 >> 400 >> 400 // GC_ERROR "constant shift overflow"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test typed integer constants.
+
package main
import "fmt"
--- /dev/null
+// run
+
+// 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 len constants and non-constants, http://golang.org/issue/3244.
+
+package main
+
+var b struct {
+ a[10]int
+}
+
+var m map[string][20]int
+
+var s [][30]int
+
+const (
+ n1 = len(b.a)
+ n2 = len(m[""])
+ n3 = len(s[10])
+)
+
+// Non-constants (see also const5.go).
+var (
+ n4 = len(f())
+ n5 = len(<-c)
+ n6 = cap(g())
+ n7 = cap(<-c1)
+)
+
+var calledF = false
+
+func f() *[40]int {
+ calledF = true
+ return nil
+}
+
+var c = func() chan *[50]int {
+ c := make(chan *[50]int, 2)
+ c <- nil
+ c <- new([50]int)
+ return c
+}()
+
+var calledG = false
+
+func g() *[60]int {
+ calledG = true
+ return nil
+}
+
+var c1 = func() chan *[70]int {
+ c := make(chan *[70]int, 2)
+ c <- nil
+ c <- new([70]int)
+ return c
+}()
+
+func main() {
+ if n1 != 10 || n2 != 20 || n3 != 30 || n4 != 40 || n5 != 50 || n6 != 60 || n7 != 70 {
+ println("BUG:", n1, n2, n3, n4, n5, n6, n7)
+ }
+ if !calledF {
+ println("BUG: did not call f")
+ }
+ if <-c == nil {
+ println("BUG: did not receive from c")
+ }
+ if !calledG {
+ println("BUG: did not call g")
+ }
+ if <-c1 == nil {
+ println("BUG: did not receive from c1")
+ }
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that len non-constants are not constants, http://golang.org/issue/3244.
+
+package p
+
+var b struct {
+ a[10]int
+}
+
+var m map[string][20]int
+
+var s [][30]int
+
+func f() *[40]int
+var c chan *[50]int
+
+const (
+ n1 = len(b.a)
+ n2 = len(m[""])
+ n3 = len(s[10])
+
+ n4 = len(f()) // ERROR "must be constant|is not constant"
+ n5 = len(<-c) // ERROR "must be constant|is not constant"
+
+ n6 = cap(f()) // ERROR "must be constant|is not constant"
+ n7 = cap(<-c) // ERROR "must be constant|is not constant"
+)
+
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test conversion from non-interface types to the empty interface.
+
+package main
+
+type J interface {
+ Method()
+}
+
+type (
+ U16 uint16
+ U32 uint32
+ U64 uint64
+ U128 [2]uint64
+ F32 float32
+ F64 float64
+ C128 complex128
+ S string
+ B []byte
+ M map[int]int
+ C chan int
+ Z struct{}
+)
+
+func (U16) Method() {}
+func (U32) Method() {}
+func (U64) Method() {}
+func (U128) Method() {}
+func (F32) Method() {}
+func (F64) Method() {}
+func (C128) Method() {}
+func (S) Method() {}
+func (B) Method() {}
+func (M) Method() {}
+func (C) Method() {}
+func (Z) Method() {}
+
+var (
+ u16 = U16(1)
+ u32 = U32(2)
+ u64 = U64(3)
+ u128 = U128{4, 5}
+ f32 = F32(6)
+ f64 = F64(7)
+ c128 = C128(8 + 9i)
+ s = S("10")
+ b = B("11")
+ m = M{12: 13}
+ c = make(C, 14)
+ z = Z{}
+ p = &z
+ pp = &p
+)
+
+var (
+ iu16 interface{} = u16
+ iu32 interface{} = u32
+ iu64 interface{} = u64
+ iu128 interface{} = u128
+ if32 interface{} = f32
+ if64 interface{} = f64
+ ic128 interface{} = c128
+ is interface{} = s
+ ib interface{} = b
+ im interface{} = m
+ ic interface{} = c
+ iz interface{} = z
+ ip interface{} = p
+ ipp interface{} = pp
+
+ ju16 J = u16
+ ju32 J = u32
+ ju64 J = u64
+ ju128 J = u128
+ jf32 J = f32
+ jf64 J = f64
+ jc128 J = c128
+ js J = s
+ jb J = b
+ jm J = m
+ jc J = c
+ jz J = z
+ jp J = p // The method set for *T contains the methods for T.
+ // pp does not implement error.
+)
+
+func second(a ...interface{}) interface{} {
+ return a[1]
+}
+
+func main() {
+ // Test equality.
+ if u16 != iu16 {
+ panic("u16 != iu16")
+ }
+ if u16 != ju16 {
+ panic("u16 != ju16")
+ }
+ if u32 != iu32 {
+ panic("u32 != iu32")
+ }
+ if u32 != ju32 {
+ panic("u32 != ju32")
+ }
+ if u64 != iu64 {
+ panic("u64 != iu64")
+ }
+ if u64 != ju64 {
+ panic("u64 != ju64")
+ }
+ if u128 != iu128 {
+ panic("u128 != iu128")
+ }
+ if u128 != ju128 {
+ panic("u128 != ju128")
+ }
+ if f32 != if32 {
+ panic("f32 != if32")
+ }
+ if f32 != jf32 {
+ panic("f32 != jf32")
+ }
+ if f64 != if64 {
+ panic("f64 != if64")
+ }
+ if f64 != jf64 {
+ panic("f64 != jf64")
+ }
+ if c128 != ic128 {
+ panic("c128 != ic128")
+ }
+ if c128 != jc128 {
+ panic("c128 != jc128")
+ }
+ if s != is {
+ panic("s != is")
+ }
+ if s != js {
+ panic("s != js")
+ }
+ if c != ic {
+ panic("c != ic")
+ }
+ if c != jc {
+ panic("c != jc")
+ }
+ // There are no tests for b and m, as slices and maps are not comparable by ==.
+ if z != iz {
+ panic("z != iz")
+ }
+ if z != jz {
+ panic("z != jz")
+ }
+ if p != ip {
+ panic("p != ip")
+ }
+ if p != jp {
+ panic("p != jp")
+ }
+ if pp != ipp {
+ panic("pp != ipp")
+ }
+ // pp does not implement J.
+
+ // Test that non-interface types can be used as ...interface{} arguments.
+ if got := second(z, p, pp, u16, u32, u64, u128, f32, f64, c128, s, b, m, c); got != ip {
+ println("second: got", got, "want", ip)
+ panic("fail")
+ }
+
+ // Test that non-interface types can be sent on a chan interface{}.
+ const n = 100
+ uc := make(chan interface{})
+ go func() {
+ for i := 0; i < n; i++ {
+ select {
+ case uc <- nil:
+ case uc <- u32:
+ case uc <- u64:
+ case uc <- u128:
+ }
+ }
+ }()
+ for i := 0; i < n; i++ {
+ if got := <-uc; got != nil && got != u32 && got != u64 && got != u128 {
+ println("recv: i", i, "got", got)
+ panic("fail")
+ }
+ }
+}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test types of constant expressions, using reflect.
+
package main
import "reflect"
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that illegal conversions involving strings are detected.
+// Does not compile.
+
package main
type Tbyte []byte
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify allowed and disallowed conversions.
+// Does not compile.
+
package main
// everything here is legal except the ERROR line
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify that illegal assignments with both explicit and implicit conversions of literals are detected.
+// Does not compile.
+
package main
-// explicit conversion of constants is work in progress.
-// the ERRORs in this block are debatable, but they're what
-// the language spec says for now.
+// explicit conversion of constants
var x1 = string(1)
var x2 string = string(1)
var x3 = int(1.5) // ERROR "convert|truncate"
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify that illegal uses of composite literals are detected.
+// Does not compile.
+
package main
var a = []int { "a" }; // ERROR "conver|incompatible|cannot"
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Semi-exhaustive test for copy()
+// Semi-exhaustive test for the copy predeclared function.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
-// $G tmp.go && $L tmp.$A && ./$A.out
-// rm -f tmp.go
+// runoutput
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test variadic functions and calls (dot-dot-dot).
+
package main
func sum(args ...int) int {
*T
}
+type I interface {
+ Sum(...int) int
+}
+
func main() {
if x := sum(1, 2, 3); x != 6 {
println("sum 6", x)
println("i(=u).Sum", x)
panic("fail")
}
- /* TODO(rsc): Enable once nested method expressions work.
+ var s struct {
+ I
+ }
+ s.I = &u
+ if x := s.Sum(2, 3, 5, 8); x != 18 {
+ println("s{&u}.Sum", x)
+ panic("fail")
+ }
if x := (*U).Sum(&U{}, 1, 3, 5, 2); x != 11 {
println("(*U).Sum", x)
panic("fail")
println("U.Sum", x)
panic("fail")
}
- */
}
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that illegal uses of ... are detected.
+// Does not compile.
+
package main
import "unsafe"
_ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
)
+func sum3(int, int, int) int { return 0 }
+func tuple() (int, int, int) { return 1, 2, 3 }
+
+var (
+ _ = sum(tuple())
+ _ = sum(tuple()...) // ERROR "multiple-value|[.][.][.]"
+ _ = sum3(tuple())
+ _ = sum3(tuple()...) // ERROR "multiple-value|[.][.][.]" "not enough"
+)
+
type T []T
func funny(args ...T) int { return 0 }
-// true
+// skip
// 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.
+// This file is compiled and then imported by ddd3.go.
+
package ddd
func Sum(args ...int) int {
// $G $D/ddd2.go && $G $D/$F.go && $L $F.$A && ./$A.out
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that variadic functions work across package boundaries.
+
package main
import "./ddd2"
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Correct short declarations and redeclarations.
+// Test correct short declarations and redeclarations.
package main
-// errchk $G -e $F.go
+// errorcheck
// 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.
-// Incorrect short declarations and redeclarations.
+// Test that incorrect short declarations and redeclarations are detected.
+// Does not compile.
package main
i, f := f2() // ERROR "redeclared|no new"
_, _, _ = i, f, s
}
+ {
+ // multiline no new variables
+ i := f1
+ i := func() { // ERROR "redeclared|no new|incompatible"
+ }
+ _ = i
+ }
{
// single redeclaration
i, f, s := f3()
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test defer.
+
package main
import "fmt"
-// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that we can defer the predeclared functions print and println.
+
package main
func main() {
defer println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
defer println(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
-// defer panic("dead")
+ // Disabled so the test doesn't crash but left here for reference.
+ // defer panic("dead")
defer print("printing: ")
}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// divide corner cases
+// Test divide corner cases.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.go $D/z*.go && $L $F.$A && ./$A.out
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// $G $D/$F.go
+// compile
// 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.
+// Test that top-level parenthesized declarations can be empty.
+// Compiles but does not run.
+
package P
import ( )
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test a source file does not need a final newline.
+// Compiles but does not run.
+
// No newline at the end of this file.
package main
\ No newline at end of file
-// $G $D/$F.go
+// compile
// 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
+// Test that a comment ending a source file does not need a final newline.
+// Compiles but does not run.
+
+package eof1
// No newline at the end of this comment.
\ No newline at end of file
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package main
-// check for correct heap-moving of escaped variables.
-// it is hard to check for the allocations, but it is easy
+// Test for correct heap-moving of escaped variables.
+// It is hard to check for the allocations, but it is easy
// to check that if you call the function twice at the
// same stack level, the pointers returned should be
// different.
func noalias(p, q *int, s string) {
n := len(allptr)
- *p = -(n+1)
- *q = -(n+2)
- allptr = allptr[0:n+2]
+ *p = -(n + 1)
+ *q = -(n + 2)
+ allptr = allptr[0 : n+2]
allptr[n] = p
allptr[n+1] = q
n += 2
for i := 0; i < n; i++ {
if allptr[i] != nil && *allptr[i] != -(i+1) {
- println("aliased pointers", -(i+1), *allptr[i], "after", s)
+ println("aliased pointers", -(i + 1), *allptr[i], "after", s)
allptr[i] = nil
bad = true
}
return p[0], p[1]
}
+func for_escapes3(x int, y int) (*int, *int) {
+ var f [2]func() *int
+ n := 0
+ for i := x; n < 2; i = y {
+ p := new(int)
+ *p = i
+ f[n] = func() *int { return p }
+ n++
+ }
+ return f[0](), f[1]()
+}
+
func out_escapes(i int) (x int, p *int) {
x = i
- p = &x // ERROR "address of out parameter"
+ p = &x // ERROR "address of out parameter"
return
}
func out_escapes_2(i int) (x int, p *int) {
x = i
- return x, &x // ERROR "address of out parameter"
+ return x, &x // ERROR "address of out parameter"
}
func defer1(i int) (x int) {
p, q = for_escapes2(103, 104)
chkalias(p, q, 103, "for_escapes2")
+ p, q = for_escapes3(105, 106)
+ chk(p, q, 105, "for_escapes3")
+
_, p = out_escapes(15)
_, q = out_escapes(16)
chk(p, q, 15, "out_escapes")
-// errchk -0 $G -m -l $D/$F.go
+// errorcheck -0 -m -l
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test, using compiler diagnostic flags, that the escape analysis is working.
+// Compiles but does not run. Inlining is disabled.
+
package foo
import (
}
}
+// issue 3975
+func foo74b() {
+ var array [3]func()
+ s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape"
+ for i, v := range s {
+ vv := v // ERROR "moved to heap: vv"
+ // actually just escapes its scope
+ array[i] = func() { // ERROR "func literal escapes to heap"
+ println(vv) // ERROR "&vv escapes to heap"
+ }
+ }
+}
+
func myprint(y *int, x ...interface{}) *int { // ERROR "x does not escape" "leaking param: y"
return y
}
goto L1
L1:
- i = new(int) // ERROR "does not escape"
+ i = new(int) // ERROR "new.int. does not escape"
_ = i
}
var i *int
L1:
- i = new(int) // ERROR "escapes"
+ i = new(int) // ERROR "new.int. escapes to heap"
goto L1
_ = i
}
+
+func foo124(x **int) { // ERROR "x does not escape"
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes"
+ func() { // ERROR "func literal does not escape"
+ *x = p // ERROR "leaking closure reference p"
+ }()
+}
+
+func foo125(ch chan *int) { // ERROR "does not escape"
+ var i int // ERROR "moved to heap"
+ p := &i // ERROR "&i escapes to heap"
+ func() { // ERROR "func literal does not escape"
+ ch <- p // ERROR "leaking closure reference p"
+ }()
+}
+
+func foo126() {
+ var px *int // loopdepth 0
+ for {
+ // loopdepth 1
+ var i int // ERROR "moved to heap"
+ func() { // ERROR "func literal does not escape"
+ px = &i // ERROR "&i escapes"
+ }()
+ }
+}
+
+var px *int
+
+func foo127() {
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes to heap"
+ q := p
+ px = q
+}
+
+func foo128() {
+ var i int
+ p := &i // ERROR "&i does not escape"
+ q := p
+ _ = q
+}
+
+func foo129() {
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes to heap"
+ func() { // ERROR "func literal does not escape"
+ q := p // ERROR "leaking closure reference p"
+ func() { // ERROR "func literal does not escape"
+ r := q // ERROR "leaking closure reference q"
+ px = r
+ }()
+ }()
+}
+
+func foo130() {
+ for {
+ var i int // ERROR "moved to heap"
+ func() { // ERROR "func literal does not escape"
+ px = &i // ERROR "&i escapes" "leaking closure reference i"
+ }()
+ }
+}
+
+func foo131() {
+ var i int // ERROR "moved to heap"
+ func() { // ERROR "func literal does not escape"
+ px = &i // ERROR "&i escapes" "leaking closure reference i"
+ }()
+}
+
+func foo132() {
+ var i int // ERROR "moved to heap"
+ go func() { // ERROR "func literal escapes to heap"
+ px = &i // ERROR "&i escapes" "leaking closure reference i"
+ }()
+}
+
+func foo133() {
+ var i int // ERROR "moved to heap"
+ defer func() { // ERROR "func literal does not escape"
+ px = &i // ERROR "&i escapes" "leaking closure reference i"
+ }()
+}
+
+func foo134() {
+ var i int
+ p := &i // ERROR "&i does not escape"
+ func() { // ERROR "func literal does not escape"
+ q := p
+ func() { // ERROR "func literal does not escape"
+ r := q
+ _ = r
+ }()
+ }()
+}
+
+func foo135() {
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes to heap" "moved to heap: p"
+ go func() { // ERROR "func literal escapes to heap"
+ q := p // ERROR "&p escapes to heap"
+ func() { // ERROR "func literal does not escape"
+ r := q
+ _ = r
+ }()
+ }()
+}
+
+func foo136() {
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes to heap" "moved to heap: p"
+ go func() { // ERROR "func literal escapes to heap"
+ q := p // ERROR "&p escapes to heap" "leaking closure reference p"
+ func() { // ERROR "func literal does not escape"
+ r := q // ERROR "leaking closure reference q"
+ px = r
+ }()
+ }()
+}
+
+func foo137() {
+ var i int // ERROR "moved to heap: i"
+ p := &i // ERROR "&i escapes to heap"
+ func() { // ERROR "func literal does not escape"
+ q := p // ERROR "leaking closure reference p" "moved to heap: q"
+ go func() { // ERROR "func literal escapes to heap"
+ r := q // ERROR "&q escapes to heap"
+ _ = r
+ }()
+ }()
+}
+
+func foo138() *byte {
+ type T struct {
+ x [1]byte
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x[0] // ERROR "&t.x.0. escapes to heap"
+}
+
+func foo139() *byte {
+ type T struct {
+ x struct {
+ y byte
+ }
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x.y // ERROR "&t.x.y escapes to heap"
+}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 run-time behavior of escape analysis-related optimizations.
+// Test the run-time behavior of escape analysis-related optimizations.
package main
--- /dev/null
+// errorcheck -0 -m
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test, using compiler diagnostic flags, that the escape analysis is working.
+// Compiles but does not run. Inlining is enabled.
+
+package foo
+
+var p *int
+
+func alloc(x int) *int { // ERROR "can inline alloc" "moved to heap: x"
+ return &x // ERROR "&x escapes to heap"
+}
+
+var f func()
+
+func f1() {
+ p = alloc(2) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
+
+ // Escape analysis used to miss inlined code in closures.
+
+ func() { // ERROR "func literal does not escape"
+ p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
+ }()
+
+ f = func() { // ERROR "func literal escapes to heap"
+ p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
+ }
+ f()
+}
+
+func f2() {} // ERROR "can inline f2"
+
+// No inline for panic, recover.
+func f3() { panic(1) }
+func f4() { recover() }
+
+func f5() *byte {
+ type T struct {
+ x [1]byte
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x[0] // ERROR "&t.x.0. escapes to heap"
+}
+
+func f6() *byte {
+ type T struct {
+ x struct {
+ y byte
+ }
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x.y // ERROR "&t.x.y escapes to heap"
+}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+++ /dev/null
-// ! $G $D/$F.go >/dev/null
-// # ignoring error messages...
-
-// 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
-
-func main() {
- s := float(0);
- s := float(0); // BUG redeclaration
-}
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+++ /dev/null
-// ! $G $D/$F.go >/dev/null
-// # ignoring error messages...
-
-// 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
-
-func main() {
- var z [3]byte;
- z := new([3]byte); // BUG redeclaration
-}
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// ! $G $D/$F.go >/dev/null
-// # ignoring error messages...
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package main
-func main (x, x int) { // BUG redeclaration error
+func f (x, // GCCGO_ERROR "previous"
+ x int) { // ERROR "redeclared|redefinition" "duplicate"
}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// 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
+package bug063
const c = 0 ^ 0
-// $G $D/$F.go || echo BUG: compilation should succeed
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// 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
+package bug066
type Scope struct {
entries map[string] *Object;
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: compiler crashes
+// compile
// 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
+package bug071
type rat struct {
den int;
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A
+// build
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: fails incorrectly
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.dir/bug0.go && errchk $G $D/$F.dir/bug1.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: fails incorrectly
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go || echo BUG: fails incorrectly
+// compiledir
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: fails incorrectly
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: fails incorrectly
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should not crash
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should not crash
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go || echo BUG: failed to compile
+// compiledir
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// 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
+package bug109
func f(a float64) float64 {
e := 1.0
-// $G $D/$F.go && $L $F.$A || echo BUG: const bug
+// build
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should compile and run
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && (./$A.out || echo BUG: bug114 failed)
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug115 should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug116
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// 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
+package bug118
func Send(c chan int) int {
select {
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should not fail
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug120
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should compile
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG129
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should run
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go && errchk $G $D/$F.dir/bug2.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should run
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug142
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug147
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug150
+// compile
// 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
+package bug150
type T int
func (t T) M()
-// $G $D/$F.go || echo BUG: bug151
+// compile
// 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
+package bug151
type S string
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should not panic
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A || echo BUG: bug155
+// build
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug156
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug159
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/bug160.dir/x.go && $G $D/bug160.dir/y.go && $L y.$A && ./$A.out
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A || echo BUG: bug167
+// build
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug168
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug173
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug174
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-//errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/bug191.dir/a.go && $G $D/bug191.dir/b.go && $G $D/$F.go && $L $F.$A
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should compile and run
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug196
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should run
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out >/dev/null 2>&1 || echo BUG: bug206
+// cmpout
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug214
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug216
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug218
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug219
+// compile
// 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
+package bug219
func f(func()) int { return 0 }
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+// 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 chanbug
var C chan<- (chan int)
var D chan<- func()
+// 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 Bar
import _ "chanbug"
-// $G $D/$F.dir/chanbug.go && $G -I. $D/$F.dir/chanbug2.go
+// compiledir
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// (! $G $D/$F.go) | grep 'initialization loop' >/dev/null || echo BUG: bug223
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
}
}
-var m = map[string]F{"f": f}
+var m = map[string]F{"f": f} // ERROR "initialization loop|depends upon itself"
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// 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
+package bug232
type I interface { X(...int) }
-// $G $D/$F.go
+// compile
// 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
+package bug233
import p "fmt"
var _ = p.Print
var fmt = 10
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// used to crash the compiler
-package main
+package bug235
type T struct {
x [4]byte
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug239
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: tuple evaluation order
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug245
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug246
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug247
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+// 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
type T struct {
+// 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
type T struct {
+// 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 (
+// 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 (
// $L bug2.$A &&
// ./$A.out || echo BUG: failed to compile
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// 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.
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug250
+// compile
// 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
+package bug250
type I1 interface {
m() I2
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
}
-var i1 I1 = i2 // GC_ERROR "missing m method|need type assertion"
+var i1 I1 = i2
var i2 I2
var i2a I2 = i1
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug253
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug254
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bugxxx
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug260 failed
+// run
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file
// Test that structures pack densely, according to the alignment of the largest field.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug266
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG
+// compile
// 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
+package bug267
type T []int
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package main
-import "unsafe"
-
var bug = false
var minus1 = -1
var big int64 = 10 | 1<<32
-var g1 []int
+type block [1<<19]byte
+
+var g1 []block
func shouldfail(f func(), desc string) {
defer func() { recover() }()
}
func badlen() {
- g1 = make([]int, minus1)
+ g1 = make([]block, minus1)
}
func biglen() {
- g1 = make([]int, big)
+ g1 = make([]block, big)
}
func badcap() {
- g1 = make([]int, 10, minus1)
+ g1 = make([]block, 10, minus1)
}
func badcap1() {
- g1 = make([]int, 10, 5)
+ g1 = make([]block, 10, 5)
}
func bigcap() {
- g1 = make([]int, 10, big)
+ g1 = make([]block, 10, big)
}
-var g3 map[int]int
+var g3 map[block]block
func badmapcap() {
- g3 = make(map[int]int, minus1)
+ g3 = make(map[block]block, minus1)
}
func bigmapcap() {
- g3 = make(map[int]int, big)
+ g3 = make(map[block]block, big)
}
-var g4 chan int
+type cblock [1<<16-1]byte
+
+var g4 chan cblock
func badchancap() {
- g4 = make(chan int, minus1)
+ g4 = make(chan cblock, minus1)
}
func bigchancap() {
- g4 = make(chan int, big)
+ g4 = make(chan cblock, big)
}
-const addrBits = unsafe.Sizeof((*byte)(nil))
-
-var g5 chan [1<<15]byte
func overflowchan() {
- if addrBits == 32 {
- g5 = make(chan [1<<15]byte, 1<<20)
- } else {
- // cannot overflow on 64-bit, because
- // int is 32 bits and max chan value size
- // in the implementation is 64 kB.
- panic(1)
- }
+ g4 = make(chan cblock, 1<<30)
}
func main() {
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG code should run
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG should compile
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go
+// compiledir
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// http://code.google.com/p/go/issues/detail?id=806
// triggered out of registers on 8g
-package main
+package bug283
type Point struct {
x int
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug285
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug286 failed
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug301.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/bug302.dir/p.go && gopack grc pp.a p.$A && $G $D/bug302.dir/main.go
+// $G $D/bug302.dir/p.go && pack grc pp.a p.$A && $G $D/bug302.dir/main.go
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go
+// compiledir
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// issue 1016
-package main
+package bug309
func foo(t interface{}, c chan int) {
switch v := t.(type) {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// errchk $G -e $D/$F.dir/[ab].go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug314
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug315
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug316
+// compile
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug317
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug321
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug331
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug334
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package a
-import "./b"
+type T interface{}
-var Bar = b.Foo
+func f() T { return nil }
+
+var Foo T = f()
package b
-type T interface{}
+import "./a"
-func f() T { return nil }
-
-var Foo T = f()
+var Bar = a.Foo
-// $G $D/$F.dir/b.go && $G $D/$F.dir/a.go
-// rm -f a.$A b.$A
+// compiledir
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Issue 1705.
-unused (see script at top of file)
+package ignored
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug341
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug343
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G $D/$F.dir/io.go && errchk $G -e $D/$F.dir/main.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: issue2056
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug352
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug354
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// issue 2086
// was calling makeclosure twice on the closure
-package main
+package bug354
type Inner struct {
F func() error
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug344
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug360
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+// 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 (
+// 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 T struct{ x int }
// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: should not fail
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// $G -N -o slow.$A $D/bug369.dir/pkg.go &&
// $G -o fast.$A $D/bug369.dir/pkg.go &&
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug372
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug375
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+// 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 one
func Foo() (n int64, _ *int) {
+// 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 two
import _ "./one"
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug378
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Issue 2276.
// Check that the error messages says
-// bug378.go:19: unsafe.Alignof(0) not used
+// bug381.go:29: unsafe.Alignof(0) not used
// and not
-// bug378.go:19: 4 not used
+// bug381.go:29: 4 not used
+
+// Issue 2768: previously got
+// bug381.go:30: cannot use 3 (type time.Weekday) as type int in function argument
+// want
+// bug381.go:30: cannot use time.Wednesday (type time.Weekday) as type int in function argument
package main
-import "unsafe"
+import (
+ "time"
+ "unsafe"
+)
+
+func f(int)
func main() {
unsafe.Alignof(0) // ERROR "unsafe\.Alignof|value computed is not used"
+ f(time.Wednesday) // ERROR "time.Wednesday|incompatible type"
}
// $G $D/$F.dir/pkg.go && $G $D/$F.go || echo "Bug 382"
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file
+
// Issue 2529
package main
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// [ $O == 6 ] || errchk $G -e $D/$F.go
+// [ $A == 6 ] || errchk $G -e $D/$F.go
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// [ $O != 6 ] || errchk $G -e $D/$F.go
+// [ $A != 6 ] || errchk $G -e $D/$F.go
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package main
func main() { // ERROR "stack frame too large"
- var arr [1000200030]int
+ var arr [1000200030]int32
arr_bkup := arr
_ = arr_bkup
}
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo "Bug387"
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo "Issue2576"
+// compile
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Call of inlined method with blank receiver.
func (_ *T) M() int { return 1 }
func (t *T) MM() int { return t.M() }
+
+
+// One more like issue 2678
+type S struct { x, y int }
+type U []S
+
+func F4(S int) U { return U{{S,S}} }
+
+func F5() []*S {
+ return []*S{ {1,2}, { 3, 4} }
+}
+
+func F6(S int) *U {
+ return &U{{S,S}}
+}
+
+// Bug in the fix.
+
+type PB struct { x int }
+
+func (t *PB) Reset() { *t = PB{} }
// Use the functions in one.go so that the inlined
// forms get type-checked.
-package two
+package pkg2
import "./one"
one.F1(nil)
one.F2(nil)
one.F3()
+ one.F4(1)
var t *one.T
t.M()
t.MM()
}
+
+var V = []one.PB{{}, {}}
+
+func F() *one.PB
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Use the functions in pkg2.go so that the inlined
+// forms get type-checked.
+
+package pkg3
+
+import "./pkg2"
+
+var x = pkg2.F()
+var v = pkg2.V
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go || echo BUG: bug393
+// compile
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// issue 2672
// was trying binary search with an interface type
-package main
+package bug393
func f(x interface{}) int {
switch x {
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package one
+// Issue 2687
type T struct { int }
func New(i int) T { return T{i} }
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Used to crash compiler in interface type equality check.
+
+package p
+
+type I1 interface {
+ F() interface{I1}
+}
+
+type I2 interface {
+ F() interface{I2}
+}
+
+var v1 I1
+var v2 I2
+
+func f() bool {
+ return v1 == v2
+}
--- /dev/null
+// compile
+
+// 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 2674
+
+package main
+const dow = "\000\003"
+
+func main() {
+ println(int(dow[1]))
+}
+
--- /dev/null
+// run
+
+// 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 2582
+package main
+
+type T struct{}
+
+func (T) cplx() complex128 {
+ for false {
+ } // avoid inlining
+ return complex(1, 0)
+}
+
+func (T) cplx2() complex128 {
+ return complex(0, 1)
+}
+
+type I interface {
+ cplx() complex128
+}
+
+func main() {
+
+ var t T
+
+ if v := real(t.cplx()); v != 1 {
+ panic("not-inlined complex call failed")
+ }
+ _ = imag(t.cplx())
+
+ _ = real(t.cplx2())
+ if v := imag(t.cplx2()); v != 1 {
+ panic("potentially inlined complex call failed")
+ }
+
+ var i I
+ i = t
+ if v := real(i.cplx()); v != 1 {
+ panic("potentially inlined complex call failed")
+ }
+ _ = imag(i.cplx())
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "fmt"
+
+var a = []int64{
+ 0.0005 * 1e9,
+ 0.001 * 1e9,
+ 0.005 * 1e9,
+ 0.01 * 1e9,
+ 0.05 * 1e9,
+ 0.1 * 1e9,
+ 0.5 * 1e9,
+ 1 * 1e9,
+ 5 * 1e9,
+}
+
+func main() {
+ s := ""
+ for _, v := range a {
+ s += fmt.Sprint(v) + " "
+ }
+ if s != "500000 1000000 5000000 10000000 50000000 100000000 500000000 1000000000 5000000000 " {
+ panic(s)
+ }
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Crashed gccgo.
+
+package p
+
+type S struct {
+ f interface{}
+}
+
+func F(p *S) bool {
+ v := p.f
+ switch a := v.(type) {
+ case nil:
+ _ = a
+ return true
+ }
+ return true
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package one
+
+type T1 int
+type T2 []T1
+type T3 T2
+
+func F1(T2) {
+}
+
+func (p *T1) M1() T3 {
+ return nil
+}
+
+func (p T3) M2() {
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// The gccgo compiler would fail on the import statement.
+// two.go:10:13: error: use of undefined type ‘one.T2’
+
+package two
+
+import "./one"
+
+var V one.T3
--- /dev/null
+// compiledir
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test using _ receiver. Failed with gccgo.
+
+package main
+
+type S struct {}
+
+func (_ S) F(i int) int {
+ return i
+}
+
+func main() {
+ s := S{}
+ const c = 123
+ i := s.F(c)
+ if i != c {
+ panic(i)
+ }
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 2821
+package main
+
+type matrix struct {
+ e []int
+}
+
+func (a matrix) equal() bool {
+ for _ = range a.e {
+ }
+ return true
+}
+
+func main() {
+ var a matrix
+ var i interface{}
+ i = true && a.equal()
+ _ = i
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package one
+
+// Issue 2877
+type T struct {
+ f func(t *T, arg int)
+ g func(t T, arg int)
+}
+
+func (t *T) foo(arg int) {}
+func (t T) goo(arg int) {}
+
+func (t *T) F() { t.f = (*T).foo }
+func (t *T) G() { t.g = T.goo }
+
+
+
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Use the functions in one.go so that the inlined
+// forms get type-checked.
+
+package two
+
+import "./one"
+
+func use() {
+ var r one.T
+ r.F()
+}
--- /dev/null
+// compiledir
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
--- /dev/null
+// cmpout
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Multiple inlined calls to a function that causes
+// redundant address loads.
+
+package main
+
+func F(v [2]float64) [2]float64 {
+ return [2]float64{v[0], v[1]}
+}
+
+func main() {
+ a := F([2]float64{1, 2})
+ b := F([2]float64{3, 4})
+ println(a[0], a[1], b[0], b[1])
+}
--- /dev/null
++1.000000e+000 +2.000000e+000 +3.000000e+000 +4.000000e+000
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Used to run 6g out of registers. Issue 2669.
+
+package p
+
+type y struct {
+ num int
+}
+
+func zzz () {
+ k := make([]byte, 10)
+ arr := make ([]*y, 0)
+ for s := range arr {
+ x := make([]byte, 10)
+ for i := 0; i < 100 ; i++ {
+ x[i] ^= k[i-arr[s].num%0]
+ }
+ }
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 2588. Used to trigger internal compiler error on 8g,
+// because the compiler tried to registerize the int64 being
+// used as a memory operand of a int64->float64 move.
+
+package p
+
+func f1(a int64) {
+ f2(float64(a), float64(a))
+}
+
+func f2(a,b float64) {
+}
+
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type t struct {
+ x int // ERROR "duplicate field x|duplicate field name .x."
+ x int
+}
+
+func f(t *t) int {
+ return t.x // GC_ERROR "ambiguous selector t.x"
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func f(i int) int { return i }
+
+var i = func() int {a := f(i); return a}() // ERROR "initialization loop|depends upon itself"
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+ package main
+
+ import "./p1"
+
+ type MyObject struct {
+ p1.Fer
+ }
+
+ func main() {
+ var b p1.Fer = &p1.Object{}
+ p1.PrintFer(b)
+ var c p1.Fer = &MyObject{b}
+ p1.PrintFer(c)
+ }
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+ package p1
+
+ import "fmt"
+
+ type Fer interface {
+ f() string
+ }
+
+ type Object struct {}
+
+ func (this *Object) f() string {
+ return "Object.f"
+ }
+
+ func PrintFer(fer Fer) {
+ fmt.Sprintln(fer.f())
+ }
--- /dev/null
+// $G $D/$F.dir/p1.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type A struct {
+ s struct{int}
+}
+
+func (a *A) f() {
+ a.s = struct{int}{0}
+}
+
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+import "./p"
+func main() {}
+var _ p.A
+
--- /dev/null
+// compiledir
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 2716. Export metadata error made main.go not compile.
+
+package ignored
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type T struct {
+ X int
+}
+
+func (t *T) X() {} // ERROR "type T has both field and method named X|redeclares struct field name"
--- /dev/null
+// compile
+
+// 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.
+
+// Some indirect uses of types crashed gccgo, because it assumed that
+// the size of the type was known before it had been computed.
+
+package p
+
+type S1 struct {
+ p *[1]S3
+ s [][1]S3
+ m map[int][1]S3
+ c chan [1]S3
+ i interface { f([1]S3) [1]S3 }
+ f func([1]S3) [1]S3
+}
+
+type S2 struct {
+ p *struct { F S3 }
+ s []struct { F S3 }
+ m map[int]struct { F S3 }
+ c chan struct { F S3 }
+ i interface { f(struct { F S3 }) struct { F S3 } }
+ f func(struct { F S3 } ) struct { F S3 }
+}
+
+type S3 struct {
+ I int
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3044.
+// Multiple valued expressions in return lists.
+
+package p
+
+func Two() (a, b int)
+
+// F used to compile.
+func F() (x interface{}, y int) {
+ return Two(), 0 // ERROR "single-value context"
+}
+
+// Recursive used to trigger an internal compiler error.
+func Recursive() (x interface{}, y int) {
+ return Recursive(), 0 // ERROR "single-value context"
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 1811.
+// gccgo failed to compile this.
+
+package p
+
+type E interface{}
+
+type I interface {
+ E
+ E
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 1757.
+// gccgo failed to compile this.
+
+package main
+
+func main() {
+ (_) = 0
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 1927.
+// gccgo failed to issue the first error below.
+
+package main
+
+func main() {
+ println(int(1) == uint(1)) // ERROR "types"
+ var x int = 1
+ var y uint = 1
+ println(x == y) // ERROR "types"
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gccgo crashed compiling this file.
+
+package p
+
+var V = "a" > "b"
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gc used to overflow a counter when a variable was
+// mentioned 256 times, and generate stack corruption.
+
+package main
+
+func main() {
+ F(1)
+}
+
+func F(arg int) {
+ var X interface{}
+ _ = X // used once
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 32 times
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 64 times
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 96 times
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 128 times
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 200 times
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0
+ X = 0 // used 256 times
+ if arg != 1 {
+ panic("argument was changed")
+ }
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package lib
+
+type I interface {
+ m() string
+}
+
+type T struct{}
+
+// m is not accessible from outside this package.
+func (t *T) m() string {
+ return "lib.T.m"
+}
--- /dev/null
+// $G $D/$F.dir/lib.go && $G $D/$F.go && $L $F.$A && ./$A.out
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Tests that method calls through an interface always
+// call the locally defined method localT.m independent
+// at which embedding level it is and in which order
+// embedding is done.
+
+package main
+
+import "./lib"
+import "reflect"
+import "fmt"
+
+type localI interface {
+ m() string
+}
+
+type localT struct{}
+
+func (t *localT) m() string {
+ return "main.localT.m"
+}
+
+type myT1 struct {
+ localT
+}
+
+type myT2 struct {
+ localT
+ lib.T
+}
+
+type myT3 struct {
+ lib.T
+ localT
+}
+
+func main() {
+ var i localI
+
+ i = new(localT)
+ if i.m() != "main.localT.m" {
+ println("BUG: localT:", i.m(), "called")
+ }
+
+ i = new(myT1)
+ if i.m() != "main.localT.m" {
+ println("BUG: myT1:", i.m(), "called")
+ }
+
+ i = new(myT2)
+ if i.m() != "main.localT.m" {
+ println("BUG: myT2:", i.m(), "called")
+ }
+
+ t3 := new(myT3)
+ if t3.m() != "main.localT.m" {
+ println("BUG: t3:", t3.m(), "called")
+ }
+
+ i = new(myT3)
+ if i.m() != "main.localT.m" {
+ t := reflect.TypeOf(i)
+ n := t.NumMethod()
+ for j := 0; j < n; j++ {
+ m := t.Method(j)
+ fmt.Printf("#%d: %s.%s %s\n", j, m.PkgPath, m.Name, m.Type)
+ }
+ println("BUG: myT3:", i.m(), "called")
+ }
+
+ var t4 struct {
+ localT
+ lib.T
+ }
+ if t4.m() != "main.localT.m" {
+ println("BUG: t4:", t4.m(), "called")
+ }
+ i = &t4
+ if i.m() != "main.localT.m" {
+ println("BUG: myT4:", i.m(), "called")
+ }
+
+ var t5 struct {
+ lib.T
+ localT
+ }
+ if t5.m() != "main.localT.m" {
+ println("BUG: t5:", t5.m(), "called")
+ }
+ i = &t5
+ if i.m() != "main.localT.m" {
+ println("BUG: myT5:", i.m(), "called")
+ }
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// http://code.google.com/p/go/issues/detail?id=3119
+
+package main
+
+import "fmt"
+
+func main() {
+ s := "hello"
+ fmt.Println(s == "")
+ fmt.Println(s + "world" == "world")
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gccgo crashed compiling this.
+
+package p
+
+type T *T
+
+func f(t T) {
+ println(t, *t)
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// http://code.google.com/p/go/issues/detail?id=3351
+
+package main
+
+// struct with four fields of basic type
+type S struct {a, b, c, d int}
+
+// struct with five fields of basic type
+type T struct {a, b, c, d, e int}
+
+// array with four elements
+type A [4]int
+
+// array with five elements
+type B [5]int
+
+func main() {
+ var i interface{}
+
+ var s1, s2 S
+ i = s1 == s2
+
+ var t1, t2 T
+ i = t1 == t2
+
+ var a1, a2 A
+ i = a1 == a2
+
+ var b1, b2 B
+ i = b1 == b2
+
+ _ = i
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that when the compiler expands append inline it does not
+// overwrite a value before it needs it (issue 3369).
+
+package main
+
+func main() {
+ s := make([]byte, 5, 6)
+ copy(s, "12346")
+ s = append(s[:len(s)-1], '5', s[len(s)-1])
+ if string(s) != "123456" {
+ panic(s)
+ }
+}
--- /dev/null
+// $G $D/$F.go && $L $F.$A && ! ./$A.out || echo BUG: bug429
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Should print deadlock message, not hang.
+
+package main
+
+func main() {
+ select {}
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gccgo crashed compiling this.
+
+package main
+
+type S struct {
+ f [2][]int
+}
+
+func F() (r [2][]int) {
+ return
+}
+
+func main() {
+ var a []S
+ a[0].f = F()
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gccgo gave an invalid error ("floating point constant truncated to
+// integer") compiling this.
+
+package p
+
+const C = 1<<63 - 1
+
+func F(i int64) int64 {
+ return i
+}
+
+var V = F(int64(C) / 1e6)
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// gccgo crashed compiling this.
+
+package p
+
+var v struct{ I }
+
+type I interface{}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that initializing struct fields out of order still runs
+// functions in the right order. This failed with gccgo.
+
+package main
+
+type S struct {
+ i1, i2, i3 int
+}
+
+var G int
+
+func v(i int) int {
+ if i != G {
+ panic(i)
+ }
+ G = i + 1
+ return G
+}
+
+func F() S {
+ return S{
+ i1: v(0),
+ i3: v(1),
+ i2: v(2),
+ }
+}
+
+func main() {
+ s := F()
+ if s != (S{1, 3, 2}) {
+ panic(s)
+ }
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that typed and untyped negative zero floating point constants
+// are treated as equivalent to zero constants.
+
+package main
+
+import "math"
+
+const zero = 0.0
+
+func main() {
+ x := -zero
+ b := math.Float64bits(x)
+ if b != 0 {
+ panic(b)
+ }
+ x = -float64(zero)
+ b = math.Float64bits(x)
+ if b != 0 {
+ panic(b)
+ }
+ v := x
+ b = math.Float64bits(-v)
+ if b != 0x8000000000000000 {
+ panic(b)
+ }
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that a syntax error caused by an unexpected EOF
+// gives an error message with the correct line number.
+//
+// https://code.google.com/p/go/issues/detail?id=3392
+
+package main
+
+func foo() {
+ bar(1, // ERROR "unexpected|missing|undefined"
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Gccgo used to crash compiling this.
+
+package main
+
+func foo() (int, int) {
+ return 1, 2
+}
+
+var c = b
+var a, b = foo()
+var d = b + 1
+
+func main() {
+ if a != 1 {
+ panic(a)
+ }
+ if b != 2 {
+ panic(b)
+ }
+ if c != 2 {
+ panic(c)
+ }
+ if d != 3 {
+ panic(d)
+ }
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package one
+
+type I1 interface {
+ f()
+}
+
+type S1 struct {
+}
+
+func (s S1) f() {
+}
+
+func F1(i1 I1) {
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package two
+
+import "./one"
+
+type S2 struct {
+ one.S1
+}
--- /dev/null
+// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go && $G $D/$F.go && $L $F.$A && ./$A.out
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test converting a type defined in a different package to an
+// interface defined in a third package, where the interface has a
+// hidden method. This used to cause a link error with gccgo.
+
+package main
+
+import (
+ "./one"
+ "./two"
+)
+
+func F(i1 one.I1) {
+ switch v := i1.(type) {
+ case two.S2:
+ one.F1(v)
+ }
+}
+
+func main() {
+ F(nil)
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Gccgo used to incorrectly give an error when compiling this.
+
+package p
+
+func F() (i int) {
+ for first := true; first; first = false {
+ i++
+ }
+ return
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Gccgo used to crash compiling this.
+
+package p
+
+type E int
+
+func (e E) P() *E { return &e }
+
+const (
+ C1 E = 0
+ C2 = C1
+)
+
+func F() *E {
+ return C2.P()
+}
--- /dev/null
+// run
+
+// Test for 8g register move bug. The optimizer gets confused
+// about 16- vs 32-bit moves during splitContractIndex.
+
+// Issue 3910.
+
+package main
+
+func main() {
+ const c = 0x12345678
+ index, n, offset := splitContractIndex(c)
+ if index != int((c&0xffff)>>5) || n != int(c&(1<<5-1)) || offset != (c>>16)&(1<<14-1) {
+ println("BUG", index, n, offset)
+ }
+}
+
+func splitContractIndex(ce uint32) (index, n, offset int) {
+ h := uint16(ce)
+ return int(h >> 5), int(h & (1<<5 - 1)), int(ce>>16) & (1<<14 - 1)
+}
--- /dev/null
+// run
+
+// Test for 6g register move bug. The optimizer gets confused
+// about 32- vs 64-bit moves during splitContractIndex.
+
+// Issue 3918.
+
+package main
+
+func main() {
+ const c = 0x123400005678
+ index, offset := splitContractIndex(c)
+ if index != (c&0xffffffff)>>5 || offset != c+1 {
+ println("BUG", index, offset)
+ }
+}
+
+func splitContractIndex(ce uint64) (index uint32, offset uint64) {
+ h := uint32(ce)
+ return h >> 5, ce + 1
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Was discarding function calls made for arguments named _
+// in inlined functions. Issue 3593.
+
+package main
+
+var did int
+
+func main() {
+ foo(side())
+ foo2(side(), side())
+ foo3(side(), side())
+ T.m1(T(side()))
+ T(1).m2(side())
+ const want = 7
+ if did != want {
+ println("BUG: missing", want-did, "calls")
+ }
+}
+
+func foo(_ int) {}
+func foo2(_, _ int) {}
+func foo3(int, int) {}
+type T int
+func (_ T) m1() {}
+func (t T) m2(_ int) {}
+
+func side() int {
+ did++
+ return 1
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Used to crash generating hash and == functions for struct
+// with leading _ field. Issue 3607.
+
+package main
+
+type T struct {
+ _ int
+ X interface{}
+ _ string
+ Y float64
+}
+
+func main() {
+ m := map[T]int{}
+ m[T{X: 1, Y: 2}] = 1
+ m[T{X: 2, Y: 3}] = 2
+ m[T{X: 1, Y: 2}] = 3 // overwrites first entry
+ if len(m) != 2 {
+ println("BUG")
+ }
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Was failing to compile with 'invalid receiver' due to
+// incomplete type definition evaluation. Issue 3709.
+
+package p
+
+type T1 struct { F *T2 }
+type T2 T1
+
+type T3 T2
+func (*T3) M() // was invalid receiver
+
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// The no-op conversion here used to confuse the compiler
+// into doing a load-effective-address of nil.
+// See issue 3670.
+
+package main
+
+import "reflect"
+
+type T interface {}
+
+var x bool
+
+func main() {
+ reflect.TypeOf(nil)
+ reflect.TypeOf(T(nil)) // used to miscompile
+ shouldPanic()
+}
+
+func f() byte {
+ return []byte(nil)[0] // used to miscompile
+}
+
+func shouldPanic() {
+ defer func() {
+ if recover() == nil {
+ panic("not panicking")
+ }
+ }()
+ f()
+}
--- /dev/null
+// compile
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3765
+
+package main
+
+func f(x uint) uint {
+ m := ^(1 << x)
+ return uint(m)
+}
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3824.
+// Method calls are ignored when deciding initialization
+// order.
+
+package main
+
+type T int
+
+func (r T) Method1() int { return a }
+func (r T) Method2() int { return b }
+
+// dummy1 and dummy2 must be initialized after a and b.
+var dummy1 = T(0).Method1()
+var dummy2 = T.Method2(0)
+
+// Use a function call to force generating code.
+var a = identity(1)
+var b = identity(2)
+
+func identity(a int) int { return a }
+
+func main() {
+ if dummy1 != 1 {
+ panic("dummy1 != 1")
+ }
+ if dummy2 != 2 {
+ panic("dummy2 != 2")
+ }
+}
+
--- /dev/null
+// runoutput
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3804
+// test all possible float -> integer conversions
+
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "strings"
+)
+
+var (
+ intWidths = []int{8, 16, 32, 64} // int%d and uint%d
+ floatWidths = []int{32, 64} // float%d
+)
+
+func main() {
+
+ var names, funcs bytes.Buffer
+
+ for _, iWidth := range intWidths {
+ for _, typ := range []string{"int", "uint"} {
+ var segs bytes.Buffer
+ itype := fmt.Sprintf("%s%d", typ, iWidth)
+ names.WriteString("\ttest" + itype + ",\n")
+ for _, fWidth := range floatWidths {
+ ftype := fmt.Sprintf("float%d", fWidth)
+ seg := strings.Replace(testSegment, "$F", ftype, -1)
+ seg = strings.Replace(seg, "$I", itype, -1)
+ segs.WriteString(seg)
+ }
+ body := strings.Replace(testFunc, "$I", itype, -1)
+ if typ[0] == 'u' {
+ body = strings.Replace(body, "$TEST", " || i < 0", 1)
+ } else {
+ body = strings.Replace(body, "$TEST", "", 1)
+ }
+ body = strings.Replace(body, "$TESTSEGMENTS", segs.String(), 1)
+ funcs.WriteString(body)
+ }
+ }
+
+ program = strings.Replace(program, "$NAMES", names.String(), 1)
+ program = strings.Replace(program, "$FUNCS", funcs.String(), 1)
+ fmt.Print(program)
+}
+
+const testSegment = `
+ f$F := $F(f)
+ if math.Abs(float64(f$F) - f) < 0.05 {
+ if v := $I(f$F); v != $I(i) {
+ fmt.Printf("$I($F(%f)) = %v, expected %v\n", f, v, i)
+ }
+ }`
+
+const testFunc =
+`func test$I(f float64, i int64) {
+ if i != int64($I(i))$TEST {
+ return
+ }
+$TESTSEGMENTS
+}
+`
+
+var program =
+`package main
+
+import (
+ "fmt"
+ "math"
+)
+
+var tests = []struct {
+ f float64
+ i int64
+}{
+ {39.7, 39},
+ {-39.7, -39},
+ {258.6, 258},
+ {-258.6, -258},
+ {65538.9, 65538},
+ {-65538.9, -65538},
+ {4294967298.8, 4294967298},
+ {-4294967298.8, -4294967298},
+}
+
+var funcs = []func(float64, int64){
+$NAMES
+}
+
+$FUNCS
+func main() {
+ for _, t := range tests {
+ for _, f := range funcs {
+ f(t.f, t.i)
+ }
+ }
+}
+`
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package pkg1
+
+var x = make(chan interface{})
+
+func Do() int {
+ return (<-x).(int)
+}
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3843: inlining bug due to wrong receive operator precedence.
+
+package pkg2
+
+import "./pkg1"
+
+func F() {
+ pkg1.Do()
+}
+
--- /dev/null
+// compiledir
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
--- /dev/null
+// runoutput
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3866
+// runtime.equal failed to take padding between arguments and
+// return values into account, so in certain cases gc-generated
+// code will read a random bool from the stack as the result of
+// the comparison.
+// This program generates a lot of equality tests and hopes to
+// catch this.
+// NOTE: this program assumes comparing instance of T and T's
+// underlying []byte will make gc emit calls to runtime.equal,
+// and if gc optimizes this case, then the test will no longer
+// be correct (in the sense that it no longer tests runtime.equal).
+
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+const ntest = 1024
+
+func main() {
+ var decls, calls bytes.Buffer
+
+ for i := 1; i <= ntest; i++ {
+ s := strconv.Itoa(i)
+ decls.WriteString(strings.Replace(decl, "$", s, -1))
+ calls.WriteString(strings.Replace("call(test$)\n\t", "$", s, -1))
+ }
+
+ program = strings.Replace(program, "$DECLS", decls.String(), 1)
+ program = strings.Replace(program, "$CALLS", calls.String(), 1)
+ fmt.Print(program)
+}
+
+var program = `package main
+
+var count int
+
+func call(f func() bool) {
+ if f() {
+ count++
+ }
+}
+
+$DECLS
+
+func main() {
+ $CALLS
+ if count != 0 {
+ println("failed", count, "case(s)")
+ }
+}
+`
+
+const decl = `
+type T$ [$]uint8
+func test$() bool {
+ v := T${1}
+ return v == [$]uint8{2} || v != [$]uint8{1}
+}`
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3899: 8g incorrectly thinks a variable is
+// "set but not used" and elides an assignment, causing
+// variables to end up with wrong data.
+//
+// The reason is a miscalculation of variable width.
+
+package main
+
+func bar(f func()) {
+ f()
+}
+
+func foo() {
+ f := func() {}
+ if f == nil {
+ }
+ bar(f)
+}
+
+func main() {
+ foo()
+}
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+type T x.T // ERROR "undefined|expected package"
+
+// bogus "invalid recursive type"
--- /dev/null
+// run
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 3835: 8g tries to optimize arithmetic involving integer
+// constants, but can run out of registers in the process.
+
+package main
+
+var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G int
+
+func foo() int {
+ return a + 1 + b + 2 + c + 3 + d + 4 + e + 5 + f + 6 + g + 7 + h + 8 + i + 9 + j + 10 +
+ k + 1 + l + 2 + m + 3 + n + 4 + o + 5 + p + 6 + q + 7 + r + 8 + s + 9 + t + 10 +
+ u + 1 + v + 2 + w + 3 + x + 4 + y + 5 + z + 6 + A + 7 + B + 8 + C + 9 + D + 10 +
+ E + 1 + F + 2 + G + 3
+}
+
+func bar() int8 {
+ var (
+ W int16
+ X int32
+ Y int32
+ Z int32
+ )
+ return int8(W+int16(X+3)+3) * int8(Y+3+Z*3)
+}
+
+func main() {
+ if foo() == 0 {
+ panic("foo")
+ }
+ if bar() == 0 {
+ panic("bar")
+ }
+}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test floating-point literal syntax.
+
package main
var bad bool
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test floating-point comparison involving NaN.
+
package main
import "math"
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test for loops.
+
package main
func assertequal(is, shouldbe int, msg string) {
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple functions.
package main
-// errchk $G $F.go
+// errorcheck
// 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.
-// does not compile and should not compile
+// Test that result parameters are in the same scope as regular parameters.
+// Does not compile.
package main
-func f1(a int) (int, float32) { // BUG (not caught by compiler): multiple return values must have names
+func f1(a int) (int, float32) {
return 7, 7.0
}
-// $G $F.go || echo BUG: should compile
+// compile
// 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.
+// Test function signatures.
+// Compiled but not run.
+
package main
type t1 int
-// errchk $G $F.go
+// errorcheck
// 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.
+// Verify that illegal function signatures are detected.
+// Does not compile.
+
package main
type t1 int
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify that it is illegal to take the address of a function.
+// Does not compile.
+
package main
var notmain func()
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test functions and goroutines.
+
package main
func caller(f func(int, int) int, a, b int, c chan int) {
-// $G $D/$F.go
+// run
// 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 closures in if conditions.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 evaluation order in if condition.
+
package main
var calledf = false
--- /dev/null
+// run
+
+// 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 evaluation order.
+
+package main
+
+var calledf int
+
+func f() int {
+ calledf++
+ return 0
+}
+
+func g() int {
+ return calledf
+}
+
+var xy string
+
+func x() bool {
+ for false {
+ } // no inlining
+ xy += "x"
+ return false
+}
+
+func y() string {
+ for false {
+ } // no inlining
+ xy += "y"
+ return "abc"
+}
+
+func main() {
+ if f() == g() {
+ println("wrong f,g order")
+ }
+
+ if x() == (y() == "abc") {
+ panic("wrong compare")
+ }
+ if xy != "xy" {
+ println("wrong x,y order")
+ }
+}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Simple test of the garbage collector.
+
package main
import "runtime"
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// A simple test of the garbage collector.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Check that buffered channels are garbage collected properly.
+// Test that buffered channels are garbage collected properly.
// An interesting case because they have finalizers and used to
// have self loops that kept them from being collected.
// (Cyclic data with finalizers is never finalized, nor collected.)
== dwarf/
+== safe/
+
== fixedbugs/
+=========== fixedbugs/bug429.go
+throw: all goroutines are asleep - deadlock!
+
== bugs/
=========== bugs/bug395.go
bug395 is broken
+
+=========== bugs/bug434.go
+bugs/bug434.dir/two.go:10: one.t.int undefined (cannot refer to unexported field or method one.int)
+BUG:bug434
-// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that println can be the target of a go statement.
+
package main
import "time"
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify goto semantics.
+// Does not compile.
+//
// Each test is in a separate function just so that if the
// compiler stops processing after one error, we don't
// lose other ones.
+++ /dev/null
-// $G $F.go && $L $F.$A && ./$A.out
-
-// 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
-
-// ----------------------------------------------------------------------------
-// Helper functions
-
-func ASSERT(p bool) {
- if !p {
- // panic 0
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// Implementation of the HashMap
-
-type KeyType interface {
- Hash() uint32
- Match(other KeyType) bool
-}
-
-
-type ValueType interface {
- // empty interface
-}
-
-
-type Entry struct {
- key KeyType
- value ValueType
-}
-
-
-type Array [1024]Entry
-
-type HashMap struct {
- map_ *Array
- log2_capacity_ uint32
- occupancy_ uint32
-}
-
-
-func (m *HashMap) capacity() uint32 {
- return 1 << m.log2_capacity_
-}
-
-
-func (m *HashMap) Clear() {
- // Mark all entries as empty.
- var i uint32 = m.capacity() - 1
- for i > 0 {
- m.map_[i].key = nil
- i = i - 1
- }
- m.occupancy_ = 0
-}
-
-
-func (m *HashMap) Initialize (initial_log2_capacity uint32) {
- m.log2_capacity_ = initial_log2_capacity
- m.map_ = new(Array)
- m.Clear()
-}
-
-
-func (m *HashMap) Probe (key KeyType) *Entry {
- ASSERT(key != nil)
-
- var i uint32 = key.Hash() % m.capacity()
- ASSERT(0 <= i && i < m.capacity())
-
- ASSERT(m.occupancy_ < m.capacity()) // guarantees loop termination
- for m.map_[i].key != nil && !m.map_[i].key.Match(key) {
- i++
- if i >= m.capacity() {
- i = 0
- }
- }
-
- return &m.map_[i]
-}
-
-
-func (m *HashMap) Lookup (key KeyType, insert bool) *Entry {
- // Find a matching entry.
- var p *Entry = m.Probe(key)
- if p.key != nil {
- return p
- }
-
- // No entry found; insert one if necessary.
- if insert {
- p.key = key
- p.value = nil
- m.occupancy_++
-
- // Grow the map if we reached >= 80% occupancy.
- if m.occupancy_ + m.occupancy_/4 >= m.capacity() {
- m.Resize()
- p = m.Probe(key)
- }
-
- return p
- }
-
- // No entry found and none inserted.
- return nil
-}
-
-
-func (m *HashMap) Resize() {
- var hmap *Array = m.map_
- var n uint32 = m.occupancy_
-
- // Allocate a new map of twice the current size.
- m.Initialize(m.log2_capacity_ << 1)
-
- // Rehash all current entries.
- var i uint32 = 0
- for n > 0 {
- if hmap[i].key != nil {
- m.Lookup(hmap[i].key, true).value = hmap[i].value
- n = n - 1
- }
- i++
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// Test code
-
-type Number struct {
- x uint32
-}
-
-
-func (n *Number) Hash() uint32 {
- return n.x * 23
-}
-
-
-func (n *Number) Match(other KeyType) bool {
- // var y *Number = other
- // return n.x == y.x
- return false
-}
-
-
-func MakeNumber (x uint32) *Number {
- var n *Number = new(Number)
- n.x = x
- return n
-}
-
-
-func main() {
- // func (n int) int { return n + 1; }(1)
-
- //print "HashMap - gri 2/8/2008\n"
-
- var hmap *HashMap = new(HashMap)
- hmap.Initialize(0)
-
- var x1 *Number = MakeNumber(1001)
- var x2 *Number = MakeNumber(2002)
- var x3 *Number = MakeNumber(3003)
- _, _, _ = x1, x2, x3
-
- // this doesn't work I think...
- //hmap.Lookup(x1, true)
- //hmap.Lookup(x2, true)
- //hmap.Lookup(x3, true)
-
- //print "done\n"
-}
-// $G $F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// 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.
+// Test that we can do page 1 of the C book.
+
package main
func main() {
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test if statements in various forms.
+
package main
func assertequal(is, shouldbe int, msg string) {
-// $G $D/$F.go
+// compile
// 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 that when import gives multiple names
-// to a type, they're still all the same type
+// Test that when import gives multiple names
+// to a single type, they still all refer to the same type.
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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 for import conflicts
+// Verify that import conflicts are detected by the compiler.
+// Does not compile.
package main
-// true # used by import3
+// skip # used by import3
// 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.
+// Various declarations of exported variables and functions.
+// Imported by import3.go.
+
package p
var C1 chan <- chan int = (chan<- (chan int))(nil)
// $G $D/import2.go && $G $D/$F.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Check that all the types from import2.go made it
+// Test that all the types from import2.go made it
// intact and with the same meaning, by assigning to or using them.
package main
// $G $D/empty.go && errchk $G $D/$F.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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
+// Verify that various kinds of "imported and not used"
+// errors are caught by the compiler.
+// Does not compile.
-// various kinds of imported and not used
+package main
// standard
import "fmt" // ERROR "imported and not used.*fmt"
--- /dev/null
+// errorcheck
+
+// 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.
+
+// Verify that invalid imports are rejected by the compiler.
+// Does not compile.
+
+package main
+
+// Correct import paths.
+import _ "fmt"
+import _ `time`
+import _ "m\x61th"
+import _ "go/parser"
+
+// Correct import paths, but the packages don't exist.
+// Don't test.
+//import "a.b"
+//import "greek/αβ"
+
+// Import paths must be strings.
+import 42 // ERROR "import statement"
+import 'a' // ERROR "import statement"
+import 3.14 // ERROR "import statement"
+import 0.25i // ERROR "import statement"
+
+// Each of these pairs tests both `` vs "" strings
+// and also use of invalid characters spelled out as
+// escape sequences and written directly.
+// For example `"\x00"` tests import "\x00"
+// while "`\x00`" tests import `<actual-NUL-byte>`.
+import "" // ERROR "import path"
+import `` // ERROR "import path"
+import "\x00" // ERROR "import path"
+import `\x00` // ERROR "import path"
+import "\x7f" // ERROR "import path"
+import `\x7f` // ERROR "import path"
+import "a!" // ERROR "import path"
+import `a!` // ERROR "import path"
+import "a b" // ERROR "import path"
+import `a b` // ERROR "import path"
+import "a\\b" // ERROR "import path"
+import `a\\b` // ERROR "import path"
+import "\"`a`\"" // ERROR "import path"
+import `\"a\"` // ERROR "import path"
+import "\x80\x80" // ERROR "import path"
+import `\x80\x80` // ERROR "import path"
+import "\xFFFD" // ERROR "import path"
+import `\xFFFD` // ERROR "import path"
+
+// Invalid local imports.
+import "/foo" // ERROR "import path cannot be absolute path"
+import "c:/foo" // ERROR "import path contains invalid character"
// ./$A.out -pass 2 >tmp.go && errchk $G -e tmp.go
// rm -f tmp.go $A.out1
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Generate test of index and slice bounds checks.
+// The output is compiled and run.
package main
type quad struct { x, y, z, w int }
const (
- cj = 11
- ci int = 12
- ci32 int32 = 13
- ci64 int64 = 14
+ cj = 100011
+ ci int = 100012
+ ci8 int8 = 115
+ ci16 int16 = 10016
+ ci32 int32 = 100013
+ ci64 int64 = 100014
ci64big int64 = 1<<31
ci64bigger int64 = 1<<32
chuge = 1<<100
cnj = -2
cni int = -3
+ cni8 int8 = -6
+ cni16 int16 = -7
cni32 int32 = -4
cni64 int64 = -5
cni64big int64 = -1<<31
cnhuge = -1<<100
)
-var j int = 20
-var i int = 21
-var i32 int32 = 22
-var i64 int64 = 23
+var j int = 100020
+var i int = 100021
+var i8 int8 = 126
+var i16 int16 = 10025
+var i32 int32 = 100022
+var i64 int64 = 100023
var i64big int64 = 1<<31
var i64bigger int64 = 1<<32
var huge uint64 = 1<<64 - 1
var nj int = -10
var ni int = -11
+var ni8 int8 = -14
+var ni16 int16 = -15
var ni32 int32 = -12
var ni64 int64 = -13
var ni64big int64 = -1<<31
var aq [10]quad
var paq *[10]quad = &aq
+var sib []int = make([]int, 100000)
+var aib [100000]int
+var paib *[100000]int = &aib
+
+var sqb []quad = make([]quad, 100000)
+var aqb [100000]quad
+var paqb *[100000]quad = &aqb
+
type T struct {
si []int
ai [10]int
sq []quad
aq [10]quad
paq *[10]quad
+
+ sib []int
+ aib [100000]int
+ paib *[100000]int
+ sqb []quad
+ aqb [100000]quad
+ paqb *[100000]quad
}
-var t = T{si, ai, pai, sq, aq, paq}
+var t = T{si, ai, pai, sq, aq, paq, sib, aib, paib, sqb, aqb, paqb}
-var pt = &T{si, ai, pai, sq, aq, paq}
+var pt = &T{si, ai, pai, sq, aq, paq, sib, aib, paib, sqb, aqb, paqb}
// test that f panics
func test(f func(), s string) {
_, file, line, _ := runtime.Caller(2)
bug()
print(file, ":", line, ": ", s, " did not panic\n")
+ } else if !contains(err.(error).Error(), "out of range") {
+ _, file, line, _ := runtime.Caller(2)
+ bug()
+ print(file, ":", line, ": ", s, " unexpected panic: ", err.(error).Error(), "\n")
}
}()
f()
}
+func contains(x, y string) bool {
+ for i := 0; i+len(y) <= len(x); i++ {
+ if x[i:i+len(y)] == y {
+ return true
+ }
+ }
+ return false
+}
+
+
var X interface{}
func use(y interface{}) {
X = y
// Array, pointer to array, slice.
[]string{"a", "pa", "s"},
-
+
// Element is int, element is quad (struct).
// This controls whether we end up in gsubr.c (i) or cgen.c (q).
[]string{"i", "q"},
+ // Small or big len.
+ []string{"", "b"},
+
// Variable or constant.
[]string{"", "c"},
[]string{"", "n"},
// Size of index.
- []string{"j", "i", "i32", "i64", "i64big", "i64bigger", "huge"},
+ []string{"j", "i", "i8", "i16", "i32", "i64", "i64big", "i64bigger", "huge"},
}
forall(choices, func(x []string) {
- p, a, e, c, n, i := x[0], x[1], x[2], x[3], x[4], x[5]
+ p, a, e, big, c, n, i := x[0], x[1], x[2], x[3], x[4], x[5], x[6]
// Pass: dynamic=0, static=1, 2.
// Which cases should be caught statically?
thisPass = 2
}
}
+
+ // If we're using the big-len data, positive int8 and int16 cannot overflow.
+ if big == "b" && n == "" && (i == "i8" || i == "i16") {
+ return
+ }
// Only print the test case if it is appropriate for this pass.
if thisPass == *pass {
- pae := p+a+e
+ pae := p+a+e+big
cni := c+n+i
// Index operation
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG indirect
+// run
// 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.
+// Test various safe uses of indirection.
+
package main
var m0 map[string]int
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify that illegal uses of indirection are caught by the compiler.
+// Does not compile.
+
package main
var m0 map[string]int
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that erroneous use of init is detected.
+// Does not compile.
+
package main
import "runtime"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
c := make(chan int)
go send(c)
<-c
-
- const chunk = 1<<20
- runtime.UpdateMemStats()
- sys := runtime.MemStats.Sys
+
+ const chunk = 1 << 20
+ memstats := new(runtime.MemStats)
+ runtime.ReadMemStats(memstats)
+ sys := memstats.Sys
b := make([]byte, chunk)
for i := range b {
b[i] = byte(i%10 + '0')
for i := 0; i < 1000; i++ {
x = []byte(s)
}
- runtime.UpdateMemStats()
- sys1 := runtime.MemStats.Sys
+ runtime.ReadMemStats(memstats)
+ sys1 := memstats.Sys
if sys1-sys > chunk*50 {
println("allocated 1000 chunks of", chunk, "and used ", sys1-sys, "memory")
}
func main() {
}
-
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test trailing commas. DO NOT gofmt THIS FILE.
+
package main
-var a = []int{1, 2}
-var b = [5]int{1, 2, 3}
-var c = []int{1}
-var d = [...]int{1, 2, 3}
+var a = []int{1, 2, }
+var b = [5]int{1, 2, 3, }
+var c = []int{1, }
+var d = [...]int{1, 2, 3, }
func main() {
if len(a) != 2 {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test initialization of package-level variables.
+
package main
import "fmt"
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify that erroneous initialization expressions are caught by the compiler
+// Does not compile.
+
package main
type S struct {
+++ /dev/null
-// $G $D/$F.go && $L $F.$A && ./$A.out
-
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This used to crash because the scheduler
-// tried to kick off a new scheduling thread for f
-// when time.Nanoseconds went into the system call.
-// It's not okay to schedule new goroutines
-// until main has started.
-
-package main
-
-import "time"
-
-func f() {
-}
-
-func init() {
- go f()
- time.Now()
-}
-
-func main() {
-}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test integer literal syntax.
+
package main
import "os"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test implicit and explicit conversions of constants.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 that big vs small, pointer vs not
-// interface methods work.
+// Test big vs. small, pointer vs. value interface methods.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 uses of all the different interface
-// conversion runtime functions.
+// Test all the different interface conversion runtime functions.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 that static interface conversion of
-// interface value nil succeeds.
+// Test static interface conversion of interface value nil.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 that static interface conversion of
-// interface value nil succeeds.
+// Test static interface conversion of interface value nil.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 values.
+// Test methods derived from embedded interface values.
package main
-// true # used by embed1.go
+// skip # used by embed1.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 that embedded interface types can have local methods.
+// Test that embedded interface types can have local methods.
package p
// $G $D/embed0.go && $G $D/$F.go && $L $F.$A && ./$A.out
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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 that embedded interface types can have local methods.
+// Test that embedded interface types can have local methods.
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Test methods derived from embedded interface and *interface values.
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
-// Static error messages about interface conversions.
+// Verify compiler messages about erroneous static interface conversions.
+// Does not compile.
package main
var t *T
+type X int
+
+func (x *X) M() {}
+
type I interface {
M()
}
// because i has an extra method
// that t does not, so i cannot contain a t.
i = t // ERROR "incompatible|missing M method"
- t = i // ERROR "incompatible|need type assertion"
+ t = i // ERROR "incompatible|assignment$"
i = i2 // ok
i2 = i // ERROR "incompatible|missing N method"
var _ = m.(Int) // ERROR "impossible type assertion"
+var _ = m.(X) // ERROR "pointer receiver"
+
var ii int
var jj Int
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 that interface conversion fails when method is missing.
+// Test that interface conversion fails when method is missing.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Interface comparisons using types hidden
+// Test interface comparisons using types hidden
// inside reflected-on structs.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: interface/noeq
+// run
// 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.
-// Interface values containing types that cannot be compared for equality.
+// Test run-time error detection for interface values containing types
+// that cannot be compared for equality.
package main
-// errchk $G $D/$F.go
+// errorcheck
// 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 that interface{M()} = *interface{M()} produces a compiler error.
+// Test that interface{M()} = *interface{M()} produces a compiler error.
+// Does not compile.
package main
// $G $D/${F}1.go && errchk $G $D/$F.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that unexported methods are not visible outside the package.
+// Does not compile.
+
package main
import "./private1"
-// true # used by private.go
+// skip # used by private.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.
+// Imported by private.go, which should not be able to see the private method.
+
package p
type Exported interface {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Implicit methods for embedded types.
-// Mixed pointer and non-pointer receivers.
+// Test Implicit methods for embedded types and
+// mixed pointer and non-pointer receivers.
package main
-// errchk $G $D/$F.go
+// errorcheck
// 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.
-// Error messages about missing implicit methods.
+// Verify compiler complains about missing implicit methods.
+// Does not compile.
package main
-// $G $D/$F.go || echo BUG: should compile
+// compile
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Check mutually recursive interfaces
-package main
+package recursive
type I1 interface {
foo() I2
-// true # used by recursive2
+// skip # used by recursive2
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Mutually recursive type definitions imported and used by recursive1.go.
+
package p
type I1 interface {
// $G $D/recursive1.go && $G $D/$F.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Check that the mutually recursive types in recursive1.go made it
+// Test that the mutually recursive types in recursive1.go made it
// intact and with the same meaning, by assigning to or using them.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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 with different return types.
+// Test interface methods with different return types are distinct.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG interface6
+// run
// 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.
-// Interface values containing structures.
+// Test interface values containing structures.
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test iota.
+
package main
func assert(cond bool, msg string) {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test arrays and slices.
+
package main
func setpd(a []int) {
a = a[5:25]
res(sumpd(a), 5, 25)
+
+ a = a[30:95]
+ res(sumpd(a), 35, 100)
}
// call ptr fixed with ptr fixed
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test communication operations including select.
+
package main
import "os"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test communication with multiple simultaneous goroutines.
+
package main
import "runtime"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test composite literals.
+
package main
type M map[int]int
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test, near-exhaustive, of converting numbers between types.
+// No complex numbers though.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test trivial, bootstrap-level complex numbers, including printing.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test simple arithmetic and assignment for complex numbers.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test arithmetic on complex numbers, including multiplication and division.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test composition, decomposition, and reflection on complex numbers.
+
package main
import "unsafe"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test complex numbers,including fmt support.
+// Used to crash.
+
package main
import "fmt"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test compound types made of complex numbers.
+
package main
var a [12]complex128
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test integer division by constants.
+
package main
import "math/rand"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test integer division and modulus.
+
package main
const (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test embedded fields of structs, including methods.
+
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple for loop.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test interfaces on basic types.
+
package main
type myint int
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test interfaces and methods.
+
package main
type S struct {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test interface assignment.
+
package main
type Iputs interface {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test goto and labels.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple function literals.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple multi-argument multi-valued function.
+
package main
func
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test integer modulus by contstants.
+
package main
import "math/rand"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test method invocation with pointer receivers and function-valued fields.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test pointers and the . (selector) operator on structs.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test 'for range' on arrays, slices, and maps.
+
package main
const size = 16
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test general operation using a list implementation.
+
package main
type Item interface {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test general operation using s-list.
+// First Go program ever run (although not in this exact form).
+
package main
import "fmt"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test for loops of many forms.
+
package main
func assertequal(is, shouldbe int, msg string) {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test functions of many signatures.
+
package main
func assertequal(is, shouldbe int, msg string) {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test shift.
+
package main
var ians [18]int;
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple operations on arrays.
+
package main
var b[10] float32;
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test basic operations on bool.
+
package main
type s struct {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple arithmetic conversion.
+
package main
type vlong int64
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple functions.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple switch.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test scoping of variables.
+
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test basic operations of slices and arrays.
+
package main
var bx [10]byte
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test slicing and re-slicing.
+
package main
var bx []byte
-// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// 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.
+// Test string operations including printing.
package main
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test struct-valued variables (not pointers).
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
-// Pass 1 label errors.
+// Verify that erroneous labels are caught by the compiler.
+// This set is caught by pass 1.
+// Does not compile.
package main
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
-// Pass 2 label errors.
+
+// Verify that erroneous labels are caught by the compiler.
+// This set is caught by pass 2. That's why this file is label1.go.
+// Does not compile.
package main
--- /dev/null
+// $G $D/$F.go && $L -X main.tbd hello $F.$A && ./$A.out
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test the -X facility of the gc linker (6l etc.).
+
+package main
+
+var tbd string
+
+func main() {
+ if tbd != "hello" {
+ println("BUG: test/linkx", len(tbd), tbd)
+ }
+}
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test literal syntax for basic types.
+
package main
var nbad int
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// trivial finalizer test
+// Test basic operation of finalizers.
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test maps, almost exhaustively.
+
package main
import (
"fmt"
+ "math"
"strconv"
+ "time"
)
const count = 100
}
func main() {
+ testbasic()
+ testfloat()
+ testnan()
+}
+
+func testbasic() {
// Test a map literal.
mlit := map[string]int{"0": 0, "1": 1, "2": 2, "3": 3, "4": 4}
for i := 0; i < len(mlit); i++ {
mipM[i][i]++
if mipM[i][i] != (i+1)+1 {
- fmt.Printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i])
+ fmt.Printf("update mipM[%d][%d] = %d\n", i, i, mipM[i][i])
}
}
panic("range mnil")
}
}
+
+func testfloat() {
+ // Test floating point numbers in maps.
+ // Two map keys refer to the same entry if the keys are ==.
+ // The special cases, then, are that +0 == -0 and that NaN != NaN.
+
+ {
+ var (
+ pz = float32(0)
+ nz = math.Float32frombits(1 << 31)
+ nana = float32(math.NaN())
+ nanb = math.Float32frombits(math.Float32bits(nana) ^ 2)
+ )
+
+ m := map[float32]string{
+ pz: "+0",
+ nana: "NaN",
+ nanb: "NaN",
+ }
+ if m[pz] != "+0" {
+ fmt.Println("float32 map cannot read back m[+0]:", m[pz])
+ }
+ if m[nz] != "+0" {
+ fmt.Println("float32 map does not treat", pz, "and", nz, "as equal for read")
+ fmt.Println("float32 map does not treat -0 and +0 as equal for read")
+ }
+ m[nz] = "-0"
+ if m[pz] != "-0" {
+ fmt.Println("float32 map does not treat -0 and +0 as equal for write")
+ }
+ if _, ok := m[nana]; ok {
+ fmt.Println("float32 map allows NaN lookup (a)")
+ }
+ if _, ok := m[nanb]; ok {
+ fmt.Println("float32 map allows NaN lookup (b)")
+ }
+ if len(m) != 3 {
+ fmt.Println("float32 map should have 3 entries:", m)
+ }
+ m[nana] = "NaN"
+ m[nanb] = "NaN"
+ if len(m) != 5 {
+ fmt.Println("float32 map should have 5 entries:", m)
+ }
+ }
+
+ {
+ var (
+ pz = float64(0)
+ nz = math.Float64frombits(1 << 63)
+ nana = float64(math.NaN())
+ nanb = math.Float64frombits(math.Float64bits(nana) ^ 2)
+ )
+
+ m := map[float64]string{
+ pz: "+0",
+ nana: "NaN",
+ nanb: "NaN",
+ }
+ if m[nz] != "+0" {
+ fmt.Println("float64 map does not treat -0 and +0 as equal for read")
+ }
+ m[nz] = "-0"
+ if m[pz] != "-0" {
+ fmt.Println("float64 map does not treat -0 and +0 as equal for write")
+ }
+ if _, ok := m[nana]; ok {
+ fmt.Println("float64 map allows NaN lookup (a)")
+ }
+ if _, ok := m[nanb]; ok {
+ fmt.Println("float64 map allows NaN lookup (b)")
+ }
+ if len(m) != 3 {
+ fmt.Println("float64 map should have 3 entries:", m)
+ }
+ m[nana] = "NaN"
+ m[nanb] = "NaN"
+ if len(m) != 5 {
+ fmt.Println("float64 map should have 5 entries:", m)
+ }
+ }
+
+ {
+ var (
+ pz = complex64(0)
+ nz = complex(0, math.Float32frombits(1<<31))
+ nana = complex(5, float32(math.NaN()))
+ nanb = complex(5, math.Float32frombits(math.Float32bits(float32(math.NaN()))^2))
+ )
+
+ m := map[complex64]string{
+ pz: "+0",
+ nana: "NaN",
+ nanb: "NaN",
+ }
+ if m[nz] != "+0" {
+ fmt.Println("complex64 map does not treat -0 and +0 as equal for read")
+ }
+ m[nz] = "-0"
+ if m[pz] != "-0" {
+ fmt.Println("complex64 map does not treat -0 and +0 as equal for write")
+ }
+ if _, ok := m[nana]; ok {
+ fmt.Println("complex64 map allows NaN lookup (a)")
+ }
+ if _, ok := m[nanb]; ok {
+ fmt.Println("complex64 map allows NaN lookup (b)")
+ }
+ if len(m) != 3 {
+ fmt.Println("complex64 map should have 3 entries:", m)
+ }
+ m[nana] = "NaN"
+ m[nanb] = "NaN"
+ if len(m) != 5 {
+ fmt.Println("complex64 map should have 5 entries:", m)
+ }
+ }
+
+ {
+ var (
+ pz = complex128(0)
+ nz = complex(0, math.Float64frombits(1<<63))
+ nana = complex(5, float64(math.NaN()))
+ nanb = complex(5, math.Float64frombits(math.Float64bits(float64(math.NaN()))^2))
+ )
+
+ m := map[complex128]string{
+ pz: "+0",
+ nana: "NaN",
+ nanb: "NaN",
+ }
+ if m[nz] != "+0" {
+ fmt.Println("complex128 map does not treat -0 and +0 as equal for read")
+ }
+ m[nz] = "-0"
+ if m[pz] != "-0" {
+ fmt.Println("complex128 map does not treat -0 and +0 as equal for write")
+ }
+ if _, ok := m[nana]; ok {
+ fmt.Println("complex128 map allows NaN lookup (a)")
+ }
+ if _, ok := m[nanb]; ok {
+ fmt.Println("complex128 map allows NaN lookup (b)")
+ }
+ if len(m) != 3 {
+ fmt.Println("complex128 map should have 3 entries:", m)
+ }
+ m[nana] = "NaN"
+ m[nanb] = "NaN"
+ if len(m) != 5 {
+ fmt.Println("complex128 map should have 5 entries:", m)
+ }
+ }
+}
+
+func testnan() {
+ // Test that NaNs in maps don't go quadratic.
+ t := func(n int) time.Duration {
+ t0 := time.Now()
+ m := map[float64]int{}
+ nan := math.NaN()
+ for i := 0; i < n; i++ {
+ m[nan] = 1
+ }
+ if len(m) != n {
+ panic("wrong size map after nan insertion")
+ }
+ return time.Since(t0)
+ }
+
+ // Depending on the machine and OS, this test might be too fast
+ // to measure with accurate enough granularity. On failure,
+ // make it run longer, hoping that the timing granularity
+ // is eventually sufficient.
+
+ n := 30000 // 0.02 seconds on a MacBook Air
+ fails := 0
+ for {
+ t1 := t(n)
+ t2 := t(2 * n)
+ // should be 2x (linear); allow up to 3x
+ if t2 < 3*t1 {
+ return
+ }
+ fails++
+ if fails == 4 {
+ fmt.Printf("too slow: %d inserts: %v; %d inserts: %v\n", n, t1, 2*n, t2)
+ return
+ }
+ n *= 2
+ }
+}
-// errchk $G -e $D/$F.go
+// errorcheck
// 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 map declarations of many types, including erroneous ones.
+// Does not compile.
+
package main
func main() {}
_ map[[]int]v // ERROR "invalid map key"
_ map[func()]v // ERROR "invalid map key"
_ map[map[int]int]v // ERROR "invalid map key"
+ _ map[T1]v // ERROR "invalid map key"
+ _ map[T2]v // ERROR "invalid map key"
+ _ map[T3]v // ERROR "invalid map key"
+ _ map[T4]v // ERROR "invalid map key"
+ _ map[T5]v
+ _ map[T6]v
+ _ map[T7]v
+ _ map[T8]v
)
+
+type T1 []int
+type T2 struct { F T1 }
+type T3 []T4
+type T4 struct { F T3 }
+
+type T5 *int
+type T6 struct { F T5 }
+type T7 *T4
+type T8 struct { F *T7 }
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple methods of various types, with pointer and
+// value receivers.
+
package main
type S string
}
if val(s) != 1 {
- println("s.val:", val(s))
+ println("val(s):", val(s))
panic("fail")
}
if val(ps) != 2 {
- println("ps.val:", val(ps))
+ println("val(ps):", val(ps))
panic("fail")
}
if val(i) != 3 {
- println("i.val:", val(i))
+ println("val(i):", val(i))
panic("fail")
}
if val(pi) != 4 {
- println("pi.val:", val(pi))
+ println("val(pi):", val(pi))
panic("fail")
}
if val(t) != 7 {
- println("t.val:", val(t))
+ println("val(t):", val(t))
panic("fail")
}
if val(pt) != 8 {
- println("pt.val:", val(pt))
+ println("val(pt):", val(pt))
panic("fail")
}
println("Val.val(v):", Val.val(v))
panic("fail")
}
+
+ var zs struct { S }
+ var zps struct { *S1 }
+ var zi struct { I }
+ var zpi struct { *I1 }
+ var zpt struct { *T1 }
+ var zt struct { T }
+ var zv struct { Val }
+
+ if zs.val() != 1 {
+ println("zs.val:", zs.val())
+ panic("fail")
+ }
+ if zps.val() != 2 {
+ println("zps.val:", zps.val())
+ panic("fail")
+ }
+ if zi.val() != 3 {
+ println("zi.val:", zi.val())
+ panic("fail")
+ }
+ if zpi.val() != 4 {
+ println("zpi.val:", zpi.val())
+ panic("fail")
+ }
+ if zt.val() != 7 {
+ println("zt.val:", zt.val())
+ panic("fail")
+ }
+ if zpt.val() != 8 {
+ println("zpt.val:", zpt.val())
+ panic("fail")
+ }
+
+ if val(zs) != 1 {
+ println("val(zs):", val(zs))
+ panic("fail")
+ }
+ if val(zps) != 2 {
+ println("val(zps):", val(zps))
+ panic("fail")
+ }
+ if val(zi) != 3 {
+ println("val(zi):", val(zi))
+ panic("fail")
+ }
+ if val(zpi) != 4 {
+ println("val(zpi):", val(zpi))
+ panic("fail")
+ }
+ if val(zt) != 7 {
+ println("val(zt):", val(zt))
+ panic("fail")
+ }
+ if val(zpt) != 8 {
+ println("val(zpt):", val(zpt))
+ panic("fail")
+ }
+
+ zv.Val = zi
+ if zv.val() != 3 {
+ println("zv.val():", zv.val())
+ panic("fail")
+ }
+
+ if (&zs).val() != 1 {
+ println("(&zs).val:", (&zs).val())
+ panic("fail")
+ }
+ if (&zps).val() != 2 {
+ println("(&zps).val:", (&zps).val())
+ panic("fail")
+ }
+ if (&zi).val() != 3 {
+ println("(&zi).val:", (&zi).val())
+ panic("fail")
+ }
+ if (&zpi).val() != 4 {
+ println("(&zpi).val:", (&zpi).val())
+ panic("fail")
+ }
+ if (&zt).val() != 7 {
+ println("(&zt).val:", (&zt).val())
+ panic("fail")
+ }
+ if (&zpt).val() != 8 {
+ println("(&zpt).val:", (&zpt).val())
+ panic("fail")
+ }
+
+ if val(&zs) != 1 {
+ println("val(&zs):", val(&zs))
+ panic("fail")
+ }
+ if val(&zps) != 2 {
+ println("val(&zps):", val(&zps))
+ panic("fail")
+ }
+ if val(&zi) != 3 {
+ println("val(&zi):", val(&zi))
+ panic("fail")
+ }
+ if val(&zpi) != 4 {
+ println("val(&zpi):", val(&zpi))
+ panic("fail")
+ }
+ if val(&zt) != 7 {
+ println("val(&zt):", val(&zt))
+ panic("fail")
+ }
+ if val(&zpt) != 8 {
+ println("val(&zpt):", val(&zpt))
+ panic("fail")
+ }
+
+ zv.Val = &zi
+ if zv.val() != 3 {
+ println("zv.val():", zv.val())
+ panic("fail")
+ }
}
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify that method redeclarations are caught by the compiler.
+// Does not compile.
+
package main
type T struct { }
-// errchk $G $D/$F.go
+// errorcheck
// 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.
+// Verify that pointers and interface types cannot be method receivers.
+// Does not compile.
+
package main
type T struct {
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG method3
+// run
// 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.
-// test that methods on slices work
+// Test methods on slices.
package main
--- /dev/null
+// $G $D/method4a.go && $G $D/$F.go && $L $F.$A && ./$A.out
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test method expressions with arguments.
+
+package main
+
+import "./method4a"
+
+type T1 int
+
+type T2 struct {
+ f int
+}
+
+type I1 interface {
+ Sum([]int, int) int
+}
+
+type I2 interface {
+ Sum(a []int, b int) int
+}
+
+func (i T1) Sum(a []int, b int) int {
+ r := int(i) + b
+ for _, v := range a {
+ r += v
+ }
+ return r
+}
+
+func (p *T2) Sum(a []int, b int) int {
+ r := p.f + b
+ for _, v := range a {
+ r += v
+ }
+ return r
+}
+
+func eq(v1, v2 int) {
+ if v1 != v2 {
+ panic(0)
+ }
+}
+
+func main() {
+ a := []int{1, 2, 3}
+ t1 := T1(4)
+ t2 := &T2{4}
+
+ eq(t1.Sum(a, 5), 15)
+ eq(t2.Sum(a, 6), 16)
+
+ eq(T1.Sum(t1, a, 7), 17)
+ eq((*T2).Sum(t2, a, 8), 18)
+
+ f1 := T1.Sum
+ eq(f1(t1, a, 9), 19)
+ f2 := (*T2).Sum
+ eq(f2(t2, a, 10), 20)
+
+ eq(I1.Sum(t1, a, 11), 21)
+ eq(I1.Sum(t2, a, 12), 22)
+
+ f3 := I1.Sum
+ eq(f3(t1, a, 13), 23)
+ eq(f3(t2, a, 14), 24)
+
+ eq(I2.Sum(t1, a, 15), 25)
+ eq(I2.Sum(t2, a, 16), 26)
+
+ f4 := I2.Sum
+ eq(f4(t1, a, 17), 27)
+ eq(f4(t2, a, 18), 28)
+
+ mt1 := method4a.T1(4)
+ mt2 := &method4a.T2{4}
+
+ eq(mt1.Sum(a, 30), 40)
+ eq(mt2.Sum(a, 31), 41)
+
+ eq(method4a.T1.Sum(mt1, a, 32), 42)
+ eq((*method4a.T2).Sum(mt2, a, 33), 43)
+
+ g1 := method4a.T1.Sum
+ eq(g1(mt1, a, 34), 44)
+ g2 := (*method4a.T2).Sum
+ eq(g2(mt2, a, 35), 45)
+
+ eq(method4a.I1.Sum(mt1, a, 36), 46)
+ eq(method4a.I1.Sum(mt2, a, 37), 47)
+
+ g3 := method4a.I1.Sum
+ eq(g3(mt1, a, 38), 48)
+ eq(g3(mt2, a, 39), 49)
+
+ eq(method4a.I2.Sum(mt1, a, 40), 50)
+ eq(method4a.I2.Sum(mt2, a, 41), 51)
+
+ g4 := method4a.I2.Sum
+ eq(g4(mt1, a, 42), 52)
+ eq(g4(mt2, a, 43), 53)
+}
--- /dev/null
+// skip
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test method expressions with arguments.
+// This file is not tested by itself; it is imported by method4.go.
+
+package method4a
+
+type T1 int
+
+type T2 struct {
+ F int
+}
+
+type I1 interface {
+ Sum([]int, int) int
+}
+
+type I2 interface {
+ Sum(a []int, b int) int
+}
+
+func (i T1) Sum(a []int, b int) int {
+ r := int(i) + b
+ for _, v := range a {
+ r += v
+ }
+ return r
+}
+
+func (p *T2) Sum(a []int, b int) int {
+ r := p.F + b
+ for _, v := range a {
+ r += v
+ }
+ return r
+}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Test that basic operations on named types are valid
// and preserve the type.
+// Does not compile.
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test nil.
+
package main
import (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that the implementation catches nil ptr indirection
+// in a large address space.
+
package main
import "unsafe"
// errchk $G -e tmp.go
// rm -f tmp.go
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
-// $G $D/$F.go
+// compile
// 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.
+// Test that types can be parenthesized.
+
package main
func f(interface{})
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test that heavy recursion works. Simple torture test for
+// segmented stacks: do math in unary by recursion.
+
package main
type Number *Number
-// $G $F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+// cmpout
// 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.
+// Test that big numbers work as constants and print can print them.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test the 'for range' construct.
+
package main
// test range over channels
println("wrong sum ranging over makeslice")
panic("fail")
}
+
+ x := []int{10, 20}
+ y := []int{99}
+ i := 1
+ for i, x[i] = range y {
+ break
+ }
+ if i != 0 || x[0] != 10 || x[1] != 99 {
+ println("wrong parallel assignment", i, x[0], x[1])
+ panic("fail")
+ }
}
func testslice1() {
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
die()
}
}
+
+func varargs(s *int, a ...int) {
+ *s = 0
+ for _, v := range a {
+ *s += v
+ }
+ if recover() != nil {
+ *s += 100
+ }
+}
+
+func test8a() (r int) {
+ defer varargs(&r, 1, 2, 3)
+ panic(0)
+}
+
+func test8b() (r int) {
+ defer varargs(&r, 4, 5, 6)
+ return
+}
+
+func test8() {
+ if test8a() != 106 || test8b() != 15 {
+ println("wrong value")
+ die()
+ }
+}
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test recovering from runtime errors.
+
package main
import (
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test that predeclared names can be redeclared by the user.
+
package main
import "fmt"
func main() {
n :=
- bool +
+ append +
+ bool +
byte +
- float +
+ complex +
+ complex64 +
+ complex128 +
+ cap +
+ close +
+ delete +
+ error +
+ false +
float32 +
float64 +
+ imag +
int +
int8 +
int16 +
int32 +
int64 +
+ len +
+ make +
+ new +
+ nil +
+ panic +
+ print +
+ println +
+ real +
+ recover +
+ rune +
+ string +
+ true +
uint +
uint8 +
uint16 +
uint32 +
uint64 +
uintptr +
- true +
- false +
- iota +
- nil +
- cap +
- len +
- make +
- new +
- panic +
- print +
- println
- if n != 27*28/2 {
- fmt.Println("BUG: wrong n", n, 27*28/2)
+ iota
+ if n != NUM*(NUM-1)/2 {
+ fmt.Println("BUG: wrong n", n, NUM*(NUM-1)/2)
}
}
const (
- bool = 1
- byte = 2
- float = 3
- float32 = 4
- float64 = 5
- int = 6
- int8 = 7
- int16 = 8
- int32 = 9
- int64 = 10
- uint = 11
- uint8 = 12
- uint16 = 13
- uint32 = 14
- uint64 = 15
- uintptr = 16
- true = 17
- false = 18
- iota = 19
- nil = 20
- cap = 21
- len = 22
- make = 23
- new = 24
- panic = 25
- print = 26
- println = 27
+ // cannot use iota here, because iota = 38 below
+ append = 1
+ bool = 2
+ byte = 3
+ complex = 4
+ complex64 = 5
+ complex128 = 6
+ cap = 7
+ close = 8
+ delete = 9
+ error = 10
+ false = 11
+ float32 = 12
+ float64 = 13
+ imag = 14
+ int = 15
+ int8 = 16
+ int16 = 17
+ int32 = 18
+ int64 = 19
+ len = 20
+ make = 21
+ new = 22
+ nil = 23
+ panic = 24
+ print = 25
+ println = 26
+ real = 27
+ recover = 28
+ rune = 29
+ string = 30
+ true = 31
+ uint = 32
+ uint8 = 33
+ uint16 = 34
+ uint32 = 35
+ uint64 = 36
+ uintptr = 37
+ iota = 38
+ NUM = 39
)
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify that renamed identifiers no longer have their old meaning.
+// Does not compile.
+
package main
func main() {
var n byte // ERROR "not a type|expected type"
- var y = float(0) // ERROR "cannot call|expected function"
+ var y = float32(0) // ERROR "cannot call|expected function"
const (
a = 1 + iota // ERROR "string|incompatible types" "convert iota"
)
}
const (
- bool = 1
- byte = 2
- float = 3
- float32 = 4
- float64 = 5
- int = 6
- int8 = 7
- int16 = 8
- int32 = 9
- int64 = 10
- uint = 11
- uint8 = 12
- uint16 = 13
- uint32 = 14
- uint64 = 15
- uintptr = 16
- true = 17
- false = 18
- iota = "abc"
- nil = 20
- cap = 21
- len = 22
- make = 23
- new = 24
- panic = 25
- print = 26
- println = 27
+ append = 1
+ bool = 2
+ byte = 3
+ complex = 4
+ complex64 = 5
+ complex128 = 6
+ cap = 7
+ close = 8
+ delete = 9
+ error = 10
+ false = 11
+ float32 = 12
+ float64 = 13
+ imag = 14
+ int = 15
+ int8 = 16
+ int16 = 17
+ int32 = 18
+ int64 = 19
+ len = 20
+ make = 21
+ new = 22
+ nil = 23
+ panic = 24
+ print = 25
+ println = 26
+ real = 27
+ recover = 28
+ rune = 29
+ string = 30
+ true = 31
+ uint = 32
+ uint8 = 33
+ uint16 = 34
+ uint32 = 35
+ uint64 = 36
+ uintptr = 37
+ iota = "38"
)
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// Check reordering of assignments.
+// Test reordering of assignments.
package main
p6()
p7()
p8()
+ p9()
}
var gx []int
i := 0
i, x[i], x[5] = 1, 100, 500
}
+
+func p9() {
+ m := make(map[int]int)
+ m[0] = len(m)
+ if m[0] != 0 {
+ panic(m[0])
+ }
+}
--- /dev/null
+// run
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test reorderings; derived from fixedbugs/bug294.go.
+
+package main
+
+var log string
+
+type TT int
+
+func (t TT) a(s string) TT {
+ log += "a(" + s + ")"
+ return t
+}
+
+func (TT) b(s string) string {
+ log += "b(" + s + ")"
+ return s
+}
+
+type F func(s string) F
+
+func a(s string) F {
+ log += "a(" + s + ")"
+ return F(a)
+}
+
+func b(s string) string {
+ log += "b(" + s + ")"
+ return s
+}
+
+type I interface {
+ a(s string) I
+ b(s string) string
+}
+
+type T1 int
+
+func (t T1) a(s string) I {
+ log += "a(" + s + ")"
+ return t
+}
+
+func (T1) b(s string) string {
+ log += "b(" + s + ")"
+ return s
+}
+
+// f(g(), h()) where g is not inlinable but h is will have the same problem.
+// As will x := g() + h() (same conditions).
+// And g() <- h().
+func f(x, y string) {
+ log += "f(" + x + ", " + y + ")"
+}
+
+func ff(x, y string) {
+ for false {
+ } // prevent inl
+ log += "ff(" + x + ", " + y + ")"
+}
+
+func h(x string) string {
+ log += "h(" + x + ")"
+ return x
+}
+
+func g(x string) string {
+ for false {
+ } // prevent inl
+ log += "g(" + x + ")"
+ return x
+}
+
+func main() {
+ err := 0
+ var t TT
+ if a("1")("2")("3"); log != "a(1)a(2)a(3)" {
+ println("expecting a(1)a(2)a(3) , got ", log)
+ err++
+ }
+ log = ""
+
+ if t.a("1").a(t.b("2")); log != "a(1)b(2)a(2)" {
+ println("expecting a(1)b(2)a(2), got ", log)
+ err++
+ }
+ log = ""
+ if a("3")(b("4"))(b("5")); log != "a(3)b(4)a(4)b(5)a(5)" {
+ println("expecting a(3)b(4)a(4)b(5)a(5), got ", log)
+ err++
+ }
+ log = ""
+ var i I = T1(0)
+ if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)b(7)a(7)b(8)a(8)b(9)a(9)" {
+ println("expecting a(6)ba(7)ba(8)ba(9), got", log)
+ err++
+ }
+ log = ""
+
+ if s := t.a("1").b("3"); log != "a(1)b(3)" || s != "3" {
+ println("expecting a(1)b(3) and 3, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if s := t.a("1").a(t.b("2")).b("3") + t.a("4").b("5"); log != "a(1)b(2)a(2)b(3)a(4)b(5)" || s != "35" {
+ println("expecting a(1)b(2)a(2)b(3)a(4)b(5) and 35, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if s := t.a("4").b("5") + t.a("1").a(t.b("2")).b("3"); log != "a(4)b(5)a(1)b(2)a(2)b(3)" || s != "53" {
+ println("expecting a(4)b(5)a(1)b(2)a(2)b(3) and 35, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if ff(g("1"), g("2")); log != "g(1)g(2)ff(1, 2)" {
+ println("expecting g(1)g(2)ff..., got ", log)
+ err++
+ }
+ log = ""
+
+ if ff(g("1"), h("2")); log != "g(1)h(2)ff(1, 2)" {
+ println("expecting g(1)h(2)ff..., got ", log)
+ err++
+ }
+ log = ""
+
+ if ff(h("1"), g("2")); log != "h(1)g(2)ff(1, 2)" {
+ println("expecting h(1)g(2)ff..., got ", log)
+ err++
+ }
+ log = ""
+
+ if ff(h("1"), h("2")); log != "h(1)h(2)ff(1, 2)" {
+ println("expecting h(1)h(2)ff..., got ", log)
+ err++
+ }
+ log = ""
+
+ if s := g("1") + g("2"); log != "g(1)g(2)" || s != "12" {
+ println("expecting g1g2 and 12, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if s := g("1") + h("2"); log != "g(1)h(2)" || s != "12" {
+ println("expecting g1h2 and 12, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if s := h("1") + g("2"); log != "h(1)g(2)" || s != "12" {
+ println("expecting h1g2 and 12, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if s := h("1") + h("2"); log != "h(1)h(2)" || s != "12" {
+ println("expecting h1h2 and 12, got ", log, " and ", s)
+ err++
+ }
+ log = ""
+
+ if err > 0 {
+ panic("fail")
+ }
+}
--- /dev/null
+// $G $D/$F.go && $L $F.$A &&
+// ./$A.out >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1
+// rm -f tmp.go $A.out1
+
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generate test of shift and rotate by constants.
+// The output is compiled and run.
+//
+// The output takes around a gigabyte of memory to compile, link, and run
+// but it is only done during ./run, not in normal builds using run.go.
+
+package main
+
+import (
+ "bufio"
+ "flag"
+ "fmt"
+ "os"
+ "strings"
+)
+
+func main() {
+ flag.Parse()
+
+ b := bufio.NewWriter(os.Stdout)
+ defer b.Flush()
+
+ fmt.Fprintf(b, "%s\n", prolog)
+
+ for logBits := uint(3); logBits <= 6; logBits++ {
+ typ := fmt.Sprintf("int%d", 1<<logBits)
+ fmt.Fprint(b, strings.Replace(checkFunc, "XXX", typ, -1))
+ fmt.Fprint(b, strings.Replace(checkFunc, "XXX", "u"+typ, -1))
+ for mode := 0; mode < 1<<2; mode++ {
+ gentest(b, 1<<logBits, mode&1 != 0, mode&2 != 0)
+ }
+ }
+}
+
+const prolog = `
+
+package main
+
+import (
+ "fmt"
+ "os"
+)
+
+var (
+ i8 int8 = 0x12
+ i16 int16 = 0x1234
+ i32 int32 = 0x12345678
+ i64 int64 = 0x123456789abcdef0
+ ui8 uint8 = 0x12
+ ui16 uint16 = 0x1234
+ ui32 uint32 = 0x12345678
+ ui64 uint64 = 0x123456789abcdef0
+
+ ni8 = ^i8
+ ni16 = ^i16
+ ni32 = ^i32
+ ni64 = ^i64
+ nui8 = ^ui8
+ nui16 = ^ui16
+ nui32 = ^ui32
+ nui64 = ^ui64
+)
+
+var nfail = 0
+
+func main() {
+ if nfail > 0 {
+ fmt.Printf("BUG\n")
+ }
+}
+
+`
+
+const checkFunc = `
+func check_XXX(desc string, have, want XXX) {
+ if have != want {
+ nfail++
+ fmt.Printf("%s = %T(%#x), want %T(%#x)\n", desc, have, have, want, want)
+ if nfail >= 100 {
+ fmt.Printf("BUG: stopping after 100 failures\n")
+ os.Exit(0)
+ }
+ }
+}
+`
+
+var (
+ uop = [2]func(x, y uint64) uint64{
+ func(x, y uint64) uint64 {
+ return x | y
+ },
+ func(x, y uint64) uint64 {
+ return x ^ y
+ },
+ }
+ iop = [2]func(x, y int64) int64{
+ func(x, y int64) int64 {
+ return x | y
+ },
+ func(x, y int64) int64 {
+ return x ^ y
+ },
+ }
+ cop = [2]byte{'|', '^'}
+)
+
+func gentest(b *bufio.Writer, bits uint, unsigned, inverted bool) {
+ fmt.Fprintf(b, "func init() {\n")
+ defer fmt.Fprintf(b, "}\n")
+ n := 0
+
+ // Generate tests for left/right and right/left.
+ for l := uint(0); l <= bits; l++ {
+ for r := uint(0); r <= bits; r++ {
+ for o, op := range cop {
+ typ := fmt.Sprintf("int%d", bits)
+ v := fmt.Sprintf("i%d", bits)
+ if unsigned {
+ typ = "u" + typ
+ v = "u" + v
+ }
+ v0 := int64(0x123456789abcdef0)
+ if inverted {
+ v = "n" + v
+ v0 = ^v0
+ }
+ expr1 := fmt.Sprintf("%s<<%d %c %s>>%d", v, l, op, v, r)
+ expr2 := fmt.Sprintf("%s>>%d %c %s<<%d", v, r, op, v, l)
+
+ var result string
+ if unsigned {
+ v := uint64(v0) >> (64 - bits)
+ v = uop[o](v<<l, v>>r)
+ v <<= 64 - bits
+ v >>= 64 - bits
+ result = fmt.Sprintf("%#x", v)
+ } else {
+ v := int64(v0) >> (64 - bits)
+ v = iop[o](v<<l, v>>r)
+ v <<= 64 - bits
+ v >>= 64 - bits
+ result = fmt.Sprintf("%#x", v)
+ }
+
+ fmt.Fprintf(b, "\tcheck_%s(%q, %s, %s(%s))\n", typ, expr1, expr1, typ, result)
+ fmt.Fprintf(b, "\tcheck_%s(%q, %s, %s(%s))\n", typ, expr2, expr2, typ, result)
+
+ // Chop test into multiple functions so that there's not one
+ // enormous function to compile/link.
+ // All the functions are named init so we don't have to do
+ // anything special to call them. ☺
+ if n++; n >= 50 {
+ fmt.Fprintf(b, "}\n")
+ fmt.Fprintf(b, "func init() {\n")
+ n = 0
+ }
+ }
+ }
+ }
+}
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-eval $(gomake --no-print-directory -f ../src/Make.inc go-env)
-
+eval $(go tool dist env)
+export GOARCH GOOS GOROOT
export E=
case X"$GOARCH" in
export LANG=C
unset GREP_OPTIONS # in case user has a non-standard set
+unset GOROOT_FINAL # breaks ./ imports
+
failed=0
PATH=${GOBIN:-$GOROOT/bin}:`pwd`:/bin:/usr/bin:/usr/local/bin
-RUNFILE="/tmp/gorun-$$-$USER"
-TMP1FILE="/tmp/gotest1-$$-$USER"
-TMP2FILE="/tmp/gotest2-$$-$USER"
+# TODO: We add the tool directory to the PATH to avoid thinking about a better way.
+PATH="$GOTOOLDIR:$PATH"
+
+RUNFILE="${TMPDIR:-/tmp}/gorun-$$-$USER"
+TMP1FILE="${TMPDIR:-/tmp}/gotest1-$$-$USER"
+TMP2FILE="${TMPDIR:-/tmp}/gotest2-$$-$USER"
# don't run the machine out of memory: limit individual processes to 4GB.
# on thresher, 3GB suffices to run the tests; with 2GB, peano fails.
exclude=false # exclude nothing
golden=golden.out
+rm -f tmp.go # generated by some tests, left behind if interrupted
+
filterout() {
grep '^'"$2"'$' $1 >/dev/null
}
-for dir in . ken chan interface syntax dwarf fixedbugs bugs
+for dir in . ken chan interface syntax dwarf safe fixedbugs bugs
do
echo
echo '==' $dir'/'
fi
export F=$(basename $i .go)
export D=$dir
- sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >"$RUNFILE"
+ echo '. ./testlib' >"$RUNFILE"
+ sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >>"$RUNFILE"
if ! { time -p bash -c "bash '$RUNFILE' >'$TMP1FILE' 2>&1" ; } 2>"$TMP2FILE"
then
echo
echo $i >>pass.out
fi
echo $(awk 'NR==1{print $2}' "$TMP2FILE") $D/$F >>times.out
- rm -f $F.$A $A.out
+ rm -f $F.$A $A.out tmp.go
) done
done | # clean up some stack noise
egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' |
--- /dev/null
+// skip
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Run runs tests in the test directory.
+//
+// TODO(bradfitz): docs of some sort, once we figure out how we're changing
+// headers of files
+package main
+
+import (
+ "bytes"
+ "errors"
+ "flag"
+ "fmt"
+ "go/build"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+ "regexp"
+ "runtime"
+ "sort"
+ "strconv"
+ "strings"
+)
+
+var (
+ verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.")
+ numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run")
+ summary = flag.Bool("summary", false, "show summary of results")
+ showSkips = flag.Bool("show_skips", false, "show skipped tests")
+)
+
+var (
+ // gc and ld are [568][gl].
+ gc, ld string
+
+ // letter is the build.ArchChar
+ letter string
+
+ // dirs are the directories to look for *.go files in.
+ // TODO(bradfitz): just use all directories?
+ dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "bugs"}
+
+ // ratec controls the max number of tests running at a time.
+ ratec chan bool
+
+ // toRun is the channel of tests to run.
+ // It is nil until the first test is started.
+ toRun chan *test
+)
+
+// maxTests is an upper bound on the total number of tests.
+// It is used as a channel buffer size to make sure sends don't block.
+const maxTests = 5000
+
+func main() {
+ flag.Parse()
+
+ // Disable parallelism if printing
+ if *verbose {
+ *numParallel = 1
+ }
+
+ ratec = make(chan bool, *numParallel)
+ var err error
+ letter, err = build.ArchChar(build.Default.GOARCH)
+ check(err)
+ gc = letter + "g"
+ ld = letter + "l"
+
+ var tests []*test
+ if flag.NArg() > 0 {
+ for _, arg := range flag.Args() {
+ if arg == "-" || arg == "--" {
+ // Permit running:
+ // $ go run run.go - env.go
+ // $ go run run.go -- env.go
+ // $ go run run.go - ./fixedbugs
+ // $ go run run.go -- ./fixedbugs
+ continue
+ }
+ if fi, err := os.Stat(arg); err == nil && fi.IsDir() {
+ for _, baseGoFile := range goFiles(arg) {
+ tests = append(tests, startTest(arg, baseGoFile))
+ }
+ } else if strings.HasSuffix(arg, ".go") {
+ dir, file := filepath.Split(arg)
+ tests = append(tests, startTest(dir, file))
+ } else {
+ log.Fatalf("can't yet deal with non-directory and non-go file %q", arg)
+ }
+ }
+ } else {
+ for _, dir := range dirs {
+ for _, baseGoFile := range goFiles(dir) {
+ tests = append(tests, startTest(dir, baseGoFile))
+ }
+ }
+ }
+
+ failed := false
+ resCount := map[string]int{}
+ for _, test := range tests {
+ <-test.donec
+ _, isSkip := test.err.(skipError)
+ errStr := "pass"
+ if test.err != nil {
+ errStr = test.err.Error()
+ if !isSkip {
+ failed = true
+ }
+ }
+ if isSkip && !skipOkay[path.Join(test.dir, test.gofile)] {
+ errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
+ isSkip = false
+ failed = true
+ }
+ resCount[errStr]++
+ if isSkip && !*verbose && !*showSkips {
+ continue
+ }
+ if !*verbose && test.err == nil {
+ continue
+ }
+ fmt.Printf("%-10s %-20s: %s\n", test.action, test.goFileName(), errStr)
+ }
+
+ if *summary {
+ for k, v := range resCount {
+ fmt.Printf("%5d %s\n", v, k)
+ }
+ }
+
+ if failed {
+ os.Exit(1)
+ }
+}
+
+func toolPath(name string) string {
+ p := filepath.Join(os.Getenv("GOROOT"), "bin", "tool", name)
+ if _, err := os.Stat(p); err != nil {
+ log.Fatalf("didn't find binary at %s", p)
+ }
+ return p
+}
+
+func goFiles(dir string) []string {
+ f, err := os.Open(dir)
+ check(err)
+ dirnames, err := f.Readdirnames(-1)
+ check(err)
+ names := []string{}
+ for _, name := range dirnames {
+ if !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") {
+ names = append(names, name)
+ }
+ }
+ sort.Strings(names)
+ return names
+}
+
+// skipError describes why a test was skipped.
+type skipError string
+
+func (s skipError) Error() string { return string(s) }
+
+func check(err error) {
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+// test holds the state of a test.
+type test struct {
+ dir, gofile string
+ donec chan bool // closed when done
+
+ src string
+ action string // "compile", "build", "run", "errorcheck", "skip", "runoutput", "compiledir"
+
+ tempDir string
+ err error
+}
+
+// startTest
+func startTest(dir, gofile string) *test {
+ t := &test{
+ dir: dir,
+ gofile: gofile,
+ donec: make(chan bool, 1),
+ }
+ if toRun == nil {
+ toRun = make(chan *test, maxTests)
+ go runTests()
+ }
+ select {
+ case toRun <- t:
+ default:
+ panic("toRun buffer size (maxTests) is too small")
+ }
+ return t
+}
+
+// runTests runs tests in parallel, but respecting the order they
+// were enqueued on the toRun channel.
+func runTests() {
+ for {
+ ratec <- true
+ t := <-toRun
+ go func() {
+ t.run()
+ <-ratec
+ }()
+ }
+}
+
+var cwd, _ = os.Getwd()
+
+func (t *test) goFileName() string {
+ return filepath.Join(t.dir, t.gofile)
+}
+
+func (t *test) goDirName() string {
+ return filepath.Join(t.dir, strings.Replace(t.gofile, ".go", ".dir", -1))
+}
+
+// run runs a test.
+func (t *test) run() {
+ defer close(t.donec)
+
+ srcBytes, err := ioutil.ReadFile(t.goFileName())
+ if err != nil {
+ t.err = err
+ return
+ }
+ t.src = string(srcBytes)
+ if t.src[0] == '\n' {
+ t.err = skipError("starts with newline")
+ return
+ }
+ pos := strings.Index(t.src, "\n\n")
+ if pos == -1 {
+ t.err = errors.New("double newline not found")
+ return
+ }
+ action := t.src[:pos]
+ if strings.HasPrefix(action, "//") {
+ action = action[2:]
+ }
+
+ var args, flags []string
+ wantError := false
+ f := strings.Fields(action)
+ if len(f) > 0 {
+ action = f[0]
+ args = f[1:]
+ }
+
+ switch action {
+ case "cmpout":
+ action = "run" // the run case already looks for <dir>/<test>.out files
+ fallthrough
+ case "compile", "compiledir", "build", "run", "runoutput":
+ t.action = action
+ case "errorcheck":
+ t.action = action
+ wantError = true
+ for len(args) > 0 && strings.HasPrefix(args[0], "-") {
+ if args[0] == "-0" {
+ wantError = false
+ } else {
+ flags = append(flags, args[0])
+ }
+ args = args[1:]
+ }
+ case "skip":
+ t.action = "skip"
+ return
+ default:
+ t.err = skipError("skipped; unknown pattern: " + action)
+ t.action = "??"
+ return
+ }
+
+ t.makeTempDir()
+ defer os.RemoveAll(t.tempDir)
+
+ err = ioutil.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0644)
+ check(err)
+
+ // A few tests (of things like the environment) require these to be set.
+ os.Setenv("GOOS", runtime.GOOS)
+ os.Setenv("GOARCH", runtime.GOARCH)
+
+ useTmp := true
+ runcmd := func(args ...string) ([]byte, error) {
+ cmd := exec.Command(args[0], args[1:]...)
+ var buf bytes.Buffer
+ cmd.Stdout = &buf
+ cmd.Stderr = &buf
+ if useTmp {
+ cmd.Dir = t.tempDir
+ }
+ err := cmd.Run()
+ return buf.Bytes(), err
+ }
+
+ long := filepath.Join(cwd, t.goFileName())
+ switch action {
+ default:
+ t.err = fmt.Errorf("unimplemented action %q", action)
+
+ case "errorcheck":
+ cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter}
+ cmdline = append(cmdline, flags...)
+ cmdline = append(cmdline, long)
+ out, err := runcmd(cmdline...)
+ if wantError {
+ if err == nil {
+ t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
+ return
+ }
+ } else {
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ return
+ }
+ }
+ t.err = t.errorCheck(string(out), long, t.gofile)
+ return
+
+ case "compile":
+ out, err := runcmd("go", "tool", gc, "-e", "-o", "a."+letter, long)
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ }
+
+ case "compiledir":
+ // Compile all files in the directory in lexicographic order.
+ longdir := filepath.Join(cwd, t.goDirName())
+ files, dirErr := ioutil.ReadDir(longdir)
+ if dirErr != nil {
+ t.err = dirErr
+ return
+ }
+ for _, gofile := range files {
+ if filepath.Ext(gofile.Name()) != ".go" {
+ continue
+ }
+ afile := strings.Replace(gofile.Name(), ".go", "."+letter, -1)
+ out, err := runcmd("go", "tool", gc, "-e", "-D.", "-I.", "-o", afile, filepath.Join(longdir, gofile.Name()))
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ break
+ }
+ }
+
+ case "build":
+ out, err := runcmd("go", "build", "-o", "a.exe", long)
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ }
+
+ case "run":
+ useTmp = false
+ out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ }
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
+
+ case "runoutput":
+ useTmp = false
+ out, err := runcmd("go", "run", t.goFileName())
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ }
+ tfile := filepath.Join(t.tempDir, "tmp__.go")
+ err = ioutil.WriteFile(tfile, out, 0666)
+ if err != nil {
+ t.err = fmt.Errorf("write tempfile:%s", err)
+ return
+ }
+ out, err = runcmd("go", "run", tfile)
+ if err != nil {
+ t.err = fmt.Errorf("%s\n%s", err, out)
+ }
+ if string(out) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
+ }
+}
+
+func (t *test) String() string {
+ return filepath.Join(t.dir, t.gofile)
+}
+
+func (t *test) makeTempDir() {
+ var err error
+ t.tempDir, err = ioutil.TempDir("", "")
+ check(err)
+}
+
+func (t *test) expectedOutput() string {
+ filename := filepath.Join(t.dir, t.gofile)
+ filename = filename[:len(filename)-len(".go")]
+ filename += ".out"
+ b, _ := ioutil.ReadFile(filename)
+ return string(b)
+}
+
+func (t *test) errorCheck(outStr string, full, short string) (err error) {
+ defer func() {
+ if *verbose && err != nil {
+ log.Printf("%s gc output:\n%s", t, outStr)
+ }
+ }()
+ var errs []error
+
+ var out []string
+ // 6g error messages continue onto additional lines with leading tabs.
+ // Split the output at the beginning of each line that doesn't begin with a tab.
+ for _, line := range strings.Split(outStr, "\n") {
+ if strings.HasSuffix(line, "\r") { // remove '\r', output by compiler on windows
+ line = line[:len(line)-1]
+ }
+ if strings.HasPrefix(line, "\t") {
+ out[len(out)-1] += "\n" + line
+ } else {
+ out = append(out, line)
+ }
+ }
+
+ // Cut directory name.
+ for i := range out {
+ out[i] = strings.Replace(out[i], full, short, -1)
+ }
+
+ for _, we := range t.wantedErrors() {
+ var errmsgs []string
+ errmsgs, out = partitionStrings(we.filterRe, out)
+ if len(errmsgs) == 0 {
+ errs = append(errs, fmt.Errorf("%s:%d: missing error %q", we.file, we.lineNum, we.reStr))
+ continue
+ }
+ matched := false
+ for _, errmsg := range errmsgs {
+ if we.re.MatchString(errmsg) {
+ matched = true
+ } else {
+ out = append(out, errmsg)
+ }
+ }
+ if !matched {
+ errs = append(errs, fmt.Errorf("%s:%d: no match for %q in%s", we.file, we.lineNum, we.reStr, strings.Join(out, "\n")))
+ continue
+ }
+ }
+
+ if len(errs) == 0 {
+ return nil
+ }
+ if len(errs) == 1 {
+ return errs[0]
+ }
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "\n")
+ for _, err := range errs {
+ fmt.Fprintf(&buf, "%s\n", err.Error())
+ }
+ return errors.New(buf.String())
+
+}
+
+func partitionStrings(rx *regexp.Regexp, strs []string) (matched, unmatched []string) {
+ for _, s := range strs {
+ if rx.MatchString(s) {
+ matched = append(matched, s)
+ } else {
+ unmatched = append(unmatched, s)
+ }
+ }
+ return
+}
+
+type wantedError struct {
+ reStr string
+ re *regexp.Regexp
+ lineNum int
+ file string
+ filterRe *regexp.Regexp // /^file:linenum\b/m
+}
+
+var (
+ errRx = regexp.MustCompile(`// (?:GC_)?ERROR (.*)`)
+ errQuotesRx = regexp.MustCompile(`"([^"]*)"`)
+ lineRx = regexp.MustCompile(`LINE(([+-])([0-9]+))?`)
+)
+
+func (t *test) wantedErrors() (errs []wantedError) {
+ for i, line := range strings.Split(t.src, "\n") {
+ lineNum := i + 1
+ if strings.Contains(line, "////") {
+ // double comment disables ERROR
+ continue
+ }
+ m := errRx.FindStringSubmatch(line)
+ if m == nil {
+ continue
+ }
+ all := m[1]
+ mm := errQuotesRx.FindAllStringSubmatch(all, -1)
+ if mm == nil {
+ log.Fatalf("invalid errchk line in %s: %s", t.goFileName(), line)
+ }
+ for _, m := range mm {
+ rx := lineRx.ReplaceAllStringFunc(m[1], func(m string) string {
+ n := lineNum
+ if strings.HasPrefix(m, "LINE+") {
+ delta, _ := strconv.Atoi(m[5:])
+ n += delta
+ } else if strings.HasPrefix(m, "LINE-") {
+ delta, _ := strconv.Atoi(m[5:])
+ n -= delta
+ }
+ return fmt.Sprintf("%s:%d", t.gofile, n)
+ })
+ filterPattern := fmt.Sprintf(`^(\w+/)?%s:%d[:[]`, t.gofile, lineNum)
+ errs = append(errs, wantedError{
+ reStr: rx,
+ re: regexp.MustCompile(rx),
+ filterRe: regexp.MustCompile(filterPattern),
+ lineNum: lineNum,
+ file: t.gofile,
+ })
+ }
+ }
+
+ return
+}
+
+var skipOkay = map[string]bool{
+ "args.go": true,
+ "ddd3.go": true,
+ "import3.go": true,
+ "import4.go": true,
+ "index.go": true,
+ "linkx.go": true,
+ "method4.go": true,
+ "nul1.go": true,
+ "rotate.go": true,
+ "sigchld.go": true,
+ "sinit.go": true,
+ "interface/embed1.go": true,
+ "interface/private.go": true,
+ "interface/recursive2.go": true,
+ "dwarf/main.go": true,
+ "dwarf/z1.go": true,
+ "dwarf/z10.go": true,
+ "dwarf/z11.go": true,
+ "dwarf/z12.go": true,
+ "dwarf/z13.go": true,
+ "dwarf/z14.go": true,
+ "dwarf/z15.go": true,
+ "dwarf/z16.go": true,
+ "dwarf/z17.go": true,
+ "dwarf/z18.go": true,
+ "dwarf/z19.go": true,
+ "dwarf/z2.go": true,
+ "dwarf/z20.go": true,
+ "dwarf/z3.go": true,
+ "dwarf/z4.go": true,
+ "dwarf/z5.go": true,
+ "dwarf/z6.go": true,
+ "dwarf/z7.go": true,
+ "dwarf/z8.go": true,
+ "dwarf/z9.go": true,
+ "fixedbugs/bug083.go": true,
+ "fixedbugs/bug133.go": true,
+ "fixedbugs/bug160.go": true,
+ "fixedbugs/bug191.go": true,
+ "fixedbugs/bug248.go": true,
+ "fixedbugs/bug302.go": true,
+ "fixedbugs/bug313.go": true,
+ "fixedbugs/bug322.go": true,
+ "fixedbugs/bug324.go": true,
+ "fixedbugs/bug345.go": true,
+ "fixedbugs/bug367.go": true,
+ "fixedbugs/bug369.go": true,
+ "fixedbugs/bug382.go": true,
+ "fixedbugs/bug385_32.go": true,
+ "fixedbugs/bug385_64.go": true,
+ "fixedbugs/bug414.go": true,
+ "fixedbugs/bug424.go": true,
+ "fixedbugs/bug429.go": true,
+ "fixedbugs/bug437.go": true,
+ "bugs/bug395.go": true,
+ "bugs/bug434.go": true,
+}
-// $G $D/$F.go
+// compile
// 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
+// Test rune constants, expressions and types.
+// Compiles but does not run.
+
+package rune
var (
r0 = 'a'
-// errchk $G $D/$F.go
+// errorcheck
// 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.
-// make sure that even if a file imports runtime,
+// Test that even if a file imports runtime,
// it cannot get at the low-level runtime definitions
-// known to the compiler. for normal packages
+// known to the compiler. For normal packages
// the compiler doesn't even record the lower case
// functions in its symbol table, but some functions
// in runtime are hard-coded into the compiler.
+// Does not compile.
package main
--- /dev/null
+// true
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// can't use local path with -u, use -I. instead
+import "pkg" // ERROR "import unsafe package"
+
+func main() {
+ print(pkg.Float32bits(1.0))
+}
--- /dev/null
+// $G $D/pkg.go && pack grc pkg.a pkg.$A 2> /dev/null && rm pkg.$A && errchk $G -I. -u $D/main.go
+// rm -f pkg.a
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
--- /dev/null
+// true
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// a package that uses unsafe on the inside but not in it's api
+
+package pkg
+
+import "unsafe"
+
+// this should be inlinable
+func Float32bits(f float32) uint32 {
+ return *(*uint32)(unsafe.Pointer(&f))
+}
\ No newline at end of file
--- /dev/null
+// $G $D/pkg.go && pack grcS pkg.a pkg.$A 2> /dev/null && rm pkg.$A && $G -I. -u $D/main.go
+// rm -f pkg.a
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored
-// errchk $G -e $D/$F.go
+// errorcheck
// 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 illegal shifts.
// Issue 1708, illegal cases.
+// Does not compile.
package p
-// $G $D/$F.go || echo BUG: shift2
+// compile
// 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 legal shifts.
// Issue 1708, legal cases.
+// Compiles but does not run.
package p
-// $G $F.go && $L $F.$A # don't run it - goes forever
+// build
// 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.
+// Test basic concurrency: the classic prime sieve.
+// Do not run - loops forever.
+
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
// [ "$GOOS" == windows ] ||
// ($G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out)
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 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.
+// Test that a program can survive SIGCHLD.
+
package main
import "syscall"
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simultaneous assignment.
+
package main
var a, b, c, d, e, f, g, h, i int
// $G -S $D/$F.go | egrep initdone >/dev/null && echo BUG sinit || true
+// NOTE: This test is not run by 'run.go' and so not run by all.bash.
+// To run this test you must use the ./run shell script.
+
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that many initializations can be done at link time and
+// generate no executable init functions.
+
package p
// Should be no init func in the assembly.
-// $G $D/$F.go
+// compile
// 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 unsafe.Sizeof, unsafe.Alignof, and unsafe.Offsetof all return uintptr.
+
package main
import "unsafe"
-// $G $F.go && $L $F.$A # don't run it - produces too much output
+// build
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test general operation by solving a peg solitaire game.
+// A version of this is in the Go playground.
+// Don't run it - produces too much output.
+
// This program solves the (English) peg solitaire board game.
// See also: http://en.wikipedia.org/wiki/Peg_solitaire
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test stack splitting code.
// Try to tickle stack splitting bugs by doing
// go, defer, and closure calls at different stack depths.
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test string literal syntax.
+
package main
import "os"
"backslashes 2 (backquote)")
assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)")
- // test large runes. perhaps not the most logical place for this test.
+ // test large and surrogate-half runes. perhaps not the most logical place for these tests.
var r int32
r = 0x10ffff // largest rune value
s = string(r)
r = 0x10ffff + 1
s = string(r)
assert(s, "\xef\xbf\xbd", "too-large rune")
+ r = 0xD800
+ s = string(r)
+ assert(s, "\xef\xbf\xbd", "surrogate rune min")
+ r = 0xDFFF
+ s = string(r)
+ assert(s, "\xef\xbf\xbd", "surrogate rune max")
+ r = -1
+ s = string(r)
+ assert(s, "\xef\xbf\xbd", "negative rune")
+
+ // the large rune tests again, this time using constants instead of a variable.
+ // these conversions will be done at compile time.
+ s = string(0x10ffff) // largest rune value
+ assert(s, "\xf4\x8f\xbf\xbf", "largest rune constant")
+ s = string(0x10ffff + 1)
+ assert(s, "\xef\xbf\xbd", "too-large rune constant")
+ s = string(0xD800)
+ assert(s, "\xef\xbf\xbd", "surrogate rune min constant")
+ s = string(0xDFFF)
+ assert(s, "\xef\xbf\xbd", "surrogate rune max constant")
+ s = string(-1)
+ assert(s, "\xef\xbf\xbd", "negative rune")
assert(string(gr1), gx1, "global ->[]rune")
assert(string(gr2), gx2fix, "global invalid ->[]rune")
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test range over strings.
+
package main
import (
ok = false
}
+ for _, c := range "a\xed\xa0\x80a" {
+ if c != 'a' && c != utf8.RuneError {
+ fmt.Printf("surrogate UTF-8 does not error: %U\n", c)
+ ok = false
+ }
+ }
+
if !ok {
fmt.Println("BUG: stringrange")
os.Exit(1)
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
-// zero length structs.
-// used to not be evaluated.
-// issue 2232.
+// Test zero length structs.
+// Used to not be evaluated.
+// Issue 2232.
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test switch statements.
+
package main
+import "os"
+
func assert(cond bool, msg string) {
if !cond {
print("assertion fail: ", msg, "\n")
assert(false, "m should not be nil")
default:
}
+
+ // switch on interface.
+ switch i := interface{}("hello"); i {
+ case 42:
+ assert(false, `i should be "hello"`)
+ case "hello":
+ assert(true, "hello")
+ default:
+ assert(false, `i should be "hello"`)
+ }
+
+ // switch on implicit bool converted to interface
+ // was broken: see issue 3980
+ switch i := interface{}(true); {
+ case i:
+ assert(true, "true")
+ case false:
+ assert(false, "i should be true")
+ default:
+ assert(false, "i should be true")
+ }
+
+ // switch on array.
+ switch ar := [3]int{1, 2, 3}; ar {
+ case [3]int{1,2,3}:
+ assert(true, "[1 2 3]")
+ case [3]int{4,5,6}:
+ assert(false, "ar should be [1 2 3]")
+ default:
+ assert(false, "ar should be [1 2 3]")
+ }
+
+ // switch on channel
+ switch c1, c2 := make(chan int), make(chan int); c1 {
+ case nil:
+ assert(false, "c1 did not match itself")
+ case c2:
+ assert(false, "c1 did not match itself")
+ case c1:
+ assert(true, "chan")
+ default:
+ assert(false, "c1 did not match itself")
+ }
+
+ i := 0
+ switch x := 5; {
+ case i < x:
+ os.Exit(0)
+ case i == x:
+ case i > x:
+ os.Exit(1)
+ }
}
+++ /dev/null
-// $G $F.go && $L $F.$A && ./$A.out
-
-// 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
-
-import "os"
-
-func main() {
- i := 0
- switch x := 5; {
- case i < x:
- os.Exit(0)
- case i == x:
- case i > x:
- os.Exit(1)
- }
-}
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that erroneous switch statements are detected by the compiler.
+// Does not compile.
+
package main
type I interface {
case f1: // ERROR "can only compare func f to nil|func can only be compared to nil"
default:
}
+
+ var ar, ar1 [4]func()
+ switch ar { // ERROR "cannot switch on"
+ case ar1:
+ default:
+ }
+
+ var st, st1 struct{ f func() }
+ switch st { // ERROR "cannot switch on"
+ case st1:
+ }
}
func good() {
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
--- /dev/null
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var a = []int{
+ 3 // ERROR "need trailing comma before newline in composite literal"
+}
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
+++ /dev/null
-// $G $F.go && $L $F.$A && ./$A.out
-
-// 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 a_const = 0
-
-const (
- pi = /* the usual */ 3.14159265358979323
- e = 2.718281828
- mask1 int = 1 << iota
- mask2 = 1 << iota
- mask3 = 1 << iota
- mask4 = 1 << iota
-)
-
-type (
- Empty interface{}
- Point struct {
- x, y int
- }
- Point2 Point
-)
-
-func (p *Point) Initialize(x, y int) *Point {
- p.x, p.y = x, y
- return p
-}
-
-func (p *Point) Distance() int {
- return p.x*p.x + p.y*p.y
-}
-
-var (
- x1 int
- x2 int
- u, v, w float32
-)
-
-func foo() {}
-
-func min(x, y int) int {
- if x < y {
- return x
- }
- return y
-}
-
-func swap(x, y int) (u, v int) {
- u = y
- v = x
- return
-}
-
-func control_structs() {
- var p *Point = new(Point).Initialize(2, 3)
- i := p.Distance()
- var f float32 = 0.3
- _ = f
- for {
- }
- for {
- }
- for j := 0; j < i; j++ {
- if i == 0 {
- } else {
- i = 0
- }
- var x float32
- _ = x
- }
-foo: // a label
- var j int
- switch y := 0; true {
- case i < y:
- fallthrough
- case i < j:
- case i == 0, i == 1, i == j:
- i++
- i++
- goto foo
- default:
- i = -+-+i
- break
- }
-}
-
-func main() {
-}
--- /dev/null
+# Copyright 2012 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# These function names are also known to
+# (and are the plan for transitioning to) run.go.
+
+compile() {
+ $G $D/$F.go
+}
+
+compiledir() {
+ for gofile in $D/$F.dir/*.go
+ do
+ $G -I. "$gofile" || return 1
+ done
+}
+
+build() {
+ $G $D/$F.go && $L $F.$A
+}
+
+runoutput() {
+ go run "$D/$F.go" > tmp.go
+ go run tmp.go
+}
+
+run() {
+ gofiles=""
+ ingo=true
+ while $ingo; do
+ case "$1" in
+ *.go)
+ gofiles="$gofiles $1"
+ shift
+ ;;
+ *)
+ ingo=false
+ ;;
+ esac
+ done
+
+ $G $D/$F.go $gofiles && $L $F.$A && ./$A.out "$@"
+}
+
+cmpout() {
+ $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
+}
+
+errorcheck() {
+ zero=""
+ if [ "$1" = "-0" ]; then
+ zero="-0"
+ shift
+ fi
+ errchk $zero $G -e $* $D/$F.go
+}
+
+skip() {
+ true
+}
+++ /dev/null
-0.04 ./235
-1.72 ./64bit
-0.03 ./alias
-0.03 ./alias1
-0.30 ./append
-0.07 ./args
-0.02 ./assign
-0.04 ./assign1
-0.04 ./bigalg
-0.03 ./bigmap
-0.14 ./blank
-0.03 ./blank1
-0.03 ./chancap
-0.07 ./char_lit
-0.03 ./char_lit1
-0.09 ./closedchan
-0.05 ./closure
-0.06 ./cmp
-0.02 ./cmp6
-0.03 ./cmplx
-0.60 ./cmplxdivide
-0.00 ./cmplxdivide1
-0.04 ./complit
-0.02 ./complit1
-0.03 ./compos
-0.04 ./const
-0.03 ./const1
-0.03 ./const2
-0.13 ./const3
-0.08 ./convert
-0.03 ./convert1
-0.02 ./convert3
-0.04 ./convlit
-0.02 ./convlit1
-0.34 ./copy
-0.27 ./crlf
-0.05 ./ddd
-0.02 ./ddd1
-0.00 ./ddd2
-0.04 ./ddd3
-0.03 ./decl
-0.03 ./declbad
-0.14 ./defer
-0.03 ./deferprint
-0.14 ./divide
-0.00 ./empty
-0.08 ./env
-0.00 ./eof
-0.00 ./eof1
-0.04 ./escape
-0.12 ./escape2
-0.03 ./escape3
-0.05 ./float_lit
-0.14 ./floatcmp
-0.03 ./for
-0.04 ./func
-0.03 ./func1
-0.00 ./func2
-0.03 ./func3
-0.03 ./func4
-0.03 ./func5
-0.00 ./func6
-0.04 ./func7
-0.03 ./gc
-0.04 ./gc1
-0.26 ./gc2
-0.06 ./goprint
-0.04 ./goto
-0.04 ./hashmap
-0.03 ./helloworld
-0.03 ./if
-0.02 ./import
-0.15 ./import1
-0.00 ./import2
-0.01 ./import3
-0.14 ./import4
-1.70 ./index
-0.03 ./indirect
-0.02 ./indirect1
-0.02 ./init
-0.25 ./init1
-0.03 ./initcomma
-0.15 ./initialize
-0.02 ./initializerr
-0.06 ./initsyscall
-0.07 ./int_lit
-0.03 ./intcvt
-0.03 ./iota
-0.03 ./label
-0.03 ./label1
-0.04 ./literal
-0.15 ./malloc1
-0.06 ./mallocfin
-0.19 ./mallocrand
-0.21 ./mallocrep
-0.52 ./mallocrep1
-0.17 ./map
-0.02 ./map1
-0.05 ./method
-0.02 ./method1
-0.03 ./method2
-0.04 ./method3
-0.06 ./named
-0.03 ./named1
-0.18 ./nil
-0.15 ./nilptr
-0.16 ./nul1
-0.00 ./parentype
-0.11 ./peano
-0.02 ./printbig
-0.05 ./range
-0.04 ./recover
-0.04 ./recover1
-0.08 ./recover2
-0.06 ./recover3
-0.14 ./rename
-0.02 ./rename1
-0.16 ./reorder
-0.00 ./rune
-0.03 ./runtime
-0.03 ./shift1
-0.01 ./shift2
-0.03 ./sieve
-0.06 ./sigchld
-0.03 ./simassign
-0.02 ./sinit
-0.00 ./sizeof
-0.03 ./solitaire
-0.06 ./stack
-0.08 ./string_lit
-0.14 ./stringrange
-0.04 ./struct0
-0.04 ./switch
-0.08 ./switch1
-0.02 ./switch3
-0.04 ./test0
-0.03 ./turing
-0.07 ./typeswitch
-0.15 ./typeswitch1
-0.02 ./typeswitch2
-0.03 ./typeswitch3
-0.02 ./undef
-0.04 ./utf
-0.03 ./varerr
-0.03 ./varinit
-0.26 ./zerodivide
-0.04 ken/array
-0.11 ken/chan
-0.04 ken/chan1
-0.04 ken/complit
-0.07 ken/convert
-0.03 ken/cplx0
-0.02 ken/cplx1
-0.06 ken/cplx2
-0.09 ken/cplx3
-0.14 ken/cplx4
-0.03 ken/cplx5
-0.31 ken/divconst
-0.05 ken/divmod
-0.04 ken/embed
-0.03 ken/for
-0.04 ken/interbasic
-0.03 ken/interfun
-0.04 ken/intervar
-0.03 ken/label
-0.03 ken/litfun
-0.03 ken/mfunc
-0.34 ken/modconst
-0.03 ken/ptrfun
-0.03 ken/ptrvar
-0.04 ken/range
-0.03 ken/rob1
-0.18 ken/rob2
-0.04 ken/robfor
-0.04 ken/robfunc
-0.03 ken/shift
-0.03 ken/simparray
-0.04 ken/simpbool
-0.03 ken/simpconv
-0.03 ken/simpfun
-0.03 ken/simpswitch
-0.03 ken/simpvar
-0.02 ken/slicearray
-0.03 ken/sliceslice
-0.03 ken/string
-0.03 ken/strvar
-0.32 chan/doubleselect
-0.06 chan/fifo
-0.12 chan/goroutines
-0.07 chan/nonblock
-0.02 chan/perm
-0.10 chan/powser1
-0.09 chan/powser2
-0.03 chan/select
-0.15 chan/select2
-0.97 chan/select3
-0.03 chan/select4
-0.72 chan/select5
-0.03 chan/select6
-0.04 chan/select7
-0.03 chan/sendstmt
-0.03 chan/sieve1
-0.04 chan/sieve2
-0.02 chan/zerosize
-0.04 interface/bigdata
-0.04 interface/convert
-0.03 interface/convert1
-0.03 interface/convert2
-0.09 interface/embed
-0.00 interface/embed0
-0.03 interface/embed1
-0.02 interface/embed2
-0.02 interface/explicit
-0.03 interface/fail
-0.09 interface/fake
-0.03 interface/noeq
-0.03 interface/pointer
-0.03 interface/private
-0.00 interface/private1
-0.04 interface/receiver
-0.03 interface/receiver1
-0.00 interface/recursive
-0.03 interface/returntype
-0.09 interface/struct
-0.02 syntax/chan
-0.03 syntax/chan1
-0.02 syntax/else
-0.02 syntax/forvar
-0.03 syntax/if
-0.03 syntax/import
-0.03 syntax/interface
-0.03 syntax/semi1
-0.02 syntax/semi2
-0.03 syntax/semi3
-0.03 syntax/semi4
-0.02 syntax/semi5
-0.03 syntax/semi6
-0.02 syntax/semi7
-0.02 syntax/topexpr
-0.03 syntax/typesw
-0.02 syntax/vareq
-0.03 syntax/vareq1
-0.04 dwarf/linedirectives
-0.05 dwarf/main
-0.00 dwarf/z1
-0.00 dwarf/z10
-0.00 dwarf/z11
-0.00 dwarf/z12
-0.00 dwarf/z13
-0.00 dwarf/z14
-0.00 dwarf/z15
-0.00 dwarf/z16
-0.00 dwarf/z17
-0.00 dwarf/z18
-0.00 dwarf/z19
-0.00 dwarf/z2
-0.00 dwarf/z20
-0.00 dwarf/z3
-0.00 dwarf/z4
-0.00 dwarf/z5
-0.00 dwarf/z6
-0.00 dwarf/z7
-0.00 dwarf/z8
-0.00 dwarf/z9
-0.03 fixedbugs/bug000
-0.03 fixedbugs/bug002
-0.03 fixedbugs/bug003
-0.03 fixedbugs/bug004
-0.04 fixedbugs/bug005
-0.08 fixedbugs/bug006
-0.03 fixedbugs/bug007
-0.03 fixedbugs/bug008
-0.02 fixedbugs/bug009
-0.03 fixedbugs/bug010
-0.03 fixedbugs/bug011
-0.03 fixedbugs/bug012
-0.03 fixedbugs/bug013
-0.03 fixedbugs/bug014
-0.02 fixedbugs/bug015
-0.02 fixedbugs/bug016
-0.03 fixedbugs/bug017
-0.00 fixedbugs/bug020
-0.03 fixedbugs/bug021
-0.02 fixedbugs/bug022
-0.03 fixedbugs/bug023
-0.03 fixedbugs/bug024
-0.03 fixedbugs/bug026
-0.14 fixedbugs/bug027
-0.03 fixedbugs/bug028
-0.02 fixedbugs/bug030
-0.03 fixedbugs/bug031
-0.02 fixedbugs/bug035
-0.00 fixedbugs/bug036
-0.02 fixedbugs/bug037
-0.00 fixedbugs/bug038
-0.03 fixedbugs/bug039
-0.00 fixedbugs/bug040
-0.03 fixedbugs/bug045
-0.03 fixedbugs/bug046
-0.03 fixedbugs/bug047
-0.02 fixedbugs/bug048
-0.03 fixedbugs/bug049
-0.03 fixedbugs/bug050
-0.02 fixedbugs/bug051
-0.03 fixedbugs/bug052
-0.03 fixedbugs/bug053
-0.03 fixedbugs/bug054
-0.03 fixedbugs/bug055
-0.03 fixedbugs/bug056
-0.00 fixedbugs/bug057
-0.04 fixedbugs/bug058
-0.08 fixedbugs/bug059
-0.08 fixedbugs/bug060
-0.03 fixedbugs/bug061
-0.03 fixedbugs/bug062
-0.00 fixedbugs/bug063
-0.00 fixedbugs/bug064
-0.03 fixedbugs/bug065
-0.00 fixedbugs/bug066
-0.03 fixedbugs/bug067
-0.03 fixedbugs/bug068
-0.00 fixedbugs/bug069
-0.15 fixedbugs/bug070
-0.00 fixedbugs/bug071
-0.03 fixedbugs/bug072
-0.03 fixedbugs/bug073
-0.03 fixedbugs/bug074
-0.03 fixedbugs/bug075
-0.03 fixedbugs/bug076
-0.00 fixedbugs/bug077
-0.03 fixedbugs/bug078
-0.00 fixedbugs/bug080
-0.02 fixedbugs/bug081
-0.03 fixedbugs/bug082
-0.03 fixedbugs/bug083
-0.04 fixedbugs/bug084
-0.02 fixedbugs/bug085
-0.03 fixedbugs/bug086
-0.00 fixedbugs/bug087
-0.01 fixedbugs/bug088
-0.00 fixedbugs/bug089
-0.03 fixedbugs/bug090
-0.02 fixedbugs/bug091
-0.03 fixedbugs/bug092
-0.03 fixedbugs/bug093
-0.00 fixedbugs/bug094
-0.00 fixedbugs/bug096
-0.03 fixedbugs/bug097
-0.00 fixedbugs/bug098
-0.03 fixedbugs/bug099
-0.03 fixedbugs/bug101
-0.03 fixedbugs/bug102
-0.02 fixedbugs/bug103
-0.03 fixedbugs/bug104
-0.01 fixedbugs/bug106
-0.03 fixedbugs/bug107
-0.03 fixedbugs/bug108
-0.00 fixedbugs/bug109
-0.03 fixedbugs/bug110
-0.03 fixedbugs/bug111
-0.00 fixedbugs/bug112
-0.03 fixedbugs/bug113
-0.03 fixedbugs/bug114
-0.00 fixedbugs/bug115
-0.03 fixedbugs/bug116
-0.02 fixedbugs/bug117
-0.00 fixedbugs/bug118
-0.03 fixedbugs/bug119
-0.11 fixedbugs/bug120
-0.02 fixedbugs/bug121
-0.03 fixedbugs/bug122
-0.03 fixedbugs/bug123
-0.02 fixedbugs/bug126
-0.02 fixedbugs/bug127
-0.03 fixedbugs/bug128
-0.01 fixedbugs/bug129
-0.08 fixedbugs/bug130
-0.02 fixedbugs/bug131
-0.02 fixedbugs/bug132
-0.03 fixedbugs/bug133
-0.00 fixedbugs/bug135
-0.02 fixedbugs/bug136
-0.00 fixedbugs/bug137
-0.00 fixedbugs/bug139
-0.00 fixedbugs/bug140
-0.07 fixedbugs/bug141
-0.03 fixedbugs/bug142
-0.00 fixedbugs/bug143
-0.00 fixedbugs/bug144
-0.00 fixedbugs/bug145
-0.03 fixedbugs/bug146
-0.06 fixedbugs/bug147
-0.03 fixedbugs/bug148
-0.00 fixedbugs/bug149
-0.00 fixedbugs/bug150
-0.00 fixedbugs/bug151
-0.03 fixedbugs/bug1515
-0.03 fixedbugs/bug152
-0.14 fixedbugs/bug154
-0.03 fixedbugs/bug155
-0.00 fixedbugs/bug156
-0.00 fixedbugs/bug157
-0.00 fixedbugs/bug158
-0.07 fixedbugs/bug159
-0.09 fixedbugs/bug160
-0.00 fixedbugs/bug161
-0.02 fixedbugs/bug163
-0.00 fixedbugs/bug164
-0.03 fixedbugs/bug165
-0.03 fixedbugs/bug167
-0.03 fixedbugs/bug168
-0.02 fixedbugs/bug169
-0.03 fixedbugs/bug170
-0.03 fixedbugs/bug171
-0.02 fixedbugs/bug172
-0.00 fixedbugs/bug173
-0.00 fixedbugs/bug174
-0.03 fixedbugs/bug175
-0.03 fixedbugs/bug176
-0.09 fixedbugs/bug177
-0.03 fixedbugs/bug178
-0.03 fixedbugs/bug179
-0.03 fixedbugs/bug180
-0.03 fixedbugs/bug181
-0.02 fixedbugs/bug182
-0.03 fixedbugs/bug183
-0.15 fixedbugs/bug184
-0.04 fixedbugs/bug185
-0.02 fixedbugs/bug186
-0.08 fixedbugs/bug187
-0.03 fixedbugs/bug188
-0.03 fixedbugs/bug189
-0.00 fixedbugs/bug190
-0.04 fixedbugs/bug191
-0.03 fixedbugs/bug192
-0.03 fixedbugs/bug193
-0.03 fixedbugs/bug194
-0.02 fixedbugs/bug195
-0.04 fixedbugs/bug196
-0.02 fixedbugs/bug197
-0.03 fixedbugs/bug198
-0.03 fixedbugs/bug199
-0.03 fixedbugs/bug200
-0.03 fixedbugs/bug201
-0.03 fixedbugs/bug202
-0.03 fixedbugs/bug203
-0.03 fixedbugs/bug204
-0.02 fixedbugs/bug205
-0.21 fixedbugs/bug206
-0.14 fixedbugs/bug207
-0.02 fixedbugs/bug208
-0.02 fixedbugs/bug209
-0.03 fixedbugs/bug211
-0.03 fixedbugs/bug212
-0.03 fixedbugs/bug213
-0.00 fixedbugs/bug214
-0.02 fixedbugs/bug215
-0.00 fixedbugs/bug216
-0.03 fixedbugs/bug217
-0.00 fixedbugs/bug218
-0.00 fixedbugs/bug219
-0.04 fixedbugs/bug221
-0.01 fixedbugs/bug222
-0.00 fixedbugs/bug223
-0.03 fixedbugs/bug224
-0.03 fixedbugs/bug225
-0.03 fixedbugs/bug227
-0.03 fixedbugs/bug228
-0.03 fixedbugs/bug229
-0.03 fixedbugs/bug230
-0.02 fixedbugs/bug231
-0.00 fixedbugs/bug232
-0.01 fixedbugs/bug233
-0.04 fixedbugs/bug234
-0.00 fixedbugs/bug235
-0.04 fixedbugs/bug236
-0.15 fixedbugs/bug237
-0.03 fixedbugs/bug238
-0.00 fixedbugs/bug239
-0.03 fixedbugs/bug240
-0.03 fixedbugs/bug241
-0.04 fixedbugs/bug242
-0.04 fixedbugs/bug243
-0.03 fixedbugs/bug244
-0.00 fixedbugs/bug245
-0.03 fixedbugs/bug246
-0.03 fixedbugs/bug247
-0.11 fixedbugs/bug248
-0.03 fixedbugs/bug249
-0.00 fixedbugs/bug250
-0.03 fixedbugs/bug251
-0.03 fixedbugs/bug252
-0.03 fixedbugs/bug253
-0.03 fixedbugs/bug254
-0.03 fixedbugs/bug255
-0.03 fixedbugs/bug256
-0.47 fixedbugs/bug257
-0.14 fixedbugs/bug258
-0.16 fixedbugs/bug259
-0.16 fixedbugs/bug260
-0.03 fixedbugs/bug261
-0.10 fixedbugs/bug262
-0.03 fixedbugs/bug263
-0.03 fixedbugs/bug264
-0.07 fixedbugs/bug265
-0.03 fixedbugs/bug266
-0.00 fixedbugs/bug267
-0.03 fixedbugs/bug269
-0.13 fixedbugs/bug271
-0.02 fixedbugs/bug272
-0.04 fixedbugs/bug273
-0.02 fixedbugs/bug274
-0.00 fixedbugs/bug275
-0.03 fixedbugs/bug276
-0.00 fixedbugs/bug277
-0.03 fixedbugs/bug278
-0.04 fixedbugs/bug279
-0.02 fixedbugs/bug280
-0.04 fixedbugs/bug281
-0.00 fixedbugs/bug282
-0.00 fixedbugs/bug283
-0.03 fixedbugs/bug284
-0.05 fixedbugs/bug285
-0.04 fixedbugs/bug286
-0.02 fixedbugs/bug287
-0.00 fixedbugs/bug288
-0.02 fixedbugs/bug289
-0.04 fixedbugs/bug290
-0.04 fixedbugs/bug291
-0.03 fixedbugs/bug292
-0.04 fixedbugs/bug293
-0.03 fixedbugs/bug294
-0.16 fixedbugs/bug295
-0.04 fixedbugs/bug296
-0.03 fixedbugs/bug297
-0.03 fixedbugs/bug298
-0.03 fixedbugs/bug299
-0.03 fixedbugs/bug300
-0.00 fixedbugs/bug301
-0.04 fixedbugs/bug302
-0.05 fixedbugs/bug303
-0.00 fixedbugs/bug304
-0.03 fixedbugs/bug305
-0.01 fixedbugs/bug306
-0.00 fixedbugs/bug307
-0.01 fixedbugs/bug308
-0.00 fixedbugs/bug309
-0.04 fixedbugs/bug311
-0.03 fixedbugs/bug312
-0.04 fixedbugs/bug313
-0.04 fixedbugs/bug314
-0.00 fixedbugs/bug315
-0.00 fixedbugs/bug316
-0.03 fixedbugs/bug317
-0.03 fixedbugs/bug318
-0.00 fixedbugs/bug319
-0.03 fixedbugs/bug320
-0.14 fixedbugs/bug321
-0.04 fixedbugs/bug322
-0.03 fixedbugs/bug323
-0.04 fixedbugs/bug324
-0.03 fixedbugs/bug325
-0.02 fixedbugs/bug326
-0.04 fixedbugs/bug327
-0.03 fixedbugs/bug328
-0.04 fixedbugs/bug329
-0.02 fixedbugs/bug330
-0.04 fixedbugs/bug331
-0.02 fixedbugs/bug332
-0.03 fixedbugs/bug333
-0.01 fixedbugs/bug334
-0.01 fixedbugs/bug335
-0.04 fixedbugs/bug336
-0.03 fixedbugs/bug337
-0.00 fixedbugs/bug338
-0.03 fixedbugs/bug339
-0.02 fixedbugs/bug340
-0.03 fixedbugs/bug341
-0.02 fixedbugs/bug342
-0.04 fixedbugs/bug343
-0.02 fixedbugs/bug344
-0.03 fixedbugs/bug345
-0.08 fixedbugs/bug346
-0.04 fixedbugs/bug347
-0.06 fixedbugs/bug348
-0.03 fixedbugs/bug349
-0.03 fixedbugs/bug350
-0.02 fixedbugs/bug351
-0.03 fixedbugs/bug352
-0.03 fixedbugs/bug353
-0.00 fixedbugs/bug354
-0.03 fixedbugs/bug355
-0.03 fixedbugs/bug356
-0.02 fixedbugs/bug357
-0.04 fixedbugs/bug358
-0.00 fixedbugs/bug361
-0.03 fixedbugs/bug362
-0.03 fixedbugs/bug363
-0.15 fixedbugs/bug364
-0.02 fixedbugs/bug365
-0.03 fixedbugs/bug366
-0.03 fixedbugs/bug367
-0.03 fixedbugs/bug368
-0.51 fixedbugs/bug369
-0.03 fixedbugs/bug370
-0.02 fixedbugs/bug371
-0.03 fixedbugs/bug372
-0.03 fixedbugs/bug373
-0.03 fixedbugs/bug374
-0.03 fixedbugs/bug375
-0.03 fixedbugs/bug376
-0.01 fixedbugs/bug377
-0.03 fixedbugs/bug378
-0.02 fixedbugs/bug379
-0.00 fixedbugs/bug380
-0.03 fixedbugs/bug381
-0.01 fixedbugs/bug382
-0.03 fixedbugs/bug383
-0.03 fixedbugs/bug384
-0.00 fixedbugs/bug385_32
-0.03 fixedbugs/bug385_64
-0.03 fixedbugs/bug386
-0.01 fixedbugs/bug387
-0.02 fixedbugs/bug388
-0.03 fixedbugs/bug389
-0.03 fixedbugs/bug390
-0.00 fixedbugs/bug391
-0.01 fixedbugs/bug392
-0.00 fixedbugs/bug393
-0.03 fixedbugs/bug394
-0.00 fixedbugs/bug395
-0.01 fixedbugs/bug396
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simulating a Turing machine, sort of.
+
package main
// brainfuck
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple type switches, including chans, maps etc.
+
package main
import "os"
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test simple type switches on basic types.
+
package main
import "fmt"
-// errchk $G -e $D/$F.go
+// errorcheck
// 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.
+// Verify that various erroneous type switches are caught be the compiler.
+// Does not compile.
+
package main
import "io"
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that erroneous type switches are caught be the compiler.
+// Issue 2700, among other things.
+// Does not compile.
+
package main
+import (
+ "io"
+)
type I interface {
- M()
+ M()
}
func main(){
- var x I
- switch x.(type) {
- case string: // ERROR "impossible"
- println("FAIL")
- }
+ var x I
+ switch x.(type) {
+ case string: // ERROR "impossible"
+ println("FAIL")
+ }
+
+ // Issue 2700: if the case type is an interface, nothing is impossible
+
+ var r io.Reader
+
+ _, _ = r.(io.Writer)
+
+ switch r.(type) {
+ case io.Writer:
+ }
+
+ // Issue 2827.
+ switch _ := r.(type) { // ERROR "invalid variable name _|no new variables"
+ }
}
+
+
-// errchk $G -e $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Check line numbers in error messages.
+// Test line numbers in error messages.
+// Does not compile.
package main
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// 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.
+// Test UTF-8 in strings and character constants.
+
package main
import "unicode/utf8"
-// errchk $G $D/$F.go
+// errorcheck
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Verify that a couple of illegal variable declarations are caught by the compiler.
+// Does not compile.
+
package main
func main() {
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result
+// run
// 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.
+// Test var x = x + 1 works.
+
package main
func main() {
-// $G $F.go && $L $F.$A && ./$A.out
+// run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// Test that zero division causes a panic.
+
package main
import (