From ba74e74ac66ab85a4a0a2b06c7e15bba2571823b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 16 Dec 2020 19:38:08 -0800 Subject: [PATCH] test: add new Go tests from source repo --- .../go.test/test/fixedbugs/issue10047.go | 19 ++ .../test/fixedbugs/issue10066.dir/a.go | 11 + .../test/fixedbugs/issue10066.dir/b.go | 7 + .../go.test/test/fixedbugs/issue10066.go | 10 + .../go.test/test/fixedbugs/issue10135.go | 25 +++ .../test/fixedbugs/issue10219.dir/a.go | 24 +++ .../test/fixedbugs/issue10219.dir/b.go | 11 + .../test/fixedbugs/issue10219.dir/c.go | 12 ++ .../go.test/test/fixedbugs/issue10219.go | 10 + .../go.test/test/fixedbugs/issue10253.go | 26 +++ .../go.test/test/fixedbugs/issue10284.go | 16 ++ .../go.test/test/fixedbugs/issue10320.go | 55 +++++ .../go.test/test/fixedbugs/issue10332.go | 25 +++ .../go.test/test/fixedbugs/issue10353.go | 49 +++++ .../go.test/test/fixedbugs/issue10407.go | 16 ++ .../go.test/test/fixedbugs/issue10441.go | 17 ++ .../go.test/test/fixedbugs/issue10486.go | 31 +++ .../go.test/test/fixedbugs/issue10607.go | 34 ++++ .../go.test/test/fixedbugs/issue10607a.go | 81 ++++++++ .../go.test/test/fixedbugs/issue10654.go | 17 ++ .../test/fixedbugs/issue10700.dir/other.go | 10 + .../test/fixedbugs/issue10700.dir/test.go | 49 +++++ .../go.test/test/fixedbugs/issue10700.go | 7 + .../go.test/test/fixedbugs/issue10925.go | 23 +++ .../go.test/test/fixedbugs/issue10958.go | 95 +++++++++ .../go.test/test/fixedbugs/issue10975.go | 18 ++ .../go.test/test/fixedbugs/issue10977.go | 20 ++ .../test/fixedbugs/issue11053.dir/p.go | 9 + .../test/fixedbugs/issue11053.dir/p_test.go | 51 +++++ .../go.test/test/fixedbugs/issue11053.go | 10 + .../go.test/test/fixedbugs/issue11053.out | 3 + .../go.test/test/fixedbugs/issue11256.go | 53 +++++ .../go.test/test/fixedbugs/issue11286.go | 34 ++++ .../go.test/test/fixedbugs/issue11326b.go | 44 ++++ .../go.test/test/fixedbugs/issue11354.go | 15 ++ .../go.test/test/fixedbugs/issue11359.go | 11 + .../go.test/test/fixedbugs/issue11361.go | 11 + .../go.test/test/fixedbugs/issue11362.go | 15 ++ .../go.test/test/fixedbugs/issue11369.go | 27 +++ .../go.test/test/fixedbugs/issue11370.go | 13 ++ .../go.test/test/fixedbugs/issue11371.go | 17 ++ .../go.test/test/fixedbugs/issue11590.go | 11 + .../go.test/test/fixedbugs/issue11610.go | 17 ++ .../go.test/test/fixedbugs/issue11614.go | 26 +++ .../go.test/test/fixedbugs/issue11674.go | 40 ++++ .../go.test/test/fixedbugs/issue11699.go | 12 ++ .../go.test/test/fixedbugs/issue11750.go | 20 ++ .../go.test/test/fixedbugs/issue11771.go | 64 ++++++ .../go.test/test/fixedbugs/issue11790.go | 36 ++++ .../go.test/test/fixedbugs/issue11945.go | 71 +++++++ .../go.test/test/fixedbugs/issue11987.go | 23 +++ .../go.test/test/fixedbugs/issue12006.go | 174 ++++++++++++++++ .../go.test/test/fixedbugs/issue12108.go | 37 ++++ .../go.test/test/fixedbugs/issue12133.go | 26 +++ .../go.test/test/fixedbugs/issue12226.go | 15 ++ .../go.test/test/fixedbugs/issue12347.go | 16 ++ .../go.test/test/fixedbugs/issue12411.go | 24 +++ .../go.test/test/fixedbugs/issue12413.go | 19 ++ .../go.test/test/fixedbugs/issue12536.go | 22 ++ .../go.test/test/fixedbugs/issue12577.go | 66 ++++++ .../go.test/test/fixedbugs/issue12588.go | 88 ++++++++ .../test/fixedbugs/issue12677.dir/p.go | 8 + .../test/fixedbugs/issue12677.dir/q.go | 7 + .../go.test/test/fixedbugs/issue12677.go | 9 + .../go.test/test/fixedbugs/issue12686.go | 16 ++ .../go.test/test/fixedbugs/issue1304.go | 23 +++ .../go.test/test/fixedbugs/issue13160.go | 70 +++++++ .../go.test/test/fixedbugs/issue13162.go | 82 ++++++++ .../go.test/test/fixedbugs/issue13169.go | 49 +++++ .../go.test/test/fixedbugs/issue13171.go | 34 ++++ .../go.test/test/fixedbugs/issue13248.go | 13 ++ .../go.test/test/fixedbugs/issue13261.go | 29 +++ .../go.test/test/fixedbugs/issue13262.go | 21 ++ .../go.test/test/fixedbugs/issue13263.go | 15 ++ .../go.test/test/fixedbugs/issue13266.go | 10 + .../go.test/test/fixedbugs/issue13268.go | 42 ++++ .../go.test/test/fixedbugs/issue13274.go | 11 + .../go.test/test/fixedbugs/issue13337.go | 30 +++ .../go.test/test/fixedbugs/issue13365.go | 25 +++ .../go.test/test/fixedbugs/issue13415.go | 19 ++ .../go.test/test/fixedbugs/issue13471.go | 25 +++ .../go.test/test/fixedbugs/issue13480.go | 38 ++++ .../go.test/test/fixedbugs/issue13485.go | 18 ++ .../go.test/test/fixedbugs/issue13539.go | 20 ++ .../go.test/test/fixedbugs/issue13684.go | 17 ++ .../test/fixedbugs/issue13777.dir/burnin.go | 19 ++ .../test/fixedbugs/issue13777.dir/main.go | 11 + .../go.test/test/fixedbugs/issue13777.go | 7 + .../go.test/test/fixedbugs/issue13799.go | 190 ++++++++++++++++++ .../go.test/test/fixedbugs/issue13821.go | 15 ++ .../go.test/test/fixedbugs/issue13821b.go | 24 +++ .../go.test/test/fixedbugs/issue14006.go | 67 ++++++ .../go.test/test/fixedbugs/issue14010.go | 15 ++ .../go.test/test/fixedbugs/issue14136.go | 19 ++ .../test/fixedbugs/issue14164.dir/a.go | 47 +++++ .../test/fixedbugs/issue14164.dir/main.go | 12 ++ .../go.test/test/fixedbugs/issue14164.go | 7 + .../test/fixedbugs/issue14331.dir/a.go | 14 ++ .../test/fixedbugs/issue14331.dir/b.go | 11 + .../go.test/test/fixedbugs/issue14331.go | 9 + .../go.test/test/fixedbugs/issue14405.go | 17 ++ .../go.test/test/fixedbugs/issue14520.go | 14 ++ .../go.test/test/fixedbugs/issue14553.go | 45 +++++ .../go.test/test/fixedbugs/issue14591.go | 38 ++++ .../go.test/test/fixedbugs/issue14636.go | 43 ++++ .../go.test/test/fixedbugs/issue14646.go | 23 +++ .../go.test/test/fixedbugs/issue14651.go | 71 +++++++ .../go.test/test/fixedbugs/issue14652.go | 9 + .../go.test/test/fixedbugs/issue14725.go | 57 ++++++ .../go.test/test/fixedbugs/issue14729.go | 14 ++ .../go.test/test/fixedbugs/issue14988.go | 13 ++ .../go.test/test/fixedbugs/issue15013.go | 24 +++ .../go.test/test/fixedbugs/issue15039.go | 25 +++ .../go.test/test/fixedbugs/issue15042.go | 27 +++ .../test/fixedbugs/issue15071.dir/exp.go | 24 +++ .../test/fixedbugs/issue15071.dir/main.go | 14 ++ .../go.test/test/fixedbugs/issue15071.go | 7 + .../go.test/test/fixedbugs/issue15084.go | 30 +++ .../go.test/test/fixedbugs/issue15141.go | 33 +++ .../go.test/test/fixedbugs/issue15175.go | 66 ++++++ .../go.test/test/fixedbugs/issue15252.go | 32 +++ .../go.test/test/fixedbugs/issue15277.go | 40 ++++ .../go.test/test/fixedbugs/issue15303.go | 24 +++ .../go.test/test/fixedbugs/issue15329.go | 79 ++++++++ .../go.test/test/fixedbugs/issue15439.go | 25 +++ .../test/fixedbugs/issue15470.dir/a.go | 24 +++ .../test/fixedbugs/issue15470.dir/b.go | 3 + .../go.test/test/fixedbugs/issue15470.go | 10 + .../test/fixedbugs/issue15514.dir/a.go | 7 + .../test/fixedbugs/issue15514.dir/b.go | 7 + .../test/fixedbugs/issue15514.dir/c.go | 10 + .../go.test/test/fixedbugs/issue15514.go | 7 + .../go.test/test/fixedbugs/issue15528.go | 131 ++++++++++++ .../test/fixedbugs/issue15548.dir/a.go | 17 ++ .../test/fixedbugs/issue15548.dir/b.go | 9 + .../test/fixedbugs/issue15548.dir/c.go | 10 + .../go.test/test/fixedbugs/issue15548.go | 7 + .../go.test/test/fixedbugs/issue15550.go | 28 +++ .../test/fixedbugs/issue15572.dir/a.go | 40 ++++ .../test/fixedbugs/issue15572.dir/b.go | 27 +++ .../go.test/test/fixedbugs/issue15572.go | 11 + .../go.test/test/fixedbugs/issue15585.go | 45 +++++ .../go.test/test/fixedbugs/issue15602.go | 11 + .../go.test/test/fixedbugs/issue15604.go | 17 ++ .../test/fixedbugs/issue15609.dir/call.go | 7 + .../test/fixedbugs/issue15609.dir/call_386.s | 8 + .../fixedbugs/issue15609.dir/call_amd64.s | 8 + .../fixedbugs/issue15609.dir/call_decl.go | 5 + .../test/fixedbugs/issue15609.dir/main.go | 14 ++ .../test/fixedbugs/issue15646.dir/a.go | 23 +++ .../test/fixedbugs/issue15646.dir/b.go | 16 ++ .../go.test/test/fixedbugs/issue15646.go | 9 + .../go.test/test/fixedbugs/issue15722.go | 21 ++ .../go.test/test/fixedbugs/issue15733.go | 23 +++ .../test/fixedbugs/issue15838.dir/a.go | 61 ++++++ .../test/fixedbugs/issue15838.dir/b.go | 9 + .../go.test/test/fixedbugs/issue15838.go | 12 ++ .../go.test/test/fixedbugs/issue15895.go | 27 +++ .../go.test/test/fixedbugs/issue15898.go | 18 ++ .../go.test/test/fixedbugs/issue15902.go | 27 +++ .../test/fixedbugs/issue15920.dir/a.go | 9 + .../test/fixedbugs/issue15920.dir/b.go | 7 + .../go.test/test/fixedbugs/issue15920.go | 7 + .../go.test/test/fixedbugs/issue15926.go | 20 ++ .../go.test/test/fixedbugs/issue15961.go | 21 ++ .../go.test/test/fixedbugs/issue15988.go | 14 ++ .../go.test/test/fixedbugs/issue15992.go | 38 ++++ .../go.test/test/fixedbugs/issue15992.out | 4 + .../go.test/test/fixedbugs/issue16016.go | 35 ++++ .../go.test/test/fixedbugs/issue16037_run.go | 70 +++++++ .../go.test/test/fixedbugs/issue16095.go | 104 ++++++++++ .../go.test/test/fixedbugs/issue16130.go | 43 ++++ .../test/fixedbugs/issue16133.dir/a1.go | 7 + .../test/fixedbugs/issue16133.dir/a2.go | 7 + .../test/fixedbugs/issue16133.dir/b.go | 7 + .../test/fixedbugs/issue16133.dir/c.go | 10 + .../go.test/test/fixedbugs/issue16193.go | 27 +++ .../go.test/test/fixedbugs/issue16249.go | 58 ++++++ .../go.test/test/fixedbugs/issue16306.go | 15 ++ .../test/fixedbugs/issue16317.dir/a.go | 11 + .../test/fixedbugs/issue16317.dir/b.go | 11 + .../go.test/test/fixedbugs/issue16317.go | 10 + .../go.test/test/fixedbugs/issue16331.go | 48 +++++ .../go.test/test/fixedbugs/issue16369.go | 13 ++ .../go.test/test/fixedbugs/issue16428.go | 12 ++ .../go.test/test/fixedbugs/issue16439.go | 18 ++ .../go.test/test/fixedbugs/issue16515.go | 53 +++++ .../test/fixedbugs/issue16616.dir/a.go | 7 + .../test/fixedbugs/issue16616.dir/b.go | 14 ++ .../fixedbugs/issue16616.dir/issue16616.go | 26 +++ .../go.test/test/fixedbugs/issue16616.go | 9 + .../go.test/test/fixedbugs/issue16733.go | 16 ++ .../go.test/test/fixedbugs/issue16741.go | 17 ++ .../go.test/test/fixedbugs/issue16760.go | 42 ++++ .../go.test/test/fixedbugs/issue16804.go | 16 ++ .../go.test/test/fixedbugs/issue16948.go | 34 ++++ .../go.test/test/fixedbugs/issue16985.go | 37 ++++ .../go.test/test/fixedbugs/issue17005.go | 46 +++++ .../go.test/test/fixedbugs/issue17111.go | 16 ++ .../go.test/test/fixedbugs/issue17194.go | 17 ++ .../go.test/test/fixedbugs/issue17270.go | 11 + .../go.test/test/fixedbugs/issue17328.go | 13 ++ .../go.test/test/fixedbugs/issue17381.go | 54 +++++ .../go.test/test/fixedbugs/issue17551.go | 21 ++ .../go.test/test/fixedbugs/issue17588.go | 20 ++ .../go.test/test/fixedbugs/issue17596.go | 19 ++ .../go.test/test/fixedbugs/issue17631.go | 22 ++ .../go.test/test/fixedbugs/issue17640.go | 28 +++ .../go.test/test/fixedbugs/issue17645.go | 16 ++ .../go.test/test/fixedbugs/issue17710.go | 13 ++ .../go.test/test/fixedbugs/issue17752.go | 20 ++ .../go.test/test/fixedbugs/issue17758.go | 17 ++ .../go.test/test/fixedbugs/issue17918.go | 41 ++++ .../go.test/test/fixedbugs/issue18089.go | 19 ++ .../go.test/test/fixedbugs/issue18092.go | 15 ++ .../go.test/test/fixedbugs/issue18231.go | 20 ++ .../go.test/test/fixedbugs/issue18393.go | 24 +++ .../go.test/test/fixedbugs/issue18410.go | 40 ++++ .../test/fixedbugs/issue18419.dir/other.go | 11 + .../test/fixedbugs/issue18419.dir/test.go | 15 ++ .../go.test/test/fixedbugs/issue18419.go | 7 + .../go.test/test/fixedbugs/issue18595.go | 53 +++++ .../go.test/test/fixedbugs/issue18636.go | 27 +++ .../go.test/test/fixedbugs/issue18640.go | 46 +++++ .../go.test/test/fixedbugs/issue18655.go | 22 ++ .../go.test/test/fixedbugs/issue18661.go | 39 ++++ .../go.test/test/fixedbugs/issue18725.go | 24 +++ .../go.test/test/fixedbugs/issue18808.go | 63 ++++++ .../go.test/test/fixedbugs/issue18906.go | 36 ++++ .../go.test/test/fixedbugs/issue18915.go | 21 ++ .../go.test/test/fixedbugs/issue18994.go | 22 ++ .../go.test/test/fixedbugs/issue19012.go | 25 +++ .../test/fixedbugs/issue19028.dir/a.go | 9 + .../test/fixedbugs/issue19028.dir/main.go | 26 +++ .../go.test/test/fixedbugs/issue19028.go | 13 ++ .../go.test/test/fixedbugs/issue19040.go | 36 ++++ .../go.test/test/fixedbugs/issue19056.go | 9 + .../go.test/test/fixedbugs/issue19078.go | 42 ++++ .../go.test/test/fixedbugs/issue19084.go | 17 ++ .../go.test/test/fixedbugs/issue19137.go | 51 +++++ .../go.test/test/fixedbugs/issue19182.go | 37 ++++ .../go.test/test/fixedbugs/issue19201.go | 52 +++++ .../go.test/test/fixedbugs/issue19217.go | 39 ++++ .../go.test/test/fixedbugs/issue19275.go | 72 +++++++ .../go.test/test/fixedbugs/issue19323.go | 19 ++ .../go.test/test/fixedbugs/issue19359.go | 91 +++++++++ .../go.test/test/fixedbugs/issue19482.go | 34 ++++ .../test/fixedbugs/issue19507.dir/div_arm.s | 12 ++ .../test/fixedbugs/issue19507.dir/main.go | 16 ++ .../go.test/test/fixedbugs/issue19507.go | 8 + .../go.test/test/fixedbugs/issue19515.go | 51 +++++ .../test/fixedbugs/issue19548.dir/a.go | 26 +++ .../test/fixedbugs/issue19548.dir/b.go | 24 +++ .../go.test/test/fixedbugs/issue19548.go | 9 + .../go.test/test/fixedbugs/issue19555.go | 36 ++++ .../go.test/test/fixedbugs/issue19632.go | 21 ++ .../go.test/test/fixedbugs/issue19658.go | 99 +++++++++ .../go.test/test/fixedbugs/issue19667.go | 13 ++ .../go.test/test/fixedbugs/issue19671.go | 16 ++ .../go.test/test/fixedbugs/issue19678.go | 21 ++ .../go.test/test/fixedbugs/issue19679.go | 38 ++++ .../go.test/test/fixedbugs/issue19696.go | 20 ++ .../go.test/test/fixedbugs/issue19699b.go | 14 ++ .../go.test/test/fixedbugs/issue19705.go | 17 ++ .../go.test/test/fixedbugs/issue19710.go | 25 +++ .../go.test/test/fixedbugs/issue19743.go | 31 +++ .../test/fixedbugs/issue19764.dir/a.go | 15 ++ .../test/fixedbugs/issue19764.dir/b.go | 13 ++ .../go.test/test/fixedbugs/issue19764.go | 10 + .../go.test/test/fixedbugs/issue19783.go | 18 ++ .../go.test/test/fixedbugs/issue19799.go | 71 +++++++ .../go.test/test/fixedbugs/issue19880.go | 20 ++ .../go.test/test/fixedbugs/issue19911.go | 34 ++++ .../go.test/test/fixedbugs/issue19977.go | 16 ++ 274 files changed, 7480 insertions(+) create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10047.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10066.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10135.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/c.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10219.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10253.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10284.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10320.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10332.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10353.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10407.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10441.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10486.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10607.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10607a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10654.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/other.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/test.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10700.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10925.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10958.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10975.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue10977.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p_test.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11053.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11053.out create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11256.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11286.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11326b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11354.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11359.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11361.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11362.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11369.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11370.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11371.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11590.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11610.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11614.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11674.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11699.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11750.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11771.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11790.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11945.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue11987.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12006.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12108.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12133.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12226.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12347.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12411.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12413.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12536.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12577.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12588.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/p.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/q.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12677.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue12686.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue1304.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13160.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13162.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13169.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13171.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13248.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13261.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13262.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13263.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13266.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13268.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13274.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13337.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13365.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13415.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13471.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13480.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13485.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13539.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13684.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/burnin.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13777.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13799.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13821.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue13821b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14006.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14010.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14136.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14164.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14331.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14405.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14520.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14553.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14591.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14636.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14646.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14651.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14652.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14725.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14729.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue14988.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15013.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15039.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15042.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/exp.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15071.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15084.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15141.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15175.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15252.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15277.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15303.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15329.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15439.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15470.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/c.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15514.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15528.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/c.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15548.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15550.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15572.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15585.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15602.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15604.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_386.s create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_amd64.s create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_decl.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15646.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15722.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15733.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15838.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15895.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15898.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15902.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15920.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15926.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15961.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15988.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15992.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue15992.out create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16016.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16037_run.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16095.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16130.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a1.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a2.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/c.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16193.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16249.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16306.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16317.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16331.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16369.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16428.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16439.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16515.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/issue16616.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16616.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16733.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16741.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16760.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16804.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16948.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue16985.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17005.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17111.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17194.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17270.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17328.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17381.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17551.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17588.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17596.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17631.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17640.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17645.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17710.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17752.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17758.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue17918.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18089.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18092.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18231.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18393.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18410.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/other.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/test.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18419.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18595.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18636.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18640.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18655.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18661.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18725.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18808.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18906.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18915.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue18994.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19012.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19028.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19040.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19056.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19078.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19084.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19137.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19182.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19201.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19217.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19275.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19323.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19359.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19482.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/div_arm.s create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/main.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19507.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19515.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19548.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19555.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19632.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19658.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19667.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19671.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19678.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19679.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19696.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19699b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19705.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19710.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19743.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/a.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/b.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19764.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19783.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19799.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19880.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19911.go create mode 100644 gcc/testsuite/go.test/test/fixedbugs/issue19977.go diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10047.go b/gcc/testsuite/go.test/test/fixedbugs/issue10047.go new file mode 100644 index 00000000000..dcbde48e876 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10047.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10047: gccgo failed to compile a type switch where the switch variable +// and the base type of a case share the same identifier. + +package main + +func main() { + type t int + var p interface{} + switch t := p.(type) { + case t: + _ = t + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/a.go new file mode 100644 index 00000000000..8bb3b303ea6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/a.go @@ -0,0 +1,11 @@ +package a + +import "log" + +func Do() { + Do2() +} + +func Do2() { + println(log.Ldate | log.Ltime | log.Lshortfile) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/b.go new file mode 100644 index 00000000000..46d2f55fed6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10066.dir/b.go @@ -0,0 +1,7 @@ +package b + +import "./a" + +func test() { + a.Do() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10066.go b/gcc/testsuite/go.test/test/fixedbugs/issue10066.go new file mode 100644 index 00000000000..3ea552f9fea --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10066.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10066: constants are printed in the original form +// in export data. This is the opposite of issue 9076. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10135.go b/gcc/testsuite/go.test/test/fixedbugs/issue10135.go new file mode 100644 index 00000000000..9985e5a0ee0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10135.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10135: append a slice with zero-sized element used +// to always return a slice with the same data pointer as the +// old slice, even if it's nil, so this program used to panic +// with nil pointer dereference because after append, s is a +// slice with nil data pointer but non-zero len and cap. + +package main + +type empty struct{} + +func main() { + var s []empty + + s = append(s, empty{}) + + for _, v := range s { + _ = v + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/a.go new file mode 100644 index 00000000000..c61d02b66a9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/a.go @@ -0,0 +1,24 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type m struct { + S string +} + +var g = struct { + m + P string +}{ + m{"a"}, + "", +} + +type S struct{} + +func (s *S) M(p string) { + r := g + r.P = p +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/b.go new file mode 100644 index 00000000000..09d8911ff4a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/b.go @@ -0,0 +1,11 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +func F() *a.S { + return &a.S{} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/c.go b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/c.go new file mode 100644 index 00000000000..d331495df20 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10219.dir/c.go @@ -0,0 +1,12 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package c + +import "./b" + +func F() { + s := b.F() + s.M("c") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10219.go b/gcc/testsuite/go.test/test/fixedbugs/issue10219.go new file mode 100644 index 00000000000..325818cff2a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10219.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10219: failure of inlinable function that uses embedded types +// in an anonymous struct via :=. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10253.go b/gcc/testsuite/go.test/test/fixedbugs/issue10253.go new file mode 100644 index 00000000000..fafca6c733e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10253.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 10253: cmd/7g: bad codegen, probably regopt related + +package main + +func main() { + if !eq() { + panic("wrong value") + } +} + +var text = "abc" +var s = &str{text} + +func eq() bool { + return text[0] == s.text[0] +} + +type str struct { + text string +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10284.go b/gcc/testsuite/go.test/test/fixedbugs/issue10284.go new file mode 100644 index 00000000000..39028e756ca --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10284.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10284: gccgo failed to allow converting a user-defined +// type whose underlying type is uintptr to unsafe.Pointer. + +package p + +import "unsafe" + +type T uintptr + +var _ unsafe.Pointer = unsafe.Pointer(T(0)) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10320.go b/gcc/testsuite/go.test/test/fixedbugs/issue10320.go new file mode 100644 index 00000000000..c7e2bab569c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10320.go @@ -0,0 +1,55 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10320: 7g failed to compile a program because it attempted +// to use ZR as register. Other programs compiled but failed to +// execute correctly because they clobbered the g register. + +package main + +func main() { + var x00, x01, x02, x03, x04, x05, x06, x07, x08, x09 int + var x10, x11, x12, x13, x14, x15, x16, x17, x18, x19 int + var x20, x21, x22, x23, x24, x25, x26, x27, x28, x29 int + var x30, x31, x32 int + + _ = x00 + _ = x01 + _ = x02 + _ = x03 + _ = x04 + _ = x05 + _ = x06 + _ = x07 + _ = x08 + _ = x09 + + _ = x10 + _ = x11 + _ = x12 + _ = x13 + _ = x14 + _ = x15 + _ = x16 + _ = x17 + _ = x18 + _ = x19 + + _ = x20 + _ = x21 + _ = x22 + _ = x23 + _ = x24 + _ = x25 + _ = x26 + _ = x27 + _ = x28 + _ = x29 + + _ = x30 + _ = x31 + _ = x32 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10332.go b/gcc/testsuite/go.test/test/fixedbugs/issue10332.go new file mode 100644 index 00000000000..096b7a50554 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10332.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The PkgPath of unexported fields of types defined in package main was incorrectly "" + +package main + +import ( + "fmt" + "reflect" +) + +type foo struct { + bar int +} + +func main() { + pkgpath := reflect.ValueOf(foo{}).Type().Field(0).PkgPath + if pkgpath != "main" { + fmt.Printf("BUG: incorrect PkgPath: %v", pkgpath) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10353.go b/gcc/testsuite/go.test/test/fixedbugs/issue10353.go new file mode 100644 index 00000000000..87771d400d3 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10353.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 10253: cmd/gc: incorrect escape analysis of closures +// Partial call x.foo was not promoted to heap. + +package main + +func main() { + c := make(chan bool) + // Create a new goroutine to get a default-size stack segment. + go func() { + x := new(X) + clos(x.foo)() + c <- true + }() + <-c +} + +type X int + +func (x *X) foo() { +} + +func clos(x func()) func() { + f := func() { + print("") + x() // This statement crashed, because the partial call was allocated on the old stack. + } + // Grow stack so that partial call x becomes invalid if allocated on stack. + growstack(10000) + c := make(chan bool) + // Spoil the previous stack segment. + go func() { + c <- true + }() + <-c + return f +} + +func growstack(x int) { + if x == 0 { + return + } + growstack(x - 1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10407.go b/gcc/testsuite/go.test/test/fixedbugs/issue10407.go new file mode 100644 index 00000000000..c6461a36204 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10407.go @@ -0,0 +1,16 @@ +// runoutput + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10407: gccgo failed to remove carriage returns +// from raw string literals. + +package main + +import "fmt" + +func main() { + fmt.Println("package main\nfunc main() { if `a\rb\r\nc` != \"ab\\nc\" { panic(42) }}") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10441.go b/gcc/testsuite/go.test/test/fixedbugs/issue10441.go new file mode 100644 index 00000000000..9bc4948b15b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10441.go @@ -0,0 +1,17 @@ +// build + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func bar() { + f := func() {} + foo(&f) +} + +//go:noinline +func foo(f *func()) func() { + return *f +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10486.go b/gcc/testsuite/go.test/test/fixedbugs/issue10486.go new file mode 100644 index 00000000000..3b62cb9002f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10486.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10486. +// Check stack walk during div by zero fault, +// especially on software divide systems. + +package main + +import "runtime" + +var A, B int + +func divZero() int { + defer func() { + if p := recover(); p != nil { + var pcs [512]uintptr + runtime.Callers(2, pcs[:]) + runtime.GC() + } + }() + return A / B +} + +func main() { + A = 1 + divZero() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10607.go b/gcc/testsuite/go.test/test/fixedbugs/issue10607.go new file mode 100644 index 00000000000..6f4717d8202 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10607.go @@ -0,0 +1,34 @@ +// +build linux,!ppc64,!riscv64 +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that a -B option is passed through when using both internal +// and external linking mode. + +// TODO(jsing): Re-enable on riscv64 when it has support for external +// linking - see golang.org/issue/36739 + +package main + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" +) + +func main() { + test("internal") + test("external") +} + +func test(linkmode string) { + out, err := exec.Command("go", "run", "-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() + if err != nil { + fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out) + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10607a.go b/gcc/testsuite/go.test/test/fixedbugs/issue10607a.go new file mode 100644 index 00000000000..51399e4ecfc --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10607a.go @@ -0,0 +1,81 @@ +// skip + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This is built by issue10607.go with a -B option. +// Verify that we have one build-id note with the expected value. + +package main + +import ( + "bytes" + "debug/elf" + "fmt" + "os" +) + +func main() { + f, err := elf.Open("/proc/self/exe") + if err != nil { + if os.IsNotExist(err) { + return + } + fmt.Fprintln(os.Stderr, "opening /proc/self/exe:", err) + os.Exit(1) + } + + c := 0 + fail := false + for i, s := range f.Sections { + if s.Type != elf.SHT_NOTE { + continue + } + + d, err := s.Data() + if err != nil { + fmt.Fprintf(os.Stderr, "reading data of note section %d: %v\n", i, err) + continue + } + + for len(d) > 0 { + namesz := f.ByteOrder.Uint32(d) + descsz := f.ByteOrder.Uint32(d[4:]) + typ := f.ByteOrder.Uint32(d[8:]) + + an := (namesz + 3) &^ 3 + ad := (descsz + 3) &^ 3 + + if int(12+an+ad) > len(d) { + fmt.Fprintf(os.Stderr, "note section %d too short for header (%d < 12 + align(%d,4) + align(%d,4))\n", i, len(d), namesz, descsz) + break + } + + // 3 == NT_GNU_BUILD_ID + if typ == 3 && namesz == 4 && bytes.Equal(d[12:16], []byte("GNU\000")) { + id := string(d[12+an:12+an+descsz]) + if id == "\x12\x34\x56\x78" { + c++ + } else { + fmt.Fprintf(os.Stderr, "wrong build ID data: %q\n", id) + fail = true + } + } + + d = d[12+an+ad:] + } + } + + if c == 0 { + fmt.Fprintln(os.Stderr, "no build-id note") + fail = true + } else if c > 1 { + fmt.Fprintln(os.Stderr, c, "build-id notes") + fail = true + } + + if fail { + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10654.go b/gcc/testsuite/go.test/test/fixedbugs/issue10654.go new file mode 100644 index 00000000000..0600a801bb2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10654.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10654: Failure to use generated temps +// for function calls etc. in boolean codegen. + +package main + +var s string + +func main() { + if (s == "this") != (s == "that") { + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/other.go b/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/other.go new file mode 100644 index 00000000000..12908b92053 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/other.go @@ -0,0 +1,10 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package other + +type Exported interface { + Do() + secret() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/test.go b/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/test.go new file mode 100644 index 00000000000..2dfc24af077 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10700.dir/test.go @@ -0,0 +1,49 @@ +// errorcheck -0 -m -l + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./other" + +type Imported interface { + Do() +} + +type HasAMethod struct { + x int +} + +func (me *HasAMethod) Do() { + println(me.x) +} + +func InMyCode(x *Imported, y *HasAMethod, z *other.Exported) { + x.Do() // ERROR "x\.Do undefined \(type \*Imported is pointer to interface, not interface\)|type that is pointer to interface" + x.do() // ERROR "x\.do undefined \(type \*Imported is pointer to interface, not interface\)|type that is pointer to interface" + (*x).Do() + x.Dont() // ERROR "x\.Dont undefined \(type \*Imported is pointer to interface, not interface\)|type that is pointer to interface" + (*x).Dont() // ERROR "\(\*x\)\.Dont undefined \(type Imported has no field or method Dont\)|reference to undefined field or method" + + y.Do() + y.do() // ERROR "y\.do undefined \(type \*HasAMethod has no field or method do, but does have Do\)|reference to undefined field or method" + (*y).Do() + (*y).do() // ERROR "\(\*y\)\.do undefined \(type HasAMethod has no field or method do, but does have Do\)|reference to undefined field or method" + y.Dont() // ERROR "y\.Dont undefined \(type \*HasAMethod has no field or method Dont\)|reference to undefined field or method" + (*y).Dont() // ERROR "\(\*y\)\.Dont undefined \(type HasAMethod has no field or method Dont\)|reference to undefined field or method" + + z.Do() // ERROR "z\.Do undefined \(type \*other\.Exported is pointer to interface, not interface\)|type that is pointer to interface" + z.do() // ERROR "z\.do undefined \(type \*other\.Exported is pointer to interface, not interface\)|type that is pointer to interface" + (*z).Do() + (*z).do() // ERROR "\(\*z\)\.do undefined \(type other.Exported has no field or method do, but does have Do\)|reference to undefined field or method" + z.Dont() // ERROR "z\.Dont undefined \(type \*other\.Exported is pointer to interface, not interface\)|type that is pointer to interface" + (*z).Dont() // ERROR "\(\*z\)\.Dont undefined \(type other\.Exported has no field or method Dont\)|reference to undefined field or method" + z.secret() // ERROR "z\.secret undefined \(type \*other\.Exported is pointer to interface, not interface\)|type that is pointer to interface" + (*z).secret() // ERROR "\(\*z\)\.secret undefined \(cannot refer to unexported field or method secret\)|reference to unexported field or method" + +} + +func main() { +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10700.go b/gcc/testsuite/go.test/test/fixedbugs/issue10700.go new file mode 100644 index 00000000000..25544efd9b9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10700.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10925.go b/gcc/testsuite/go.test/test/fixedbugs/issue10925.go new file mode 100644 index 00000000000..30add82c78a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10925.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func prototype(xyz []string) {} +func main() { + var got [][]string + f := prototype + f = func(ss []string) { got = append(got, ss) } + for _, s := range []string{"one", "two", "three"} { + f([]string{s}) + } + if got[0][0] != "one" || got[1][0] != "two" || got[2][0] != "three" { + // Bug's wrong output was [[three] [three] [three]] + fmt.Println("Expected [[one] [two] [three]], got", got) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10958.go b/gcc/testsuite/go.test/test/fixedbugs/issue10958.go new file mode 100644 index 00000000000..52487fb9bd6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10958.go @@ -0,0 +1,95 @@ +// +build !nacl,!js,disabled_see_issue_18589 +// buildrun -t 10 -gcflags=-d=ssa/insert_resched_checks/on,ssa/check/on + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test is disabled because it flakes when run in all.bash +// on some platforms, but is useful standalone to verify +// that rescheduling checks are working (and we may wish +// to investigate the flake, since it suggests that the +// loop rescheduling check may not work right on those +// platforms). + +// This checks to see that call-free infinite loops do not +// block garbage collection. IF YOU RUN IT STANDALONE without +// -gcflags=-d=ssa/insert_resched_checks/on in a not-experimental +// build, it should hang. + +package main + +import ( + "runtime" +) + +var someglobal1 int +var someglobal2 int +var someglobal3 int + +//go:noinline +func f() {} + +func standinacorner1() { + for someglobal1&1 == 0 { + someglobal1++ + someglobal1++ + } +} + +func standinacorner2(i int) { + // contains an irreducible loop containing changes to memory + if i != 0 { + goto midloop + } + +loop: + if someglobal2&1 != 0 { + goto done + } + someglobal2++ +midloop: + someglobal2++ + goto loop + +done: + return +} + +func standinacorner3() { + for someglobal3&1 == 0 { + if someglobal3&2 != 0 { + for someglobal3&3 == 2 { + someglobal3++ + someglobal3++ + someglobal3++ + someglobal3++ + } + } + someglobal3++ + someglobal3++ + someglobal3++ + someglobal3++ + } +} + +func main() { + go standinacorner1() + go standinacorner2(0) + go standinacorner3() + // println("About to stand in a corner1") + for someglobal1 == 0 { + runtime.Gosched() + } + // println("About to stand in a corner2") + for someglobal2 == 0 { + runtime.Gosched() + } + // println("About to stand in a corner3") + for someglobal3 == 0 { + runtime.Gosched() + } + // println("About to GC") + runtime.GC() + // println("Success") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10975.go b/gcc/testsuite/go.test/test/fixedbugs/issue10975.go new file mode 100644 index 00000000000..933badfd2f3 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10975.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 10975: Returning an invalid interface would cause +// `internal compiler error: getinarg: not a func`. + +package main + +type I interface { + int // ERROR "interface contains embedded non-interface" +} + +func New() I { + return struct{}{} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue10977.go b/gcc/testsuite/go.test/test/fixedbugs/issue10977.go new file mode 100644 index 00000000000..0b18c700056 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue10977.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +type T struct{} + +var ( + t = T{} + u = t.New() +) + +func x(T) (int, int) { return 0, 0 } + +var _, _ = x(u) + +func (T) New() T { return T{} } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p.go b/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p.go new file mode 100644 index 00000000000..81b412aef13 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p.go @@ -0,0 +1,9 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func Int32(i int32) *int32 { + return &i +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p_test.go b/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p_test.go new file mode 100644 index 00000000000..542c2a349e5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11053.dir/p_test.go @@ -0,0 +1,51 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "p" +) + +type I interface { + Add(out *P) +} + +type P struct { + V *int32 +} + +type T struct{} + +var x int32 = 42 + +func Int32x(i int32) *int32 { + return &i +} + +func (T) Add(out *P) { + out.V = p.Int32(x) // inlined, p.i.2 moved to heap +} + +var PP P +var out *P = &PP + +func F(s I) interface{} { + s.Add(out) // not inlined. + return out +} + +var s T + +func main() { + println("Starting") + fmt.Sprint(new(int32)) + resp := F(s).(*P) + println("Before, *resp.V=", *resp.V) // Trashes *resp.V in process of printing. + println("After, *resp.V=", *resp.V) + if got, want := *resp.V, int32(42); got != want { + fmt.Printf("FAIL, got %v, want %v", got, want) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11053.go b/gcc/testsuite/go.test/test/fixedbugs/issue11053.go new file mode 100644 index 00000000000..06005d3841d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11053.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11053: Compiler does not run escape analysis on an inlined +// generated method wrapper. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11053.out b/gcc/testsuite/go.test/test/fixedbugs/issue11053.out new file mode 100644 index 00000000000..a75f73c8829 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11053.out @@ -0,0 +1,3 @@ +Starting +Before, *resp.V= 42 +After, *resp.V= 42 diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11256.go b/gcc/testsuite/go.test/test/fixedbugs/issue11256.go new file mode 100644 index 00000000000..69fc3e8d842 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11256.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that stack barriers are reset when a goroutine exits without +// returning. + +package main + +import ( + "runtime" + "sync/atomic" + "time" +) + +func main() { + // Let the garbage collector run concurrently. + runtime.GOMAXPROCS(2) + + var x [100][]byte + + for i := range x { + var done int32 + + go func() { + // Use enough stack to get stack barriers, but + // not so much that we go over _FixedStack. + // There's a very narrow window here on most + // OSs, so we basically can't do anything (not + // even a time.Sleep or a channel). + var buf [1024]byte + buf[0]++ + for atomic.LoadInt32(&done) == 0 { + runtime.Gosched() + } + atomic.StoreInt32(&done, 0) + // Exit without unwinding stack barriers. + runtime.Goexit() + }() + + // Generate some garbage. + x[i] = make([]byte, 1024*1024) + + // Give GC some time to install stack barriers in the G. + time.Sleep(50 * time.Microsecond) + atomic.StoreInt32(&done, 1) + for atomic.LoadInt32(&done) == 1 { + runtime.Gosched() + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11286.go b/gcc/testsuite/go.test/test/fixedbugs/issue11286.go new file mode 100644 index 00000000000..560b7d47942 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11286.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that pointer bitmaps of types with large scalar tails are +// correctly repeated when unrolled into the heap bitmap. + +package main + +import "runtime" + +const D = 57 + +type T struct { + a [D]float64 + b map[string]int + c [D]float64 +} + +var ts []T + +func main() { + ts = make([]T, 4) + for i := range ts { + ts[i].b = make(map[string]int) + } + ts[3].b["abc"] = 42 + runtime.GC() + if ts[3].b["abc"] != 42 { + panic("bad field value") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11326b.go b/gcc/testsuite/go.test/test/fixedbugs/issue11326b.go new file mode 100644 index 00000000000..8aba4d91215 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11326b.go @@ -0,0 +1,44 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// Tests for golang.org/issue/11326. + +func main() { + { + const n = 1e646456992 + const d = 1e646456991 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e64645699 + const d = 1e64645698 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e6464569 + const d = 1e6464568 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e646456 + const d = 1e646455 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11354.go b/gcc/testsuite/go.test/test/fixedbugs/issue11354.go new file mode 100644 index 00000000000..3980e8fcae4 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11354.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2017 The Go 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 X int + +var foo = map[int]X{} + +var bar = map[int][8]X{} + +func main() {} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11359.go b/gcc/testsuite/go.test/test/fixedbugs/issue11359.go new file mode 100644 index 00000000000..6ffffede6b9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11359.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// identifiers beginning with non-ASCII digits were incorrectly accepted. +// issue 11359. + +package p +var ۶ = 0 // ERROR "identifier cannot begin with digit" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11361.go b/gcc/testsuite/go.test/test/fixedbugs/issue11361.go new file mode 100644 index 00000000000..63dbf05d731 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11361.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +import "fmt" // GC_ERROR "imported and not used" + +const n = fmt // ERROR "fmt without selector|unexpected reference to package" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11362.go b/gcc/testsuite/go.test/test/fixedbugs/issue11362.go new file mode 100644 index 00000000000..964e5fdf6b7 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11362.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11362: prints empty canonical import path + +package main + +import _ "unicode//utf8" // GC_ERROR "non-canonical import path .unicode//utf8. \(should be .unicode/utf8.\)" "can't find import: .unicode//utf8." + +func main() { +} + diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11369.go b/gcc/testsuite/go.test/test/fixedbugs/issue11369.go new file mode 100644 index 00000000000..9df37c36499 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11369.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that the half multiply resulting from a division +// by a constant generates correct code. + +package main + +func main() { + var _ = 7 / "0"[0] // test case from #11369 + var _ = 1 / "."[0] // test case from #11358 + var x = 0 / "0"[0] + var y = 48 / "0"[0] + var z = 5 * 48 / "0"[0] + if x != 0 { + panic("expected 0") + } + if y != 1 { + panic("expected 1") + } + if z != 5 { + panic("expected 5") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11370.go b/gcc/testsuite/go.test/test/fixedbugs/issue11370.go new file mode 100644 index 00000000000..30f2904550a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11370.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 11370: cmd/compile: "0"[0] should not be a constant + +package p + +func main() { + println(-"abc"[1] >> 1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11371.go b/gcc/testsuite/go.test/test/fixedbugs/issue11371.go new file mode 100644 index 00000000000..8acd18fccb9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11371.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2017 The Go 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 11371 (cmd/compile: meaningless error message "truncated to +// integer") + +package issue11371 + +const a int = 1.1 // ERROR "constant 1.1 truncated to integer|floating-point constant truncated to integer" +const b int = 1e20 // ERROR "overflows int|integer constant overflow" +const c int = 1 + 1e-70 // ERROR "constant truncated to integer" +const d int = 1 - 1e-70 // ERROR "constant truncated to integer" +const e int = 1.00000001 // ERROR "constant truncated to integer" +const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|floating-point constant truncated to integer" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11590.go b/gcc/testsuite/go.test/test/fixedbugs/issue11590.go new file mode 100644 index 00000000000..f2a955f96d0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11590.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var _ = int8(4) * 300 // ERROR "constant 300 overflows int8" "constant 1200 overflows int8|integer constant overflow" +var _ = complex64(1) * 1e200 // ERROR "constant 1e\+200 overflows complex64|complex real part overflow" +var _ = complex128(1) * 1e500 // ERROR "constant 1e\+500 overflows complex128|complex real part overflow" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11610.go b/gcc/testsuite/go.test/test/fixedbugs/issue11610.go new file mode 100644 index 00000000000..7ebfae6709f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11610.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test an internal compiler error on ? symbol in declaration +// following an empty import. + +package a +import"" // ERROR "import path is empty" +var? // ERROR "invalid character U\+003F '\?'|invalid character 0x3f in input file" + +var x int // ERROR "unexpected var|expected identifier|expected type" + +func main() { +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11614.go b/gcc/testsuite/go.test/test/fixedbugs/issue11614.go new file mode 100644 index 00000000000..de15f9827ff --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11614.go @@ -0,0 +1,26 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that incorrect expressions involving wrong anonymous interface +// do not generate panics in Type Stringer. +// Does not compile. + +package main + +type I interface { + int // ERROR "interface contains embedded non-interface" +} + +func n() { + (I) +} + +func m() { + (interface{int}) // ERROR "interface contains embedded non-interface" "type interface { int } is not an expression" +} + +func main() { +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11674.go b/gcc/testsuite/go.test/test/fixedbugs/issue11674.go new file mode 100644 index 00000000000..b43032deac4 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11674.go @@ -0,0 +1,40 @@ +// errorcheck + +// Copyright 2017 The Go 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 11674: cmd/compile: does not diagnose constant division by +// zero + +package p + +const x complex64 = 0 +const y complex128 = 0 + +var _ = x / 1e-20 +var _ = x / 1e-50 // GC_ERROR "complex division by zero" +var _ = x / 1e-1000 // GC_ERROR "complex division by zero" +var _ = x / 1e-20i +var _ = x / 1e-50i // GC_ERROR "complex division by zero" +var _ = x / 1e-1000i // GC_ERROR "complex division by zero" + +var _ = x / 1e-45 // smallest positive float32 + +var _ = x / (1e-20 + 1e-20i) +var _ = x / (1e-50 + 1e-20i) +var _ = x / (1e-20 + 1e-50i) +var _ = x / (1e-50 + 1e-50i) // GC_ERROR "complex division by zero" +var _ = x / (1e-1000 + 1e-1000i) // GC_ERROR "complex division by zero" + +var _ = y / 1e-50 +var _ = y / 1e-1000 // GC_ERROR "complex division by zero" +var _ = y / 1e-50i +var _ = y / 1e-1000i // GC_ERROR "complex division by zero" + +var _ = y / 5e-324 // smallest positive float64 + +var _ = y / (1e-50 + 1e-50) +var _ = y / (1e-1000 + 1e-50i) +var _ = y / (1e-50 + 1e-1000i) +var _ = y / (1e-1000 + 1e-1000i) // GC_ERROR "complex division by zero" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11699.go b/gcc/testsuite/go.test/test/fixedbugs/issue11699.go new file mode 100644 index 00000000000..755e9a1fde6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11699.go @@ -0,0 +1,12 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 11699; used to fail with duplicate _.args_stackmap symbols. + +package p + +func _() +func _() diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11750.go b/gcc/testsuite/go.test/test/fixedbugs/issue11750.go new file mode 100644 index 00000000000..d5a2b22dda0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11750.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11750: mkdotargslice: typecheck failed + +package main + +func main() { + fn := func(names string) { + + } + func(names ...string) { + for _, name := range names { + fn(name) + } + }("one", "two") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11771.go b/gcc/testsuite/go.test/test/fixedbugs/issue11771.go new file mode 100644 index 00000000000..99d7060d44e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11771.go @@ -0,0 +1,64 @@ +// +build !nacl,!js +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11771: Magic comments should ignore carriage returns. + +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "runtime" +) + +func main() { + if runtime.Compiler != "gc" { + return + } + + dir, err := ioutil.TempDir("", "go-issue11771") + if err != nil { + log.Fatalf("creating temp dir: %v\n", err) + } + defer os.RemoveAll(dir) + + // The go:nowritebarrier magic comment is only permitted in + // the runtime package. So we confirm that the compilation + // fails. + + var buf bytes.Buffer + fmt.Fprintln(&buf, ` +package main + +func main() { +} +`) + fmt.Fprintln(&buf, "//go:nowritebarrier\r") + fmt.Fprintln(&buf, ` +func x() { +} +`) + + if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil { + log.Fatal(err) + } + + cmd := exec.Command("go", "tool", "compile", "x.go") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { + log.Fatal("compile succeeded unexpectedly") + } + if !bytes.Contains(output, []byte("only allowed in runtime")) { + log.Fatalf("wrong error message from compiler; got:\n%s\n", output) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11790.go b/gcc/testsuite/go.test/test/fixedbugs/issue11790.go new file mode 100644 index 00000000000..096b297f990 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11790.go @@ -0,0 +1,36 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11790: Incorrect error following named pointer dereference on field + +package main + +import "fmt" + +type T0 struct { + x int +} + +func (*T0) M0() { + fmt.Println("M0") +} + +type T2 struct { + *T0 +} + +type Q *T2 + +func main() { + // If run, expected output is + // 42 + // M0 + t0 := T0{42} + t2 := T2{&t0} + var q Q = &t2 + fmt.Println(q.x) // Comment out either this line or the next line and the program works + (*q).T0.M0() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11945.go b/gcc/testsuite/go.test/test/fixedbugs/issue11945.go new file mode 100644 index 00000000000..510b6555c65 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11945.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2017 The Go 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" + +// issue 17446 +const ( + _ = real(0) // from bug report + _ = imag(0) // from bug report + + // if the arguments are untyped, the results must be untyped + // (and compatible with types that can represent the values) + _ int = real(1) + _ int = real('a') + _ int = real(2.0) + _ int = real(3i) + + _ float32 = real(1) + _ float32 = real('a') + _ float32 = real(2.1) + _ float32 = real(3.2i) + + _ float64 = real(1) + _ float64 = real('a') + _ float64 = real(2.1) + _ float64 = real(3.2i) + + _ int = imag(1) + _ int = imag('a') + _ int = imag(2.1 + 3i) + _ int = imag(3i) + + _ float32 = imag(1) + _ float32 = imag('a') + _ float32 = imag(2.1 + 3.1i) + _ float32 = imag(3i) + + _ float64 = imag(1) + _ float64 = imag('a') + _ float64 = imag(2.1 + 3.1i) + _ float64 = imag(3i) +) + +var tests = []struct { + code string + got, want interface{} +}{ + {"real(1)", real(1), 1.0}, + {"real('a')", real('a'), float64('a')}, + {"real(2.0)", real(2.0), 2.0}, + {"real(3.2i)", real(3.2i), 0.0}, + + {"imag(1)", imag(1), 0.0}, + {"imag('a')", imag('a'), 0.0}, + {"imag(2.1 + 3.1i)", imag(2.1 + 3.1i), 3.1}, + {"imag(3i)", imag(3i), 3.0}, +} + +func main() { + // verify compile-time evaluated constant expressions + for _, test := range tests { + if test.got != test.want { + panic(fmt.Sprintf("%s: %v (%T) != %v (%T)", test.code, test.got, test.got, test.want, test.want)) + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue11987.go b/gcc/testsuite/go.test/test/fixedbugs/issue11987.go new file mode 100644 index 00000000000..9b665dc635e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue11987.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 11987. The ppc64 SRADCC instruction was misassembled in a way +// lost bit 5 of the immediate so v>>32 was assembled as v>>0. SRADCC +// is only ever inserted by peep so it's hard to be sure when it will +// be used. This formulation worked when the bug was fixed. + +package main + +import "fmt" + +var v int64 = 0x80000000 + +func main() { + s := fmt.Sprintf("%v", v>>32 == 0) + if s != "true" { + fmt.Printf("BUG: v>>32 == 0 evaluated as %q\n", s) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12006.go b/gcc/testsuite/go.test/test/fixedbugs/issue12006.go new file mode 100644 index 00000000000..0a2ef8dad04 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12006.go @@ -0,0 +1,174 @@ +// errorcheck -0 -m -l + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test escape analysis through ... parameters. + +package foo + +func FooN(vals ...*int) (s int) { // ERROR "vals does not escape" + for _, v := range vals { + s += *v + } + return s +} + +// Append forces heap allocation and copies entries in vals to heap, therefore they escape to heap. +func FooNx(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param content: vals" + vals = append(vals, x) + return FooN(vals...) +} + +var sink []*int + +func FooNy(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param: vals" + vals = append(vals, x) + sink = vals + return FooN(vals...) +} + +func FooNz(vals ...*int) (s int) { // ERROR "leaking param: vals" + sink = vals + return FooN(vals...) +} + +func TFooN() { + for i := 0; i < 1000; i++ { + var i, j int + FooN(&i, &j) // ERROR "... argument does not escape" + } +} + +func TFooNx() { + for i := 0; i < 1000; i++ { + var i, j, k int // ERROR "moved to heap: i" "moved to heap: j" "moved to heap: k" + FooNx(&k, &i, &j) // ERROR "... argument does not escape" + } +} + +func TFooNy() { + for i := 0; i < 1000; i++ { + var i, j, k int // ERROR "moved to heap: i" "moved to heap: j" "moved to heap: k" + FooNy(&k, &i, &j) // ERROR "... argument escapes to heap" + } +} + +func TFooNz() { + for i := 0; i < 1000; i++ { + var i, j int // ERROR "moved to heap: i" "moved to heap: j" + FooNz(&i, &j) // ERROR "... argument escapes to heap" + } +} + +var isink *int32 + +func FooI(args ...interface{}) { // ERROR "leaking param content: args" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + isink = x + case string: + println("is string") + } + } +} + +func TFooI() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + FooI(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape" +} + +func FooJ(args ...interface{}) *int32 { // ERROR "leaking param: args to result ~r1 level=1" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooJ1() { + a := int32(1) + b := "cat" + c := &a + FooJ(a, b, c) // ERROR "a does not escape" "b does not escape" "... argument does not escape" +} + +func TFooJ2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + isink = FooJ(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape" +} + +type fakeSlice struct { + l int + a *[4]interface{} +} + +func FooK(args fakeSlice) *int32 { // ERROR "leaking param: args to result ~r1 level=1" + for i := 0; i < args.l; i++ { + switch x := (*args.a)[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooK2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + fs := fakeSlice{3, &[4]interface{}{a, b, c, nil}} // ERROR "a escapes to heap" "b escapes to heap" "&\[4\]interface {}{...} does not escape" + isink = FooK(fs) +} + +func FooL(args []interface{}) *int32 { // ERROR "leaking param: args to result ~r1 level=1" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooL2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + s := []interface{}{a, b, c} // ERROR "a escapes to heap" "b escapes to heap" "\[\]interface {}{...} does not escape" + isink = FooL(s) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12108.go b/gcc/testsuite/go.test/test/fixedbugs/issue12108.go new file mode 100644 index 00000000000..c7a742513af --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12108.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// A generated method with a return value large enough to be +// initialized by duffzero is not a leaf method, which violated +// assumptions made by cmd/internal/obj/ppc64. + +package main + +const N = 9 // values > 8 cause (Super).Method to use duffzero + +type Base struct { +} + +func (b *Base) Method() (x [N]uintptr) { + return +} + +type Super struct { + Base +} + +type T interface { + Method() [N]uintptr +} + +func f(q T) { + q.Method() +} + +func main() { + var s Super + f(&s) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12133.go b/gcc/testsuite/go.test/test/fixedbugs/issue12133.go new file mode 100644 index 00000000000..bbf9fb0063f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12133.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 12133. The CX register was getting clobbered +// because we did not keep track of its allocation correctly. + +package main + +import "fmt" + +func main() { + want := uint(48) + got := f1(48) + if got != want { + fmt.Println("got", got, ", wanted", want) + panic("bad") + } +} + +//go:noinline +func f1(v1 uint) uint { + return v1 >> ((1 >> v1) + (1 >> v1)) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12226.go b/gcc/testsuite/go.test/test/fixedbugs/issue12226.go new file mode 100644 index 00000000000..22467116c19 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12226.go @@ -0,0 +1,15 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func main() { + if []byte("foo")[0] == []byte("b")[0] { + fmt.Println("BUG: \"foo\" and \"b\" appear to have the same first byte") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12347.go b/gcc/testsuite/go.test/test/fixedbugs/issue12347.go new file mode 100644 index 00000000000..fc5678e3ed7 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12347.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func f_ssa(x int, p *int) { + if false { + y := x + 5 + for { + *p = y + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12411.go b/gcc/testsuite/go.test/test/fixedbugs/issue12411.go new file mode 100644 index 00000000000..ff49314a6b5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12411.go @@ -0,0 +1,24 @@ +// +build !386 +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 12411. Loss of AX during %. + +package main + +func main() { + x := f(4) + if x != 0 { + println("BUG: x=", x) + } +} + +//go:noinline +func f(x int) int { + // AX was live on entry to one of the % code generations, + // and the % code generation smashed it. + return ((2 * x) % 3) % (2 % ((x << 2) ^ (x % 3))) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12413.go b/gcc/testsuite/go.test/test/fixedbugs/issue12413.go new file mode 100644 index 00000000000..a054765118b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12413.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 12413: invalid variable name x in type switch: code would fail +// to compile if the variable used in the short variable declaration was +// previously declared as a constant. + +package main + +func main() { + const x = 42 + switch x := interface{}(nil).(type) { + default: + _ = x + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12536.go b/gcc/testsuite/go.test/test/fixedbugs/issue12536.go new file mode 100644 index 00000000000..ceeaec4360e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12536.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2017 The Go 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 12536: compiler crashes while checking keys in a map literal for equality + +package p + +func main() { + m1 := map[interface{}]interface{}{ + nil: 0, + true: 1, + } + m2 := map[interface{}]interface{}{ + true: 1, + nil: 0, + } + println(len(m1)) + println(len(m2)) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12577.go b/gcc/testsuite/go.test/test/fixedbugs/issue12577.go new file mode 100644 index 00000000000..249b4f24325 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12577.go @@ -0,0 +1,66 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 12577: Test that there are no -0 floating-point constants. + +package main + +import "math" + +const ( + z0 = 0.0 + z1 = -0.0 + z2 = -z0 + z3 = -z2 +) + +var ( + x0 float32 = z0 + x1 float32 = z1 + x2 float32 = z2 + x3 float32 = z3 + + y0 float64 = z0 + y1 float64 = z1 + y2 float64 = z2 + y3 float64 = z3 +) + +func test32(f float32) { + if f != 0 || math.Signbit(float64(f)) { + println("BUG: got", f, "want 0.0") + return + } +} + +func test64(f float64) { + if f != 0 || math.Signbit(f) { + println("BUG: got", f, "want 0.0") + return + } +} + +func main() { + if f := -x0; f != 0 || !math.Signbit(float64(f)) { + println("BUG: got", f, "want -0.0") + } + + test32(-0.0) + test32(x0) + test32(x1) + test32(x2) + test32(x3) + + if f := -y0; f != 0 || !math.Signbit(f) { + println("BUG: got", f, "want -0.0") + } + + test64(-0.0) + test64(y0) + test64(y1) + test64(y2) + test64(y3) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12588.go b/gcc/testsuite/go.test/test/fixedbugs/issue12588.go new file mode 100644 index 00000000000..950ef36e206 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12588.go @@ -0,0 +1,88 @@ +// errorcheck -0 -m -l + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Tests escape analysis for range of arrays. +// Compiles but need not run. Inlining is disabled. + +package main + +type A struct { + b [3]uint64 +} + +type B struct { + b [3]*uint64 +} + +func f(a A) int { + for i, x := range &a.b { + if x != 0 { + return 64*i + int(x) + } + } + return 0 +} + +func g(a *A) int { // ERROR "a does not escape" + for i, x := range &a.b { + if x != 0 { + return 64*i + int(x) + } + } + return 0 +} + +func h(a *B) *uint64 { // ERROR "leaking param: a to result ~r1 level=1" + for i, x := range &a.b { + if i == 0 { + return x + } + } + return nil +} + +func h2(a *B) *uint64 { // ERROR "leaking param: a to result ~r1 level=1" + p := &a.b + for i, x := range p { + if i == 0 { + return x + } + } + return nil +} + +// Seems like below should be level=1, not 0. +func k(a B) *uint64 { // ERROR "leaking param: a to result ~r1 level=0" + for i, x := range &a.b { + if i == 0 { + return x + } + } + return nil +} + +var sink *uint64 + +func main() { + var a1, a2 A + var b1, b2, b3, b4 B + var x1, x2, x3, x4 uint64 // ERROR "moved to heap: x1" "moved to heap: x3" + b1.b[0] = &x1 + b2.b[0] = &x2 + b3.b[0] = &x3 + b4.b[0] = &x4 + f(a1) + g(&a2) + sink = h(&b1) + h(&b2) + sink = h2(&b1) + h2(&b4) + x1 = 17 + println("*sink=", *sink) // Verify that sink addresses x1 + x3 = 42 + sink = k(b3) + println("*sink=", *sink) // Verify that sink addresses x3 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/p.go b/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/p.go new file mode 100644 index 00000000000..e395071f8d5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/p.go @@ -0,0 +1,8 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p +func Baz(f int) float64 { + return 1 / float64(int(1)<<(uint(f))) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/q.go b/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/q.go new file mode 100644 index 00000000000..fd39c8a9ca6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12677.dir/q.go @@ -0,0 +1,7 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package q +import "./p" +func f() { println(p.Baz(2)) } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12677.go b/gcc/testsuite/go.test/test/fixedbugs/issue12677.go new file mode 100644 index 00000000000..6ad7161b2a5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12677.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 12677: Type loss during export/import of inlined function body. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue12686.go b/gcc/testsuite/go.test/test/fixedbugs/issue12686.go new file mode 100644 index 00000000000..bde42550148 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue12686.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// golang.org/issue/12686. +// interesting because it's a non-constant but ideal value +// and we used to incorrectly attach a constant Val to the Node. + +package p + +func f(i uint) uint { + x := []uint{1 << i} + return x[0] +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue1304.go b/gcc/testsuite/go.test/test/fixedbugs/issue1304.go new file mode 100644 index 00000000000..9e0ca5ae3f6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue1304.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +var a = 1 + +func main() { + defer func() { + recover() + if a != 2 { + println("BUG a =", a) + } + }() + a = 2 + b := a - a + c := 4 + a = c / b + a = 3 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13160.go b/gcc/testsuite/go.test/test/fixedbugs/issue13160.go new file mode 100644 index 00000000000..c21ecf671a2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13160.go @@ -0,0 +1,70 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "runtime" +) + +const N = 100000 + +func main() { + // Allocate more Ps than processors. This raises + // the chance that we get interrupted by the OS + // in exactly the right (wrong!) place. + p := runtime.NumCPU() + runtime.GOMAXPROCS(2 * p) + + // Allocate some pointers. + ptrs := make([]*int, p) + for i := 0; i < p; i++ { + ptrs[i] = new(int) + } + + // Arena where we read and write pointers like crazy. + collider := make([]*int, p) + + done := make(chan struct{}, 2*p) + + // Start writers. They alternately write a pointer + // and nil to a slot in the collider. + for i := 0; i < p; i++ { + i := i + go func() { + for j := 0; j < N; j++ { + // Write a pointer using memmove. + copy(collider[i:i+1], ptrs[i:i+1]) + // Write nil using memclr. + // (This is a magic loop that gets lowered to memclr.) + r := collider[i : i+1] + for k := range r { + r[k] = nil + } + } + done <- struct{}{} + }() + } + // Start readers. They read pointers from slots + // and make sure they are valid. + for i := 0; i < p; i++ { + i := i + go func() { + for j := 0; j < N; j++ { + var ptr [1]*int + copy(ptr[:], collider[i:i+1]) + if ptr[0] != nil && ptr[0] != ptrs[i] { + panic(fmt.Sprintf("bad pointer read %p!", ptr[0])) + } + } + done <- struct{}{} + }() + } + for i := 0; i < 2*p; i++ { + <-done + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13162.go b/gcc/testsuite/go.test/test/fixedbugs/issue13162.go new file mode 100644 index 00000000000..f8b3150c3ea --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13162.go @@ -0,0 +1,82 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Ensure that range loops over a string have the requisite side-effects. + +package main + +import ( + "fmt" + "os" +) + +func check(n int) { + var i int + var r rune + + b := make([]byte, n) + for i = range b { + b[i] = byte(i + 1) + } + s := string(b) + + // When n == 0, i is untouched by the range loop. + // Picking an initial value of -1 for i makes the + // "want" calculation below correct in all cases. + i = -1 + for i = range s { + b[i] = s[i] + } + if want := n - 1; i != want { + fmt.Printf("index after range with side-effect = %d want %d\n", i, want) + os.Exit(1) + } + + i = -1 + r = '\x00' + for i, r = range s { + b[i] = byte(r) + } + if want := n - 1; i != want { + fmt.Printf("index after range with side-effect = %d want %d\n", i, want) + os.Exit(1) + } + if want := rune(n); r != want { + fmt.Printf("rune after range with side-effect = %q want %q\n", r, want) + os.Exit(1) + } + + i = -1 + // i is shadowed here, so its value should be unchanged. + for i := range s { + b[i] = s[i] + } + if want := -1; i != want { + fmt.Printf("index after range without side-effect = %d want %d\n", i, want) + os.Exit(1) + } + + i = -1 + r = -1 + // i and r are shadowed here, so their values should be unchanged. + for i, r := range s { + b[i] = byte(r) + } + if want := -1; i != want { + fmt.Printf("index after range without side-effect = %d want %d\n", i, want) + os.Exit(1) + } + if want := rune(-1); r != want { + fmt.Printf("rune after range without side-effect = %q want %q\n", r, want) + os.Exit(1) + } +} + +func main() { + check(0) + check(1) + check(15) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13169.go b/gcc/testsuite/go.test/test/fixedbugs/issue13169.go new file mode 100644 index 00000000000..03c52e2951d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13169.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type T struct { + a, b, c int +} + +func usestack() { + usestack1(32) +} +func usestack1(d int) byte { + if d == 0 { + return 0 + } + var b [1024]byte + usestack1(d - 1) + return b[3] +} + +const n = 100000 + +func main() { + c := make(chan interface{}) + done := make(chan bool) + + for i := 0; i < 10; i++ { + go func() { + for j := 0; j < n; j++ { + c <- new(T) + } + done <- true + }() + go func() { + for j := 0; j < n; j++ { + _ = (<-c).(*T) + usestack() + } + done <- true + }() + } + for i := 0; i < 20; i++ { + <-done + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13171.go b/gcc/testsuite/go.test/test/fixedbugs/issue13171.go new file mode 100644 index 00000000000..addb872781a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13171.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// Make sure the compiler knows that DUFFCOPY clobbers X0 + +import "fmt" + +//go:noinline +func f(x float64) float64 { + // y is allocated to X0 + y := x + 5 + // marshals z before y. Marshaling z + // calls DUFFCOPY. + return g(z, y) +} + +//go:noinline +func g(b [64]byte, y float64) float64 { + return y +} + +var z [64]byte + +func main() { + got := f(5) + if got != 10 { + panic(fmt.Sprintf("want 10, got %f", got)) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13248.go b/gcc/testsuite/go.test/test/fixedbugs/issue13248.go new file mode 100644 index 00000000000..e23ba47b586 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13248.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This program caused an infinite loop with the recursive-descent parser. + +package main + +func main() { + foo( // GCCGO_ERROR "undefined name" +} // ERROR "unexpected }|expected operand|missing" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13261.go b/gcc/testsuite/go.test/test/fixedbugs/issue13261.go new file mode 100644 index 00000000000..a944f3a9b57 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13261.go @@ -0,0 +1,29 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Taking the address of a parenthesized composite literal is permitted. + +package main + +type T struct{} + +func main() { + _ = &T{} + _ = &(T{}) + _ = &((T{})) + + _ = &struct{}{} + _ = &(struct{}{}) + _ = &((struct{}{})) + + switch (&T{}) {} + switch &(T{}) {} + switch &((T{})) {} + + switch &struct{}{} {} + switch &(struct{}{}) {} + switch &((struct{}{})) {} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13262.go b/gcc/testsuite/go.test/test/fixedbugs/issue13262.go new file mode 100644 index 00000000000..8837c007989 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13262.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 13262: cmd/compile: bogus "fallthrough +// statement out of place" error + +package p + +func f() int { + var a int + switch a { + case 0: + return func() int { return 1 }() + fallthrough + default: + } + return 0 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13263.go b/gcc/testsuite/go.test/test/fixedbugs/issue13263.go new file mode 100644 index 00000000000..1933f2b5c5c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13263.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +var ( + x uint + y = x + z = uintptr(y) + a = uint32(y) + b = uint64(y) +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13266.go b/gcc/testsuite/go.test/test/fixedbugs/issue13266.go new file mode 100644 index 00000000000..73c9e16bcc2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13266.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Offending character % must not be interpreted as +// start of format verb when emitting error message. + +package% // ERROR "unexpected %|package name must be an identifier|after package clause|expected declaration" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13268.go b/gcc/testsuite/go.test/test/fixedbugs/issue13268.go new file mode 100644 index 00000000000..fcb69c90682 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13268.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test error message when EOF is encountered in the +// middle of a BOM. +// +// Since the error requires an EOF, we cannot use the +// errorcheckoutput mechanism. + +package main + +import ( + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) + +func main() { + // create source + f, err := ioutil.TempFile("", "issue13268-") + if err != nil { + log.Fatalf("could not create source file: %v", err) + } + f.Write([]byte("package p\n\nfunc \xef\xef")) // if this fails, we will die later + f.Close() + defer os.Remove(f.Name()) + + // compile and test output + cmd := exec.Command("go", "tool", "compile", f.Name()) + out, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("expected cmd/compile to fail") + } + if strings.HasPrefix(string(out), "illegal UTF-8 sequence") { + log.Fatalf("error %q not found", out) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13274.go b/gcc/testsuite/go.test/test/fixedbugs/issue13274.go new file mode 100644 index 00000000000..816bd9b8f27 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13274.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Check that we don't ignore EOF. + +package p + +var f = func() { // ERROR "unexpected EOF|expected .*}.*" \ No newline at end of file diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13337.go b/gcc/testsuite/go.test/test/fixedbugs/issue13337.go new file mode 100644 index 00000000000..81f984b7322 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13337.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 13337: The Go compiler limited how deeply embedded types +// were searched for promoted fields and methods. + +package s + +type S0 struct{ f int } +func (S0) m() {} + +type S1 struct{ S0 } +type S2 struct{ S1 } +type S3 struct{ S2 } +type S4 struct{ S3 } +type S5 struct{ S4 } +type S6 struct{ S5 } +type S7 struct{ S6 } +type S8 struct{ S7 } +type S9 struct{ S8 } +type S10 struct{ S9 } +type S11 struct{ S10 } +type S12 struct{ S11 } +type S13 struct{ S12 } + +var _ = S13{}.f +var _ = S13.m diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13365.go b/gcc/testsuite/go.test/test/fixedbugs/issue13365.go new file mode 100644 index 00000000000..31a663eb1f6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13365.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 13365: confusing error message (array vs slice) + +package main + +var t struct{} + +func main() { + _ = []int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative" + _ = [10]int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative" + _ = [...]int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative" + + _ = []int{100: 0} + _ = [10]int{100: 0} // ERROR "array index 100 out of bounds|out of range" + _ = [...]int{100: 0} + + _ = []int{t} // ERROR "cannot use .* as type int in slice literal|incompatible type" + _ = [10]int{t} // ERROR "cannot use .* as type int in array literal|incompatible type" + _ = [...]int{t} // ERROR "cannot use .* as type int in array literal|incompatible type" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13415.go b/gcc/testsuite/go.test/test/fixedbugs/issue13415.go new file mode 100644 index 00000000000..4c4655e5473 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13415.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that error message regarding := appears on +// correct line (and not on the line of the 2nd :=). + +package p + +func f() { + select { + case x, x := <-func() chan int { // ERROR "x repeated on left side of :=|redefinition|declared but not used" + c := make(chan int) + return c + }(): + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13471.go b/gcc/testsuite/go.test/test/fixedbugs/issue13471.go new file mode 100644 index 00000000000..9bfc8c3d2cf --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13471.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Tests for golang.org/issue/13471 + +package main + +func main() { + const _ int64 = 1e646456992 // ERROR "integer too large|floating-point constant truncated to integer" + const _ int32 = 1e64645699 // ERROR "integer too large|floating-point constant truncated to integer" + const _ int16 = 1e6464569 // ERROR "integer too large|floating-point constant truncated to integer" + const _ int8 = 1e646456 // ERROR "integer too large|floating-point constant truncated to integer" + const _ int = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer" + + const _ uint64 = 1e646456992 // ERROR "integer too large|floating-point constant truncated to integer" + const _ uint32 = 1e64645699 // ERROR "integer too large|floating-point constant truncated to integer" + const _ uint16 = 1e6464569 // ERROR "integer too large|floating-point constant truncated to integer" + const _ uint8 = 1e646456 // ERROR "integer too large|floating-point constant truncated to integer" + const _ uint = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer" + + const _ rune = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13480.go b/gcc/testsuite/go.test/test/fixedbugs/issue13480.go new file mode 100644 index 00000000000..cd2f05de5f6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13480.go @@ -0,0 +1,38 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that comparisons of slice/map/func values against converted nil +// values are properly rejected. + +package p + +func bug() { + type S []byte + type M map[int]int + type F func() + + var s S + var m M + var f F + + _ = s == S(nil) // ERROR "compare.*to nil" + _ = S(nil) == s // ERROR "compare.*to nil" + switch s { + case S(nil): // ERROR "compare.*to nil" + } + + _ = m == M(nil) // ERROR "compare.*to nil" + _ = M(nil) == m // ERROR "compare.*to nil" + switch m { + case M(nil): // ERROR "compare.*to nil" + } + + _ = f == F(nil) // ERROR "compare.*to nil" + _ = F(nil) == f // ERROR "compare.*to nil" + switch f { + case F(nil): // ERROR "compare.*to nil" + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13485.go b/gcc/testsuite/go.test/test/fixedbugs/issue13485.go new file mode 100644 index 00000000000..a9beea1f7df --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13485.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var ( + _ [10]int + _ [10.0]int + _ [float64(10)]int // ERROR "invalid array bound" + _ [10 + 0i]int + _ [complex(10, 0)]int + _ [complex128(complex(10, 0))]int // ERROR "invalid array bound" + _ ['a']int + _ [rune(65)]int +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13539.go b/gcc/testsuite/go.test/test/fixedbugs/issue13539.go new file mode 100644 index 00000000000..72c3ab0ae0e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13539.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that a label named like a package is recognized +// as a label rather than a package and that the package +// remains unused. + +package main + +import "math" // ERROR "imported and not used" + +func main() { +math: + for { + break math + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13684.go b/gcc/testsuite/go.test/test/fixedbugs/issue13684.go new file mode 100644 index 00000000000..a1d88566e40 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13684.go @@ -0,0 +1,17 @@ +// run + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that a label name matching a constant name +// is permitted. + +package main + +const labelname = 1 + +func main() { + goto labelname +labelname: +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/burnin.go b/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/burnin.go new file mode 100644 index 00000000000..512563975ed --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/burnin.go @@ -0,0 +1,19 @@ +package burnin + +type sendCmdFunc func(string) + +func sendCommand(c string) {} + +func NewSomething() { + // This works... + // var sendCmd sendCmdFunc + // sendCmd = sendCommand + + // So does this... + //sendCmd := sendCmdFunc(sendCommand) + + // This fails... + sendCmd := sendCommand + + _ = sendCmd +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/main.go new file mode 100644 index 00000000000..2512b93a81a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13777.dir/main.go @@ -0,0 +1,11 @@ +// build + +package main + +import ( + x "./burnin" +) + +func main() { + x.NewSomething() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13777.go b/gcc/testsuite/go.test/test/fixedbugs/issue13777.go new file mode 100644 index 00000000000..8f83c13ab99 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13777.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13799.go b/gcc/testsuite/go.test/test/fixedbugs/issue13799.go new file mode 100644 index 00000000000..fbdd4c32bc8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13799.go @@ -0,0 +1,190 @@ +// errorcheck -0 -m -l + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test, using compiler diagnostic flags, that the escape analysis is working. +// Compiles but does not run. Inlining is disabled. +// Registerization is disabled too (-N), which should +// have no effect on escape analysis. + +package main + +import "fmt" + +func main() { + // Just run test over and over again. This main func is just for + // convenience; if test were the main func, we could also trigger + // the panic just by running the program over and over again + // (sometimes it takes 1 time, sometimes it takes ~4,000+). + for iter := 0; ; iter++ { + if iter%50 == 0 { + fmt.Println(iter) // ERROR "iter escapes to heap$" "... argument does not escape$" + } + test1(iter) + test2(iter) + test3(iter) + test4(iter) + test5(iter) + test6(iter) + } +} + +func test1(iter int) { + + const maxI = 500 + m := make(map[int][]int) // ERROR "make\(map\[int\]\[\]int\) escapes to heap$" + + // The panic seems to be triggered when m is modified inside a + // closure that is both recursively called and reassigned to in a + // loop. + + // Cause of bug -- escape of closure failed to escape (shared) data structures + // of map. Assign to fn declared outside of loop triggers escape of closure. + // Heap -> stack pointer eventually causes badness when stack reallocation + // occurs. + + var fn func() // ERROR "moved to heap: fn$" + for i := 0; i < maxI; i++ { // ERROR "moved to heap: i$" + // var fn func() // this makes it work, because fn stays off heap + j := 0 // ERROR "moved to heap: j$" + fn = func() { // ERROR "func literal escapes to heap$" + m[i] = append(m[i], 0) + if j < 25 { + j++ + fn() + } + } + fn() + } + + if len(m) != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, len(m) = %d", iter, maxI, len(m))) // ERROR "iter escapes to heap$" "len\(m\) escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} + +func test2(iter int) { + + const maxI = 500 + m := make(map[int][]int) // ERROR "make\(map\[int\]\[\]int\) does not escape$" + + // var fn func() + for i := 0; i < maxI; i++ { + var fn func() // this makes it work, because fn stays off heap + j := 0 + fn = func() { // ERROR "func literal does not escape$" + m[i] = append(m[i], 0) + if j < 25 { + j++ + fn() + } + } + fn() + } + + if len(m) != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, len(m) = %d", iter, maxI, len(m))) // ERROR "iter escapes to heap$" "len\(m\) escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} + +func test3(iter int) { + + const maxI = 500 + var x int // ERROR "moved to heap: x$" + m := &x + + var fn func() // ERROR "moved to heap: fn$" + for i := 0; i < maxI; i++ { + // var fn func() // this makes it work, because fn stays off heap + j := 0 // ERROR "moved to heap: j$" + fn = func() { // ERROR "func literal escapes to heap$" + if j < 100 { + j++ + fn() + } else { + *m = *m + 1 + } + } + fn() + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} + +func test4(iter int) { + + const maxI = 500 + var x int + m := &x + + // var fn func() + for i := 0; i < maxI; i++ { + var fn func() // this makes it work, because fn stays off heap + j := 0 + fn = func() { // ERROR "func literal does not escape$" + if j < 100 { + j++ + fn() + } else { + *m = *m + 1 + } + } + fn() + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} + +type str struct { + m *int +} + +func recur1(j int, s *str) { // ERROR "s does not escape" + if j < 100 { + j++ + recur1(j, s) + } else { + *s.m++ + } +} + +func test5(iter int) { + + const maxI = 500 + var x int // ERROR "moved to heap: x$" + m := &x + + var fn *str + for i := 0; i < maxI; i++ { + // var fn *str // this makes it work, because fn stays off heap + fn = &str{m} // ERROR "&str{...} escapes to heap" + recur1(0, fn) + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} + +func test6(iter int) { + + const maxI = 500 + var x int + m := &x + + // var fn *str + for i := 0; i < maxI; i++ { + var fn *str // this makes it work, because fn stays off heap + fn = &str{m} // ERROR "&str{...} does not escape" + recur1(0, fn) + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "maxI escapes to heap$" "... argument does not escape$" + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13821.go b/gcc/testsuite/go.test/test/fixedbugs/issue13821.go new file mode 100644 index 00000000000..187e4b4cfb8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13821.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 13821. Compiler rejected "bool(true)" as not a constant. + +package p + +const ( + A = true + B = bool(A) + C = bool(true) +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue13821b.go b/gcc/testsuite/go.test/test/fixedbugs/issue13821b.go new file mode 100644 index 00000000000..df68e8d6264 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue13821b.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 13821. Additional regress tests. + +package p + +type B bool +type B2 bool + +var b B +var b2 B2 +var x1 = b && 1 < 2 // x1 has type B, not ideal bool +var x2 = 1 < 2 && b // x2 has type B, not ideal bool +var x3 = b && b2 // ERROR "mismatched types B and B2|incompatible types" +var x4 = x1 && b2 // ERROR "mismatched types B and B2|incompatible types" +var x5 = x2 && b2 // ERROR "mismatched types B and B2|incompatible types" +var x6 = b2 && x1 // ERROR "mismatched types B2 and B|incompatible types" +var x7 = b2 && x2 // ERROR "mismatched types B2 and B|incompatible types" + +var x8 = b && !B2(true) // ERROR "mismatched types B and B2|incompatible types" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14006.go b/gcc/testsuite/go.test/test/fixedbugs/issue14006.go new file mode 100644 index 00000000000..9cad2b4c9d1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14006.go @@ -0,0 +1,67 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Literals that happen to resolve to named constants +// may be used as label names (see issue 13684). Make +// sure that other literals don't crash the compiler. + +package main + +const labelname = 1 + +func main() { + goto labelname +labelname: +} + +func f() { + var x int + switch x { + case 1: + 2: // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case 2: + } + + switch x { + case 1: + 2: ; // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case 2: + } + + var y string + switch y { + case "foo": + "bar": // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case "bar": + } + + switch y { + case "foo": + "bar": ; // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case "bar": + } + + var z bool + switch { + case z: + labelname: // ERROR "missing statement after label" + case false: + } +} + +func g() { + var z bool + switch { + case z: + labelname: // ERROR "label labelname defined and not used|previous definition|defined and not used" + } + + switch { + case z: + labelname: ; // ERROR "label labelname already defined at LINE-5|label .*labelname.* already defined" + case false: + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14010.go b/gcc/testsuite/go.test/test/fixedbugs/issue14010.go new file mode 100644 index 00000000000..0b233342be5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14010.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that built-in types don't get printed with +// (empty) package qualification. + +package main + +func main() { + true = false // ERROR "cannot assign to true|invalid left hand side" + byte = 0 // ERROR "not an expression|invalid left hand side|invalid use of type" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14136.go b/gcc/testsuite/go.test/test/fixedbugs/issue14136.go new file mode 100644 index 00000000000..38308cd75c9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14136.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that > 10 non-syntax errors on the same line +// don't lead to early exit. Specifically, here test +// that we see the initialization error for variable +// s. + +package main + +type T struct{} + +func main() { + t := T{X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1} // ERROR "unknown field 'X' in struct literal of type T|unknown field .*X.* in .*T.*" + var s string = 1 // ERROR "cannot use 1|incompatible type" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/a.go new file mode 100644 index 00000000000..bf030516198 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/a.go @@ -0,0 +1,47 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +// F is an exported function, small enough to be inlined. +// It defines a local interface with an unexported method +// f, which will appear with a package-qualified method +// name in the export data. +func F(x interface{}) bool { + _, ok := x.(interface { + f() + }) + return ok +} + +// Like F but with the unexported interface method f +// defined via an embedded interface t. The compiler +// always flattens embedded interfaces so there should +// be no difference between F and G. Alas, currently +// G is not inlineable (at least via export data), so +// the issue is moot, here. +func G(x interface{}) bool { + type t0 interface { + f() + } + _, ok := x.(interface { + t0 + }) + return ok +} + +// Like G but now the embedded interface is declared +// at package level. This function is inlineable via +// export data. The export data representation is like +// for F. +func H(x interface{}) bool { + _, ok := x.(interface { + t1 + }) + return ok +} + +type t1 interface { + f() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/main.go new file mode 100644 index 00000000000..bcc6a63c207 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14164.dir/main.go @@ -0,0 +1,12 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// Verify that we can import package "a" containing an inlineable +// function F that declares a local interface with a non-exported +// method f. +import _ "./a" + +func main() {} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14164.go b/gcc/testsuite/go.test/test/fixedbugs/issue14164.go new file mode 100644 index 00000000000..5247599d497 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14164.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/a.go new file mode 100644 index 00000000000..f1e57ef5278 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/a.go @@ -0,0 +1,14 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +var S struct { + Str string `tag` +} + +func F() string { + v := S + return v.Str +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/b.go new file mode 100644 index 00000000000..a2280a36297 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14331.dir/b.go @@ -0,0 +1,11 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +func G() string { + return a.F() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14331.go b/gcc/testsuite/go.test/test/fixedbugs/issue14331.go new file mode 100644 index 00000000000..b8ee2fb14b7 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14331.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Inline function misses struct tags. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14405.go b/gcc/testsuite/go.test/test/fixedbugs/issue14405.go new file mode 100644 index 00000000000..94592fd18b8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14405.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Mention of field with large offset in struct literal causes crash +package p + +type T struct { + Slice [1 << 20][]int + Ptr *int +} + +func New(p *int) *T { + return &T{Ptr: p} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14520.go b/gcc/testsuite/go.test/test/fixedbugs/issue14520.go new file mode 100644 index 00000000000..0b840ff4bee --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14520.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package f + +import /* // ERROR "import path" */ ` +bogus` + +func f(x int /* // GC_ERROR "unexpected newline" + +*/) // GCCGO_ERROR "expected .*\).*|expected declaration" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14553.go b/gcc/testsuite/go.test/test/fixedbugs/issue14553.go new file mode 100644 index 00000000000..d7ebb1288eb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14553.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test checks if the compiler's internal constant +// arithmetic correctly rounds denormal float32 values. + +package main + +import ( + "fmt" + "math" +) + +func main() { + for _, t := range []struct { + value float32 + bits uint32 + }{ + {0e+00, 0x00000000}, + {1e-46, 0x00000000}, + {0.5e-45, 0x00000000}, + {0.8e-45, 0x00000001}, + {1e-45, 0x00000001}, + {2e-45, 0x00000001}, + {3e-45, 0x00000002}, + {4e-45, 0x00000003}, + {5e-45, 0x00000004}, + {6e-45, 0x00000004}, + {7e-45, 0x00000005}, + {8e-45, 0x00000006}, + {9e-45, 0x00000006}, + {1.0e-44, 0x00000007}, + {1.1e-44, 0x00000008}, + {1.2e-44, 0x00000009}, + } { + got := math.Float32bits(t.value) + want := t.bits + if got != want { + panic(fmt.Sprintf("bits(%g) = 0x%08x; want 0x%08x", t.value, got, want)) + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14591.go b/gcc/testsuite/go.test/test/fixedbugs/issue14591.go new file mode 100644 index 00000000000..626fbbcac48 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14591.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test to make sure we don't think values are dead +// when they are assigned to a PPARAMOUT slot before +// the last GC safepoint. + +package main + +import ( + "fmt" + "runtime" +) + +// When a T is deallocated, T[1] is certain to +// get clobbered (the runtime writes 0xdeaddeaddeaddead there). +type T [4]int + +func f() (r, s *T) { + r = &T{0x30, 0x31, 0x32, 0x33} + runtime.GC() + s = &T{0x40, 0x41, 0x42, 0x43} + runtime.GC() + return +} + +func main() { + r, s := f() + if r[1] != 0x31 { + fmt.Printf("bad r[1], want 0x31 got %x\n", r[1]) + } + if s[1] != 0x41 { + fmt.Printf("bad s[1], want 0x41 got %x\n", s[1]) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14636.go b/gcc/testsuite/go.test/test/fixedbugs/issue14636.go new file mode 100644 index 00000000000..6797046e02b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14636.go @@ -0,0 +1,43 @@ +// +build !nacl,!js,!android +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "log" + "os/exec" + "strings" +) + +func main() { + checkLinkOutput("", "-B argument must start with 0x") + checkLinkOutput("0", "-B argument must start with 0x") + checkLinkOutput("0x", "usage") + checkLinkOutput("0x0", "-B argument must have even number of digits") + checkLinkOutput("0x00", "usage") + checkLinkOutput("0xYZ", "-B argument contains invalid hex digit") + checkLinkOutput("0x"+strings.Repeat("00", 32), "usage") + checkLinkOutput("0x"+strings.Repeat("00", 33), "-B option too long (max 32 digits)") +} + +func checkLinkOutput(buildid string, message string) { + cmd := exec.Command("go", "tool", "link", "-B", buildid) + out, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("expected cmd/link to fail") + } + + firstLine := string(bytes.SplitN(out, []byte("\n"), 2)[0]) + if strings.HasPrefix(firstLine, "panic") { + log.Fatalf("cmd/link panicked:\n%s", out) + } + + if !strings.Contains(firstLine, message) { + log.Fatalf("cmd/link output did not include expected message %q: %s", message, firstLine) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14646.go b/gcc/testsuite/go.test/test/fixedbugs/issue14646.go new file mode 100644 index 00000000000..96a685464fa --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14646.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "runtime" + +func main() { + var file string + var line int + func() { + defer func() { + _, file, line, _ = runtime.Caller(1) + }() + }() // this is the expected line + const EXPECTED = 18 + if line != EXPECTED { + println("Expected line =", EXPECTED, "but got line =", line, "and file =", file) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14651.go b/gcc/testsuite/go.test/test/fixedbugs/issue14651.go new file mode 100644 index 00000000000..4c756e502e2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14651.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test checks if the compiler's internal constant +// arithmetic correctly rounds up floating-point values +// that become the smallest denormal value. +// +// See also related issue 14553 and test issue14553.go. + +package main + +import ( + "fmt" + "math" +) + +const ( + p149 = 1.0 / (1 << 149) // 1p-149 + p500 = 1.0 / (1 << 500) // 1p-500 + p1074 = p500 * p500 / (1<<74) // 1p-1074 +) + +const ( + m0000p149 = 0x0 / 16.0 * p149 // = 0.0000p-149 + m1000p149 = 0x8 / 16.0 * p149 // = 0.1000p-149 + m1001p149 = 0x9 / 16.0 * p149 // = 0.1001p-149 + m1011p149 = 0xb / 16.0 * p149 // = 0.1011p-149 + m1100p149 = 0xc / 16.0 * p149 // = 0.1100p-149 + + m0000p1074 = 0x0 / 16.0 * p1074 // = 0.0000p-1074 + m1000p1074 = 0x8 / 16.0 * p1074 // = 0.1000p-1074 + m1001p1074 = 0x9 / 16.0 * p1074 // = 0.1001p-1074 + m1011p1074 = 0xb / 16.0 * p1074 // = 0.1011p-1074 + m1100p1074 = 0xc / 16.0 * p1074 // = 0.1100p-1074 +) + +func main() { + test32(float32(m0000p149), f32(m0000p149)) + test32(float32(m1000p149), f32(m1000p149)) + test32(float32(m1001p149), f32(m1001p149)) + test32(float32(m1011p149), f32(m1011p149)) + test32(float32(m1100p149), f32(m1100p149)) + + test64(float64(m0000p1074), f64(m0000p1074)) + test64(float64(m1000p1074), f64(m1000p1074)) + test64(float64(m1001p1074), f64(m1001p1074)) + test64(float64(m1011p1074), f64(m1011p1074)) + test64(float64(m1100p1074), f64(m1100p1074)) +} + +func f32(x float64) float32 { return float32(x) } +func f64(x float64) float64 { return float64(x) } + +func test32(a, b float32) { + abits := math.Float32bits(a) + bbits := math.Float32bits(b) + if abits != bbits { + panic(fmt.Sprintf("%08x != %08x\n", abits, bbits)) + } +} + +func test64(a, b float64) { + abits := math.Float64bits(a) + bbits := math.Float64bits(b) + if abits != bbits { + panic(fmt.Sprintf("%016x != %016x\n", abits, bbits)) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14652.go b/gcc/testsuite/go.test/test/fixedbugs/issue14652.go new file mode 100644 index 00000000000..d53b4126683 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14652.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var x any // ERROR "undefined: any|undefined type .*any.*" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14725.go b/gcc/testsuite/go.test/test/fixedbugs/issue14725.go new file mode 100644 index 00000000000..49f3fbcf417 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14725.go @@ -0,0 +1,57 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func f1() (x int) { + for { + defer func() { + recover() + x = 1 + }() + panic(nil) + } +} + +var sink *int + +func f2() (x int) { + sink = &x + defer func() { + recover() + x = 1 + }() + panic(nil) +} + +func f3(b bool) (x int) { + sink = &x + defer func() { + recover() + x = 1 + }() + if b { + panic(nil) + } + return +} + +func main() { + if x := f1(); x != 1 { + panic(fmt.Sprintf("f1 returned %d, wanted 1", x)) + } + if x := f2(); x != 1 { + panic(fmt.Sprintf("f2 returned %d, wanted 1", x)) + } + if x := f3(true); x != 1 { + panic(fmt.Sprintf("f3(true) returned %d, wanted 1", x)) + } + if x := f3(false); x != 1 { + panic(fmt.Sprintf("f3(false) returned %d, wanted 1", x)) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14729.go b/gcc/testsuite/go.test/test/fixedbugs/issue14729.go new file mode 100644 index 00000000000..9b30fd27150 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14729.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 14729: structs cannot embed unsafe.Pointer per the spec. + +package main + +import "unsafe" + +type s struct { unsafe.Pointer } // ERROR "embedded type cannot be a pointer|embedded type may not be a pointer" +type s1 struct { p unsafe.Pointer } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue14988.go b/gcc/testsuite/go.test/test/fixedbugs/issue14988.go new file mode 100644 index 00000000000..4ddc7e728f9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue14988.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 14988: defining a map with an invalid forward declaration array +// key doesn't cause a fatal. + +package main + +type m map[k]int // ERROR "invalid map key type" +type k [1]m diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15013.go b/gcc/testsuite/go.test/test/fixedbugs/issue15013.go new file mode 100644 index 00000000000..9e218e6d810 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15013.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// CL 21202 introduced a compiler crash in the handling of a varargs +// function in the same recursive group as a function that calls it. +// Nothing in the standard library caught the problem, so adding a test. + +package p + +func F1(p *int, a ...*int) (int, *int) { + if p == nil { + return F2(), a[0] + } + return 0, a[0] +} + +func F2() int { + var i0, i1 int + a, _ := F1(&i0, &i1) + return a +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15039.go b/gcc/testsuite/go.test/test/fixedbugs/issue15039.go new file mode 100644 index 00000000000..85d9e8340aa --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15039.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func main() { + const fffd = "\uFFFD" + + // runtime.intstring used to convert int64 to rune without checking + // for truncation. + u := uint64(0x10001f4a9) + big := string(u) + if big != fffd { + panic("big != bad") + } + + // cmd/compile used to require integer constants to fit into an "int". + const huge = string(1<<100) + if huge != fffd { + panic("huge != bad") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15042.go b/gcc/testsuite/go.test/test/fixedbugs/issue15042.go new file mode 100644 index 00000000000..85d5d6c361a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15042.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Exchanging two struct fields was compiled incorrectly. + +package main + +type S struct { + i int +} + +func F(c bool, s1, s2 S) (int, int) { + if c { + s1.i, s2.i = s2.i, s1.i + } + return s1.i, s2.i +} + +func main() { + i, j := F(true, S{1}, S{20}) + if i != 20 || j != 1 { + panic(i+j) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/exp.go b/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/exp.go new file mode 100644 index 00000000000..e6041e602da --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/exp.go @@ -0,0 +1,24 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package exp + +func Exported(x int) int { + return inlined(x) +} + +func inlined(x int) int { + y := 0 + switch { + case x > 0: + y += 5 + return 0 + y + case x < 1: + y += 6 + fallthrough + default: + y += 7 + return 2 + y + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/main.go new file mode 100644 index 00000000000..96790dae83a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15071.dir/main.go @@ -0,0 +1,14 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "os" +import "./exp" + +func main() { + _ = exp.Exported(len(os.Args)) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15071.go b/gcc/testsuite/go.test/test/fixedbugs/issue15071.go new file mode 100644 index 00000000000..af6f1341729 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15071.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15084.go b/gcc/testsuite/go.test/test/fixedbugs/issue15084.go new file mode 100644 index 00000000000..7eb294e6a66 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15084.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package x + +type T struct { + i int + e interface{} +} + +func (t *T) F() bool { + if t.i != 0 { + return false + } + _, ok := t.e.(string) + return ok +} + +var x int + +func g(t *T) { + if t.F() || true { + if t.F() { + x = 0 + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15141.go b/gcc/testsuite/go.test/test/fixedbugs/issue15141.go new file mode 100644 index 00000000000..752f530273c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15141.go @@ -0,0 +1,33 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func main() { + a := f(1, 99) + b := g(0xFFFFFFe, 98) + c := h(0xFFFFFFe, 98) + println(a[1], b[1], c[1], a[0xFFFFFFe], b[0xFFFFFFe], c[0xFFFFFFe]) +} + +//go:noinline +func f(i, y int) (a [0xFFFFFFF]byte) { + a[i] = byte(y) + return +} + +//go:noinline +func g(i, y int) [0xFFFFFFF]byte { + var a [0xFFFFFFF]byte + a[i] = byte(y) + return a +} + +//go:noinline +func h(i, y int) (a [0xFFFFFFF]byte) { + a[i] = byte(y) + return a +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15175.go b/gcc/testsuite/go.test/test/fixedbugs/issue15175.go new file mode 100644 index 00000000000..55a8f7d65ab --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15175.go @@ -0,0 +1,66 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Make sure unsigned shift results get sign-extended correctly. +package main + +import "fmt" + +func main() { + failed := false + a6 := uint8(253) + if got := a6 >> 0; got != 253 { + fmt.Printf("uint8(253)>>0 = %v, wanted 253\n", got) + failed = true + } + if got := f1(0, 2, 1, 0, 0, 1, true); got != 255 { + fmt.Printf("f1(...) = %v, wanted 255\n", got) + failed = true + } + if got := f2(1); got != 242 { + fmt.Printf("f2(...) = %v, wanted 242\n", got) + failed = true + } + if got := f3(false, 0, 0); got != 254 { + fmt.Printf("f3(...) = %v, wanted 254\n", got) + failed = true + } + if failed { + panic("bad") + } +} + +func f1(a1 uint, a2 int8, a3 int8, a4 int8, a5 uint8, a6 int, a7 bool) uint8 { + a5-- + a4 += (a2 << a1 << 2) | (a4 ^ a4<<(a1&a1)) - a3 // int8 + a6 -= a6 >> (2 + uint32(a2)>>3) // int + a1 += a1 // uint + a3 *= a4 << (a1 | a1) << (uint16(3) >> 2 & (1 - 0) & (uint16(1) << a5 << 3)) // int8 + a7 = a7 || ((a2 == a4) || (a7 && a7) || ((a5 == a5) || (a7 || a7))) // bool + return a5 >> a1 +} + +func f2(a1 uint8) uint8 { + a1-- + a1-- + a1 -= a1 + (a1 << 1) - (a1*a1*a1)<<(2-0+(3|3)-1) // uint8 + v1 := 0 * ((2 * 1) ^ 1) & ((uint(0) >> a1) + (2+0)*(uint(2)+0)) // uint + _ = v1 + return a1 >> (((2 ^ 2) >> (v1 | 2)) + 0) +} + +func f3(a1 bool, a2 uint, a3 int64) uint8 { + a3-- + v1 := 1 & (2 & 1 * (1 ^ 2) & (uint8(3*1) >> 0)) // uint8 + _ = v1 + v1 += v1 - (v1 >> a2) + (v1 << (a2 ^ a2) & v1) // uint8 + v1 *= v1 // uint8 + a3-- + v1 += v1 & v1 // uint8 + v1-- + v1 = ((v1 << 0) | v1>>0) + v1 // uint8 + return v1 >> 0 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15252.go b/gcc/testsuite/go.test/test/fixedbugs/issue15252.go new file mode 100644 index 00000000000..370a885c7f5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15252.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test makes sure that we use all 64 bits of an +// index, even on 32 bit machines. It also tests that nacl +// can compile 64 bit indexes loaded from ODOTPTR properly. + +package main + +type T struct { + i int64 +} + +func f(t *T) byte { + b := [2]byte{3, 4} + return b[t.i] +} + +func main() { + t := &T{0x100000001} + defer func() { + r := recover() + if r == nil { + panic("panic wasn't recoverable") + } + }() + f(t) + panic("index didn't panic") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15277.go b/gcc/testsuite/go.test/test/fixedbugs/issue15277.go new file mode 100644 index 00000000000..af165f7a6b2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15277.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// +build amd64 + +package main + +import "runtime" + +type big [10 << 20]byte + +func f(x *big, start int64) { + if delta := inuse() - start; delta < 9<<20 { + println("after alloc: expected delta at least 9MB, got: ", delta) + } + runtime.KeepAlive(x) + x = nil + if delta := inuse() - start; delta > 1<<20 { + println("after drop: expected delta below 1MB, got: ", delta) + } + x = new(big) + if delta := inuse() - start; delta < 9<<20 { + println("second alloc: expected delta at least 9MB, got: ", delta) + } + runtime.KeepAlive(x) +} + +func main() { + x := inuse() + f(new(big), x) +} + +func inuse() int64 { + runtime.GC() + var st runtime.MemStats + runtime.ReadMemStats(&st) + return int64(st.Alloc) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15303.go b/gcc/testsuite/go.test/test/fixedbugs/issue15303.go new file mode 100644 index 00000000000..c8dfa30dfbf --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15303.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Ensure that inlined struct/array comparisons have the right side-effects. + +package main + +import "os" + +func main() { + var x int + f := func() (r [4]int) { + x++ + return + } + _ = f() == f() + if x != 2 { + println("f evaluated ", x, " times, want 2") + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15329.go b/gcc/testsuite/go.test/test/fixedbugs/issue15329.go new file mode 100644 index 00000000000..30fbf137970 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15329.go @@ -0,0 +1,79 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Previously, cmd/compile would rewrite +// +// check(unsafe.Pointer(testMeth(1).Pointer()), unsafe.Pointer(testMeth(2).Pointer())) +// +// to +// +// var autotmp_1 uintptr = testMeth(1).Pointer() +// var autotmp_2 uintptr = testMeth(2).Pointer() +// check(unsafe.Pointer(autotmp_1), unsafe.Pointer(autotmp_2)) +// +// However, that means autotmp_1 is the only reference to the int +// variable containing the value "1", but it's not a pointer type, +// so it was at risk of being garbage collected by the evaluation of +// testMeth(2).Pointer(), even though package unsafe's documentation +// says the original code was allowed. +// +// Now cmd/compile rewrites it to +// +// var autotmp_1 unsafe.Pointer = unsafe.Pointer(testMeth(1).Pointer()) +// var autotmp_2 unsafe.Pointer = unsafe.Pointer(testMeth(2).Pointer()) +// check(autotmp_1, autotmp_2) +// +// to ensure the pointed-to variables are visible to the GC. + +package main + +import ( + "fmt" + "reflect" + "runtime" + "unsafe" +) + +func main() { + // Test all the different ways we can invoke reflect.Value.Pointer. + + // Direct method invocation. + check(unsafe.Pointer(testMeth(1).Pointer()), unsafe.Pointer(testMeth(2).Pointer())) + + // Invocation via method expression. + check(unsafe.Pointer(reflect.Value.Pointer(testMeth(1))), unsafe.Pointer(reflect.Value.Pointer(testMeth(2)))) + + // Invocation via interface. + check(unsafe.Pointer(testInter(1).Pointer()), unsafe.Pointer(testInter(2).Pointer())) + + // Invocation via method value. + check(unsafe.Pointer(testFunc(1)()), unsafe.Pointer(testFunc(2)())) +} + +func check(p, q unsafe.Pointer) { + a, b := *(*int)(p), *(*int)(q) + if a != 1 || b != 2 { + fmt.Printf("got %v, %v; expected 1, 2\n", a, b) + } +} + +func testMeth(x int) reflect.Value { + // Force GC to run. + runtime.GC() + return reflect.ValueOf(&x) +} + +type Pointerer interface { + Pointer() uintptr +} + +func testInter(x int) Pointerer { + return testMeth(x) +} + +func testFunc(x int) func() uintptr { + return testMeth(x).Pointer +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15439.go b/gcc/testsuite/go.test/test/fixedbugs/issue15439.go new file mode 100644 index 00000000000..840a3c02a8b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15439.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "reflect" + +func main() { + a := &struct{ x int }{} + b := &struct{ x int "" }{} + + ta := reflect.TypeOf(a) + tb := reflect.TypeOf(b) + + // Ensure cmd/compile treats absent and empty tags as equivalent. + a = b + + // Ensure package reflect treats absent and empty tags as equivalent. + if !tb.AssignableTo(ta) { + panic("fail") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/a.go new file mode 100644 index 00000000000..1fcf3ea6e01 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/a.go @@ -0,0 +1,24 @@ +package a + +import "io" + +type T interface { + M0(_ int) + M1(x, _ int) // _ (blank) caused crash + M2() (x, _ int) +} + +type S struct{} + +func (S) M0(_ int) {} +func (S) M1(x, _ int) {} +func (S) M2() (x, _ int) { return } +func (_ S) M3() {} + +// Snippet from x/tools/godoc/analysis/analysis.go. +// Offending code from #5470. +type Link interface { + Start() int + End() int + Write(w io.Writer, _ int, start bool) // _ (blank) caused crash +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/b.go new file mode 100644 index 00000000000..863ee9f5221 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15470.dir/b.go @@ -0,0 +1,3 @@ +package b + +import _ "./a" // must not fail diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15470.go b/gcc/testsuite/go.test/test/fixedbugs/issue15470.go new file mode 100644 index 00000000000..22b48fe2573 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15470.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 15470: Make sure special-case signatures can +// be exported and imported w/o problems. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/a.go new file mode 100644 index 00000000000..663303b863f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/a.go @@ -0,0 +1,7 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type A struct{ _ int32 } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/b.go new file mode 100644 index 00000000000..f0750d3a443 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/b.go @@ -0,0 +1,7 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +func B() (_ struct{ _ int32 }) { return } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/c.go b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/c.go new file mode 100644 index 00000000000..dc2ef5bed52 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15514.dir/c.go @@ -0,0 +1,10 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package c + +import "./a" +import "./b" + +var _ a.A = b.B() // ERROR "cannot use b\.B|incompatible type" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15514.go b/gcc/testsuite/go.test/test/fixedbugs/issue15514.go new file mode 100644 index 00000000000..626f7ad699e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15514.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15528.go b/gcc/testsuite/go.test/test/fixedbugs/issue15528.go new file mode 100644 index 00000000000..b1f9dfbb5cc --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15528.go @@ -0,0 +1,131 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "io" + "os" + "reflect" + "unsafe" +) + +type RWS struct{} + +func (x *RWS) Read(p []byte) (n int, err error) { return } +func (x *RWS) Write(p []byte) (n int, err error) { return } +func (x *RWS) Seek(offset int64, whence int) (n int64, err error) { return } +func (x *RWS) String() string { return "rws" } + +func makeRWS() io.ReadWriteSeeker { return &RWS{} } +func makeStringer() fmt.Stringer { return &RWS{} } + +// Test correct construction of static empty interface values +var efaces = [...]struct { + x interface{} + s string +}{ + {nil, " "}, + {1, "int 1"}, + {int(1), "int 1"}, + {Int(int(2)), "main.Int Int=2"}, + {int(Int(3)), "int 3"}, + {[1]int{2}, "[1]int [2]"}, + {io.Reader(io.ReadWriter(io.ReadWriteSeeker(nil))), " "}, + {io.Reader(io.ReadWriter(io.ReadWriteSeeker(&RWS{}))), "*main.RWS rws"}, + {makeRWS(), "*main.RWS rws"}, + {map[string]string{"here": "there"}, "map[string]string map[here:there]"}, + {chan bool(nil), "chan bool "}, + {unsafe.Pointer(uintptr(0)), "unsafe.Pointer "}, + {(*byte)(nil), "*uint8 "}, + {io.Writer((*os.File)(nil)), "*os.File "}, + {(interface{})(io.Writer((*os.File)(nil))), "*os.File "}, + {fmt.Stringer(Strunger(((*Int)(nil)))), "*main.Int "}, +} + +type Int int + +func (i Int) String() string { return fmt.Sprintf("Int=%d", i) } +func (i Int) Strung() {} + +type Strunger interface { + fmt.Stringer + Strung() +} + +// Test correct construction of static non-empty interface values +var ifaces = [...]struct { + x fmt.Stringer + s string +}{ + {nil, " %!s()"}, + {Int(3), "main.Int 3 Int=3"}, + {Int(int(Int(4))), "main.Int 4 Int=4"}, + {Strunger(Int(5)), "main.Int 5 Int=5"}, + {makeStringer(), "*main.RWS &main.RWS{} rws"}, + {fmt.Stringer(nil), " %!s()"}, + {(*RWS)(nil), "*main.RWS (*main.RWS)(nil) rws"}, +} + +// Test correct handling of direct interface values +var ( + one int = 1 + iptr interface{} = &one + clos int + f interface{} = func() { clos++ } + deep interface{} = [1]struct{ a *[2]byte }{{a: &[2]byte{'z', 'w'}}} + ch interface{} = make(chan bool, 1) +) + +func main() { + var fail bool + for i, test := range efaces { + s := fmt.Sprintf("%[1]T %[1]v", test.x) + if s != test.s { + fmt.Printf("eface(%d)=%q want %q\n", i, s, test.s) + fail = true + } + } + + for i, test := range ifaces { + s := fmt.Sprintf("%[1]T %#[1]v %[1]s", test.x) + if s != test.s { + fmt.Printf("iface(%d)=%q want %q\n", i, s, test.s) + fail = true + } + } + + if got := *(iptr.(*int)); got != 1 { + fmt.Printf("bad int ptr %d\n", got) + fail = true + } + + f.(func())() + f.(func())() + f.(func())() + if clos != 3 { + fmt.Printf("bad closure exec %d\n", clos) + fail = true + } + + if !reflect.DeepEqual(*(deep.([1]struct{ a *[2]byte })[0].a), [2]byte{'z', 'w'}) { + fmt.Printf("bad deep directiface\n") + fail = true + } + + cc := ch.(chan bool) + cc <- true + if got := <-cc; !got { + fmt.Printf("bad chan\n") + fail = true + } + + if fail { + fmt.Println("BUG") + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/a.go new file mode 100644 index 00000000000..3c593fc0f6a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/a.go @@ -0,0 +1,17 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type I0 interface { + I1 +} + +type T struct { + I1 +} + +type I1 interface { + M(*T) // removing * makes crash go away +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/b.go new file mode 100644 index 00000000000..b46f5adfddb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/b.go @@ -0,0 +1,9 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +var X a.T diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/c.go b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/c.go new file mode 100644 index 00000000000..6d3f3be53ec --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15548.dir/c.go @@ -0,0 +1,10 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package c + +import ( + _ "./b" + _ "./a" +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15548.go b/gcc/testsuite/go.test/test/fixedbugs/issue15548.go new file mode 100644 index 00000000000..4d2844dbb93 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15548.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15550.go b/gcc/testsuite/go.test/test/fixedbugs/issue15550.go new file mode 100644 index 00000000000..f2853fc48b5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15550.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "unsafe" + +const ( + _ = unsafe.Sizeof(func() int { + const ( + _ = 1 + _ + _ + ) + return 0 + }()) + + y = iota +) + +func main() { + if y != 1 { + panic(y) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/a.go new file mode 100644 index 00000000000..13566014304 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/a.go @@ -0,0 +1,40 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type T struct { +} + +func F() []T { + return []T{T{}} +} + +func Fi() []T { + return []T{{}} // element with implicit composite literal type +} + +func Fp() []*T { + return []*T{&T{}} +} + +func Fip() []*T { + return []*T{{}} // element with implicit composite literal type +} + +func Gp() map[int]*T { + return map[int]*T{0: &T{}} +} + +func Gip() map[int]*T { + return map[int]*T{0: {}} // element with implicit composite literal type +} + +func Hp() map[*T]int { + return map[*T]int{&T{}: 0} +} + +func Hip() map[*T]int { + return map[*T]int{{}: 0} // key with implicit composite literal type +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/b.go new file mode 100644 index 00000000000..355accc8805 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15572.dir/b.go @@ -0,0 +1,27 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +func F() { + a.F() + a.Fi() +} + +func Fp() { + a.Fp() + a.Fip() +} + +func Gp() { + a.Gp() + a.Gip() +} + +func Hp() { + a.Hp() + a.Hip() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15572.go b/gcc/testsuite/go.test/test/fixedbugs/issue15572.go new file mode 100644 index 00000000000..cf77778f664 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15572.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that exporting composite literals with implicit +// types doesn't crash the typechecker when running over +// inlined function bodies containing such literals. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15585.go b/gcc/testsuite/go.test/test/fixedbugs/issue15585.go new file mode 100644 index 00000000000..79eb13f90db --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15585.go @@ -0,0 +1,45 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bug + +func example(n int) (rc int) { + var cc, ll, pp, rr [27]int + for q0 := 0; q0 < n-2; q0++ { + for q1 := q0 + 2; q1 < n; q1++ { + var c, d, l, p, r int + b0 := 1 << uint(q0) + b1 := 1 << uint(q1) + l = ((b0 << 1) | b1) << 1 + c = b0 | b1 | (-1 << uint(n)) + r = ((b0 >> 1) | b1) >> 1 + E: + if c != -1 { + p = ^(l | c | r) + } else { + rc++ + goto R + } + L: + if p != 0 { + lsb := p & -p + p &^= lsb + ll[d], cc[d], rr[d], pp[d] = l, c, r, p + l, c, r = (l|lsb)<<1, c|lsb, (r|lsb)>>1 + d++ + goto E + } + R: + d-- + if d >= 0 { + l, c, r, p = ll[d], cc[d], rr[d], pp[d] + goto L + } + } + } + rc <<= 1 + return +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15602.go b/gcc/testsuite/go.test/test/fixedbugs/issue15602.go new file mode 100644 index 00000000000..badf8133c52 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15602.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func f(i interface{}) { + i, _ = i.(error) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15604.go b/gcc/testsuite/go.test/test/fixedbugs/issue15604.go new file mode 100644 index 00000000000..4dc0b0b0541 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15604.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bug + +import "os" + +func f(err error) { + var ok bool + if err, ok = err.(*os.PathError); ok { + if err == os.ErrNotExist { + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call.go b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call.go new file mode 100644 index 00000000000..41a489cebd4 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call.go @@ -0,0 +1,7 @@ +// +build !amd64,!386 + +package main + +func jump() { + target() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_386.s b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_386.s new file mode 100644 index 00000000000..751084c485b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_386.s @@ -0,0 +1,8 @@ +#include "textflag.h" + +DATA ·pointer(SB)/4, $·target(SB) +GLOBL ·pointer(SB),RODATA,$4 + +TEXT ·jump(SB),NOSPLIT,$4 + CALL *·pointer(SB) + RET diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_amd64.s b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_amd64.s new file mode 100644 index 00000000000..09fbe5dfc4a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_amd64.s @@ -0,0 +1,8 @@ +#include "textflag.h" + +DATA ·pointer(SB)/8, $·target(SB) +GLOBL ·pointer(SB),RODATA,$8 + +TEXT ·jump(SB),NOSPLIT,$8 + CALL *·pointer(SB) + RET diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_decl.go b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_decl.go new file mode 100644 index 00000000000..d9c5a4e9f0f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/call_decl.go @@ -0,0 +1,5 @@ +// +build amd64 386 + +package main + +func jump() diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/main.go new file mode 100644 index 00000000000..4855e31e5ed --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15609.dir/main.go @@ -0,0 +1,14 @@ +package main + +var called bool + +func target() { + called = true +} + +func main() { + jump() + if !called { + panic("target not called") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/a.go new file mode 100644 index 00000000000..842f19685fd --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/a.go @@ -0,0 +1,23 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type T struct{} + +func (T) m() string { + return "m" +} + +func (*T) mp() string { + return "mp" +} + +func F() func(T) string { + return T.m // method expression +} + +func Fp() func(*T) string { + return (*T).mp // method expression +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/b.go new file mode 100644 index 00000000000..3d011ba3019 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15646.dir/b.go @@ -0,0 +1,16 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./a" // import must succeed + +func main() { + if a.F()(a.T{}) != "m" { + panic(0) + } + if a.Fp()(nil) != "mp" { + panic(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15646.go b/gcc/testsuite/go.test/test/fixedbugs/issue15646.go new file mode 100644 index 00000000000..cd4ba9d4e52 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15646.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that method expressions are correctly encoded +// in binary export data and can be imported again. +package ignore \ No newline at end of file diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15722.go b/gcc/testsuite/go.test/test/fixedbugs/issue15722.go new file mode 100644 index 00000000000..dec54587f6b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15722.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Checks to make sure that the compiler can catch a specific invalid +// method type expression. NB: gccgo and gc have slightly different +// error messages, hence the generic test for 'method' and not something +// more specific. + +package issue15722 + +type T int +type P *T + +func (T) t() {} + +func _(p P) { + P.t(p) // ERROR "method" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15733.go b/gcc/testsuite/go.test/test/fixedbugs/issue15733.go new file mode 100644 index 00000000000..8f609e634dd --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15733.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type S struct { + a [1 << 16]byte +} + +func f1() { + p := &S{} + _ = p +} + +type T [1 << 16]byte + +func f2() { + p := &T{} + _ = p +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/a.go new file mode 100644 index 00000000000..15b7f1dcfa8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/a.go @@ -0,0 +1,61 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +func F1() { +L: + goto L +} + +func F2() { +L: + for { + break L + } +} + +func F3() { +L: + for { + continue L + } +} + +func F4() { + switch { + case true: + fallthrough + default: + } +} + +type T struct{} + +func (T) M1() { +L: + goto L +} + +func (T) M2() { +L: + for { + break L + } +} + +func (T) M3() { +L: + for { + continue L + } +} + +func (T) M4() { + switch { + case true: + fallthrough + default: + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/b.go new file mode 100644 index 00000000000..9fd6efc33c9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15838.dir/b.go @@ -0,0 +1,9 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +type T struct{ a.T } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15838.go b/gcc/testsuite/go.test/test/fixedbugs/issue15838.go new file mode 100644 index 00000000000..fb1c64d1ac1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15838.go @@ -0,0 +1,12 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test cases for issue #15838, and related failures. +// Make sure the importer correctly sets up nodes for +// label decls, goto, continue, break, and fallthrough +// statements. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15895.go b/gcc/testsuite/go.test/test/fixedbugs/issue15895.go new file mode 100644 index 00000000000..3ef295c03ea --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15895.go @@ -0,0 +1,27 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// func bad used to fail to compile. + +package p + +type A [1]int + +func bad(x A) { + switch x { + case A([1]int{1}): + case A([1]int{1}): + } +} + +func good(x A) { + y := A([1]int{1}) + z := A([1]int{1}) + switch x { + case y: + case z: + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15898.go b/gcc/testsuite/go.test/test/fixedbugs/issue15898.go new file mode 100644 index 00000000000..94369f93450 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15898.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func f(e interface{}) { + switch e.(type) { + case nil, nil: // ERROR "multiple nil cases in type switch|duplicate type in switch" + } + + switch e.(type) { + case nil: + case nil: // ERROR "multiple nil cases in type switch|duplicate type in switch" + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15902.go b/gcc/testsuite/go.test/test/fixedbugs/issue15902.go new file mode 100644 index 00000000000..9511a220edb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15902.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test makes sure we don't use 4-byte unaligned writes +// to zero memory on architectures that don't support them. + +package main + +type T struct { + a byte + b [10]byte +} + +//go:noinline +func f(t *T) { + // t will be aligned, so &t.b won't be. + t.b = [10]byte{} +} + +var t T + +func main() { + f(&t) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/a.go new file mode 100644 index 00000000000..15f92355f73 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/a.go @@ -0,0 +1,9 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type Error error + +func F() Error { return nil } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/b.go new file mode 100644 index 00000000000..0a36c5c6ab8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15920.dir/b.go @@ -0,0 +1,7 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import _ "./a" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15920.go b/gcc/testsuite/go.test/test/fixedbugs/issue15920.go new file mode 100644 index 00000000000..4d2844dbb93 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15920.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15926.go b/gcc/testsuite/go.test/test/fixedbugs/issue15926.go new file mode 100644 index 00000000000..76e25eb640a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15926.go @@ -0,0 +1,20 @@ +// build + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 15926: linker was adding .def to the end of symbols, causing +// a name collision with a method actually named def. + +package main + +type S struct{} + +func (s S) def() {} + +var I = S.def + +func main() { + I(S{}) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15961.go b/gcc/testsuite/go.test/test/fixedbugs/issue15961.go new file mode 100644 index 00000000000..db3d6623780 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15961.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package y + +type symSet []int + +//go:noinline +func (s symSet) len() (r int) { + return 0 +} + +func f(m map[int]symSet) { + var symSet []int + for _, x := range symSet { + m[x] = nil + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15988.go b/gcc/testsuite/go.test/test/fixedbugs/issue15988.go new file mode 100644 index 00000000000..2bed2a9c305 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15988.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func f(p, q []int) { + p = append(q, 5) + sink = &p +} + +var sink *[]int diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15992.go b/gcc/testsuite/go.test/test/fixedbugs/issue15992.go new file mode 100644 index 00000000000..cda5527c67e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15992.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" +) + +func f(a []byte) ([]byte, []byte) { + return a, []byte("abc") +} + +func g(a []byte) ([]byte, string) { + return a, "abc" +} + +func h(m map[int]int) (map[int]int, int) { + return m, 0 +} + +func main() { + a := []byte{1, 2, 3} + n := copy(f(a)) + fmt.Println(n, a) + + b := []byte{1, 2, 3} + n = copy(g(b)) + fmt.Println(n, b) + + m := map[int]int{0: 0} + fmt.Println(len(m)) + delete(h(m)) + fmt.Println(len(m)) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue15992.out b/gcc/testsuite/go.test/test/fixedbugs/issue15992.out new file mode 100644 index 00000000000..e0011e3edb9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue15992.out @@ -0,0 +1,4 @@ +3 [97 98 99] +3 [97 98 99] +1 +0 diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16016.go b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go new file mode 100644 index 00000000000..e738e1dba0e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16016.go @@ -0,0 +1,35 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "time" + +type T struct{} + +func (*T) Foo(vals []interface{}) { + switch v := vals[0].(type) { + case string: + _ = v + } +} + +type R struct{ *T } + +type Q interface { + Foo([]interface{}) +} + +func main() { + var q Q = &R{&T{}} + for i := 0; i < 10000; i++ { + go func() { + defer q.Foo([]interface{}{"meow"}) + time.Sleep(100 * time.Millisecond) + }() + } + time.Sleep(1 * time.Second) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16037_run.go b/gcc/testsuite/go.test/test/fixedbugs/issue16037_run.go new file mode 100644 index 00000000000..d05e3f7f314 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16037_run.go @@ -0,0 +1,70 @@ +// +build !nacl,!js,!android +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "fmt" + "html/template" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" +) + +var tmpl = template.Must(template.New("main").Parse(` +package main + +type T struct { + {{range .Names}} + {{.Name}} *string + {{end}} +} + +{{range .Names}} +func (t *T) Get{{.Name}}() string { + if t.{{.Name}} == nil { + return "" + } + return *t.{{.Name}} +} +{{end}} + +func main() {} +`)) + +func main() { + const n = 5000 + + type Name struct{ Name string } + var t struct{ Names []Name } + for i := 0; i < n; i++ { + t.Names = append(t.Names, Name{Name: fmt.Sprintf("H%06X", i)}) + } + + buf := new(bytes.Buffer) + if err := tmpl.Execute(buf, t); err != nil { + log.Fatal(err) + } + + dir, err := ioutil.TempDir("", "issue16037-") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + path := filepath.Join(dir, "ridiculous_number_of_fields.go") + if err := ioutil.WriteFile(path, buf.Bytes(), 0664); err != nil { + log.Fatal(err) + } + + out, err := exec.Command("go", "build", "-o="+filepath.Join(dir, "out"), path).CombinedOutput() + if err != nil { + log.Fatalf("build failed: %v\n%s", err, out) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16095.go b/gcc/testsuite/go.test/test/fixedbugs/issue16095.go new file mode 100644 index 00000000000..864b4b7c7cf --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16095.go @@ -0,0 +1,104 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "runtime" +) + +var sink *[20]byte + +func f() (x [20]byte) { + // Initialize x. + for i := range x { + x[i] = byte(i) + } + + // Force x to be allocated on the heap. + sink = &x + sink = nil + + // Go to deferreturn after the panic below. + defer func() { + recover() + }() + + // This call collects the heap-allocated version of x (oops!) + runtime.GC() + + // Allocate that same object again and clobber it. + y := new([20]byte) + for i := 0; i < 20; i++ { + y[i] = 99 + } + // Make sure y is heap allocated. + sink = y + + panic(nil) + + // After the recover we reach the deferreturn, which + // copies the heap version of x back to the stack. + // It gets the pointer to x from a stack slot that was + // not marked as live during the call to runtime.GC(). +} + +var sinkint int + +func g(p *int) (x [20]byte) { + // Initialize x. + for i := range x { + x[i] = byte(i) + } + + // Force x to be allocated on the heap. + sink = &x + sink = nil + + // Go to deferreturn after the panic below. + defer func() { + recover() + }() + + // This call collects the heap-allocated version of x (oops!) + runtime.GC() + + // Allocate that same object again and clobber it. + y := new([20]byte) + for i := 0; i < 20; i++ { + y[i] = 99 + } + // Make sure y is heap allocated. + sink = y + + // panic with a non-call (with no fallthrough) + for { + sinkint = *p + } + + // After the recover we reach the deferreturn, which + // copies the heap version of x back to the stack. + // It gets the pointer to x from a stack slot that was + // not marked as live during the call to runtime.GC(). +} + +func main() { + x := f() + for i, v := range x { + if v != byte(i) { + fmt.Printf("%v\n", x) + panic("bad f") + } + } + x = g(nil) + for i, v := range x { + if v != byte(i) { + fmt.Printf("%v\n", x) + panic("bad g") + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16130.go b/gcc/testsuite/go.test/test/fixedbugs/issue16130.go new file mode 100644 index 00000000000..c4e3ffd33db --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16130.go @@ -0,0 +1,43 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that an interface conversion error panics with an "interface +// conversion" run-time error. It was (incorrectly) panicking with a +// "nil pointer dereference." + +package main + +import ( + "fmt" + "runtime" + "strings" +) + +type I interface { + Get() int +} + +func main() { + defer func() { + r := recover() + if r == nil { + panic("expected panic") + } + re, ok := r.(runtime.Error) + if !ok { + panic(fmt.Sprintf("got %T, expected runtime.Error", r)) + } + if !strings.Contains(re.Error(), "interface conversion") { + panic(fmt.Sprintf("got %q, expected interface conversion error", re.Error())) + } + }() + e := (interface{})(0) + if _, ok := e.(I); ok { + panic("unexpected interface conversion success") + } + fmt.Println(e.(I)) + panic("unexpected interface conversion success") +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a1.go b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a1.go new file mode 100644 index 00000000000..497cccf3633 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a1.go @@ -0,0 +1,7 @@ +package a + +type X string + +func NewX() X { + return "" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a2.go b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a2.go new file mode 100644 index 00000000000..497cccf3633 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/a2.go @@ -0,0 +1,7 @@ +package a + +type X string + +func NewX() X { + return "" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/b.go new file mode 100644 index 00000000000..be1bebf889e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/b.go @@ -0,0 +1,7 @@ +package b + +import "./a2" + +type T struct { + X a.X +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/c.go b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/c.go new file mode 100644 index 00000000000..b25fe5a9ddb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16133.dir/c.go @@ -0,0 +1,10 @@ +package p + +import ( + "./a1" + "./b" +) + +var _ = b.T{ + X: a.NewX(), // ERROR `cannot use "a1"\.NewX\(\)` +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16193.go b/gcc/testsuite/go.test/test/fixedbugs/issue16193.go new file mode 100644 index 00000000000..eada62de9ae --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16193.go @@ -0,0 +1,27 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The compiler used the name "glob" as the function holding a global +// function literal, colliding with an actual function named "glob". + +package main + +func glob() { + func() { + }() +} + +var c1 = func() { +} + +var c2 = func() { +} + +func main() { + glob() + c1() + c2() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16249.go b/gcc/testsuite/go.test/test/fixedbugs/issue16249.go new file mode 100644 index 00000000000..723d5d9fa6c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16249.go @@ -0,0 +1,58 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Liveness calculations were wrong for a result parameter pushed onto +// the heap in a function that used defer. Program would crash with +// runtime: bad pointer in frame main.A at 0xc4201e6838: 0x1 + +package main + +import "errors" + +var sink interface{} + +//go:noinline +func f(err *error) { + if err != nil { + sink = err + } +} + +//go:noinline +func A(n, m int64) (res int64, err error) { + defer f(&err) // output parameter's address escapes to a defer. + if n < 0 { + err = errors.New("No negative") + return + } + if n <= 1 { + res = n + return + } + res = B(m) // This call to B drizzles a little junk on the stack. + res, err = A(n-1, m) + res++ + return +} + +// B does a little bit of recursion dribbling not-zero onto the stack. +//go:noinline +func B(n int64) (res int64) { + if n <= 1 { // Prefer to leave a 1 on the stack. + return n + } + return 1 + B(n-1) +} + +func main() { + x, e := A(0, 0) + for j := 0; j < 4; j++ { // j controls amount of B's stack dribble + for i := 0; i < 1000; i++ { // try more and more recursion until stack growth occurs in newobject in prologue + x, e = A(int64(i), int64(j)) + } + } + _, _ = x, e +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16306.go b/gcc/testsuite/go.test/test/fixedbugs/issue16306.go new file mode 100644 index 00000000000..d29a75a6044 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16306.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "unsafe" + +var x = unsafe.Pointer(uintptr(0)) + +func main() { + _ = map[unsafe.Pointer]int{unsafe.Pointer(uintptr(0)): 0} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/a.go new file mode 100644 index 00000000000..3a1b7e021d3 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/a.go @@ -0,0 +1,11 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +import "unsafe" + +func ConstUnsafePointer() unsafe.Pointer { + return unsafe.Pointer(uintptr(0)) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/b.go new file mode 100644 index 00000000000..b81391866b2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16317.dir/b.go @@ -0,0 +1,11 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./a" + +func main() { + _ = a.ConstUnsafePointer() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16317.go b/gcc/testsuite/go.test/test/fixedbugs/issue16317.go new file mode 100644 index 00000000000..b3376bbbd7e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16317.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 16317: cmd/compile: internal compiler error: +// unhandled OCONV INT -> TUNSAFEPTR + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16331.go b/gcc/testsuite/go.test/test/fixedbugs/issue16331.go new file mode 100644 index 00000000000..665e7fc0fd6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16331.go @@ -0,0 +1,48 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Perform tracebackdefers with a deferred reflection method. + +package main + +import "reflect" + +type T struct{} + +func (T) M() { +} + +func F(args []reflect.Value) (results []reflect.Value) { + return nil +} + +func main() { + done := make(chan bool) + go func() { + // Test reflect.makeFuncStub. + t := reflect.TypeOf((func())(nil)) + f := reflect.MakeFunc(t, F).Interface().(func()) + defer f() + growstack(10000) + done <- true + }() + <-done + go func() { + // Test reflect.methodValueCall. + f := reflect.ValueOf(T{}).Method(0).Interface().(func()) + defer f() + growstack(10000) + done <- true + }() + <-done +} + +func growstack(x int) { + if x == 0 { + return + } + growstack(x - 1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16369.go b/gcc/testsuite/go.test/test/fixedbugs/issue16369.go new file mode 100644 index 00000000000..e97f4a0e110 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16369.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +type T interface { + M(interface { + T + }) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16428.go b/gcc/testsuite/go.test/test/fixedbugs/issue16428.go new file mode 100644 index 00000000000..5696d186c77 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16428.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var ( + b = [...]byte("abc") // ERROR "outside of array literal" + s = len(b) +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16439.go b/gcc/testsuite/go.test/test/fixedbugs/issue16439.go new file mode 100644 index 00000000000..704b6b15a61 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16439.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var a []int = []int{1: 1} +var b []int = []int{-1: 1} // ERROR "must be non-negative integer constant|index expression is negative" + +var c []int = []int{2.0: 2} +var d []int = []int{-2.0: 2} // ERROR "must be non-negative integer constant|index expression is negative" + +var e []int = []int{3 + 0i: 3} +var f []int = []int{3i: 3} // ERROR "truncated to integer|index expression is not integer constant" + +var g []int = []int{"a": 4} // ERROR "must be non-negative integer constant|index expression is not integer constant" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16515.go b/gcc/testsuite/go.test/test/fixedbugs/issue16515.go new file mode 100644 index 00000000000..6b674363838 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16515.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 16515: spilled Duff-adjusted address may be invalid + +package main + +import "runtime" + +type T [62]int // DUFFZERO with non-zero adjustment on AMD64 + +var sink interface{} + +//go:noinline +func zero(x *T) { + // Two DUFFZEROs on the same address with a function call in between. + // Duff-adjusted address will be spilled and loaded + + *x = T{} // DUFFZERO + runtime.GC() + (*x)[0] = 1 + g() // call a function with large frame, trigger a stack move + *x = T{} // DUFFZERO again +} + +//go:noinline +// a function with large frame +func g() { + var x [1000]int + _ = x +} + +func main() { + var s struct { a T; b [8192-62]int } // allocate 64K, hopefully it's in a new span and a few bytes before it is garbage + sink = &s // force heap allocation + s.a[0] = 2 + zero(&s.a) + if s.a[0] != 0 { + println("s.a[0] =", s.a[0]) + panic("zeroing failed") + } + + var a T // on stack + a[0] = 2 + zero(&a) + if a[0] != 0 { + println("a[0] =", a[0]) + panic("zeroing failed") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/a.go new file mode 100644 index 00000000000..0ffdbbe2681 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/a.go @@ -0,0 +1,7 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type V struct{ i int } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/b.go new file mode 100644 index 00000000000..4f238b9a258 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/b.go @@ -0,0 +1,14 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "./a" + +var V struct{ i int } + +var U struct { + a.V + j int +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/issue16616.go b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/issue16616.go new file mode 100644 index 00000000000..0bfadb8c745 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16616.dir/issue16616.go @@ -0,0 +1,26 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "reflect" + + _ "./a" + "./b" +) + +var V struct{ i int } + +func main() { + if got := reflect.ValueOf(b.V).Type().Field(0).PkgPath; got != "b" { + panic(`PkgPath=` + got + ` for first field of b.V, want "b"`) + } + if got := reflect.ValueOf(V).Type().Field(0).PkgPath; got != "main" { + panic(`PkgPath=` + got + ` for first field of V, want "main"`) + } + if got := reflect.ValueOf(b.U).Type().Field(0).PkgPath; got != "b" { + panic(`PkgPath=` + got + ` for first field of b.U, want "b"`) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16616.go b/gcc/testsuite/go.test/test/fixedbugs/issue16616.go new file mode 100644 index 00000000000..a7d6ac095e5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16616.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Tests that unexported fields of unnamed types have different PkgPath values. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16733.go b/gcc/testsuite/go.test/test/fixedbugs/issue16733.go new file mode 100644 index 00000000000..850b042b621 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16733.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 16733: don't fold constant factors into a multiply +// beyond the capacity of a MULQ instruction (32 bits). + +package p + +func f(n int64) int64 { + n *= 1000000 + n *= 1000000 + return n +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16741.go b/gcc/testsuite/go.test/test/fixedbugs/issue16741.go new file mode 100644 index 00000000000..9946062df77 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16741.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Make sure CSE of multi-output opcodes works correctly +// with select0/1 operations. + +package main + +func div(d, r int64) int64 { + if m := d % r; m > 0 { + return d/r + 1 + } + return d / r +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16760.go b/gcc/testsuite/go.test/test/fixedbugs/issue16760.go new file mode 100644 index 00000000000..d0e08b5ead2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16760.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Make sure we don't start marshaling (writing to the stack) +// arguments until those arguments are evaluated and known +// not to unconditinally panic. If they unconditionally panic, +// we write some args but never do the call. That messes up +// the logic which decides how big the argout section needs to be. + +package main + +type W interface { + Write([]byte) +} + +type F func(W) + +func foo(f F) { + defer func() { + if r := recover(); r != nil { + usestack(1000) + } + }() + f(nil) +} + +func main() { + foo(func(w W) { + var x []string + w.Write([]byte(x[5])) + }) +} + +func usestack(n int) { + if n == 0 { + return + } + usestack(n - 1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16804.go b/gcc/testsuite/go.test/test/fixedbugs/issue16804.go new file mode 100644 index 00000000000..46dd4a33ccb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16804.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 16804: internal error for math.Sqrt as statement +// rather than expression + +package main + +import "math" + +func sqrt() { + math.Sqrt(2.0) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16948.go b/gcc/testsuite/go.test/test/fixedbugs/issue16948.go new file mode 100644 index 00000000000..c9860248961 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16948.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 16948: make sure intrinsified atomic ops won't +// confuse the scheduler. + +package main + +import "sync/atomic" + +func main() { + f() +} + +var x int32 + +type T [10]int +var sink *T + +func f() (t T) { + atomic.AddInt32(&x, 1) + g(42, 42, 42, 42, 42, &t) // use int values that is invalid pointer to smash the stack slot of return value of runtime.newobject + return +} + +//go:noinline +func g(a, b, c, d, e int, p *T) { + var t [10000]int // a large stack frame to trigger stack growing + _ = t + sink = p // force p (in caller) heap allocated +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue16985.go b/gcc/testsuite/go.test/test/fixedbugs/issue16985.go new file mode 100644 index 00000000000..0cb0dae51c4 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue16985.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 16985: intrinsified AMD64 atomic ops should clobber flags + +package main + +import "sync/atomic" + +var count uint32 + +func main() { + buffer := []byte("T") + for i := 0; i < len(buffer); { + atomic.AddUint32(&count, 1) + _ = buffer[i] + i++ + i++ + } + + for i := 0; i < len(buffer); { + atomic.CompareAndSwapUint32(&count, 0, 1) + _ = buffer[i] + i++ + i++ + } + + for i := 0; i < len(buffer); { + atomic.SwapUint32(&count, 1) + _ = buffer[i] + i++ + i++ + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17005.go b/gcc/testsuite/go.test/test/fixedbugs/issue17005.go new file mode 100644 index 00000000000..e539519b6f5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17005.go @@ -0,0 +1,46 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This tickles (a version of) the PPC64 back end to +// emit a BVS instruction. + +package foo + +type Flag int + +const ( + Identity Flag = iota - 2 // H is the identity matrix; no rotation is needed. + Rescaling // H specifies rescaling. +) + +type DrotmParams struct { + Flag +} + +func Drotmg(d1, d2, x1, y1 float64) (p DrotmParams, rd1, rd2, rx1 float64) { + + const ( + gam = 4.0 + gamsq = 16.0 + rgamsq = 5e-8 + ) + + if d1 < 0 { + p.Flag = Rescaling + return + } + + for rd1 <= rgamsq || rd1 >= gamsq { + if rd1 <= rgamsq { + rd1 *= gam * gam + rx1 /= gam + } else { + rd1 /= gam * gam + rx1 *= gam + } + } + return +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17111.go b/gcc/testsuite/go.test/test/fixedbugs/issue17111.go new file mode 100644 index 00000000000..05284a785f5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17111.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type I int + +var ( + i int + x = I(i) + + e interface{} = x +) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17194.go b/gcc/testsuite/go.test/test/fixedbugs/issue17194.go new file mode 100644 index 00000000000..0594e1cbdc1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17194.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +func f(x []interface{}) (err error) { + for _, d := range x { + _, ok := d.(*int) + if ok { + return + } + } + return +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17270.go b/gcc/testsuite/go.test/test/fixedbugs/issue17270.go new file mode 100644 index 00000000000..5c009b58dfb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17270.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +import "unsafe" + +const _ = (unsafe.Sizeof)(0) diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17328.go b/gcc/testsuite/go.test/test/fixedbugs/issue17328.go new file mode 100644 index 00000000000..ef60edbd426 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17328.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 The Go 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() { + i := 0 + for ; ; i++) { // ERROR "unexpected \), expecting { after for clause|expected .*{.*|expected .*;.*" + } +} // GCCGO_ERROR "expected declaration" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17381.go b/gcc/testsuite/go.test/test/fixedbugs/issue17381.go new file mode 100644 index 00000000000..be63633e7fb --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17381.go @@ -0,0 +1,54 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 17381: make sure leave function with non-empty frame +// saves link register, so that traceback will work. + +package main + +import ( + "runtime" + "unsafe" +) + +func main() { + defer func() { + if recover() == nil { + panic("did not panic") + } + pcs := make([]uintptr, 20) + n := runtime.Callers(1, pcs) + for _, pc := range pcs[:n] { + if runtime.FuncForPC(pc).Name() == "main.main" { + return + } + } + panic("cannot find main.main in backtrace") + }() + + prep() + f() // should panic +} + +func funcPC(f interface{}) uintptr { + var ptr uintptr + return **(**uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&f)) + unsafe.Sizeof(ptr))) +} + +//go:noinline +func f() { + var t [1]int // non-empty frame + *(*int)(nil) = t[0] +} + +var p = funcPC(runtime.GC) + 8 + +//go:noinline +func prep() { + // put some garbage on stack + var x = [20]uintptr{p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p} + _ = x +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17551.go b/gcc/testsuite/go.test/test/fixedbugs/issue17551.go new file mode 100644 index 00000000000..b8751ab42dc --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17551.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 17551: inrange optimization failed to preserve type information. + +package main + +import "fmt" + +func main() { + _, x := X() + fmt.Printf("x = %v\n", x) +} + +func X() (i int, ok bool) { + ii := int(1) + return ii, 0 <= ii && ii <= 0x7fffffff +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17588.go b/gcc/testsuite/go.test/test/fixedbugs/issue17588.go new file mode 100644 index 00000000000..0e3a14ef7c4 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17588.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 17588: internal compiler error in typecheckclosure() +// because in case of Func.Nname.Type == nil, Decldepth +// is not initialized in typecheckfunc(). This test +// produces that case. + +package p + +type F func(b T) // ERROR "T is not a type|expected type" + +func T(fn F) { + func() { + fn(nil) // If Decldepth is not initialized properly, typecheckclosure() Fatals here. + }() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17596.go b/gcc/testsuite/go.test/test/fixedbugs/issue17596.go new file mode 100644 index 00000000000..7398292d434 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17596.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +type T interface { + foo() +} + +func f() (T, int) + +func g(v interface{}) (interface{}, int) { + var x int + v, x = f() + return v, x +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17631.go b/gcc/testsuite/go.test/test/fixedbugs/issue17631.go new file mode 100644 index 00000000000..b820b2d5a75 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17631.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "time" + +func main() { + _ = struct { + about string + before map[string]uint + update map[string]int + updateTime time.Time + expect map[string]int + }{ + about: "this one", + updates: map[string]int{"gopher": 10}, // ERROR "unknown field 'updates' in struct literal of type|unknown field .*updates.* in .*unnamed struct.*" + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17640.go b/gcc/testsuite/go.test/test/fixedbugs/issue17640.go new file mode 100644 index 00000000000..a311521829a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17640.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +var results string + +type TwoInts struct { + x, y int +} + +func f(x int) int { results = results + fmt.Sprintf("_%d", x); return x } + +func main() { + _ = [19]int{1: f(1), 0: f(0), 2: f(2), 6, 7} + _ = [2]int{1: f(4), 0: f(3)} + _ = TwoInts{y: f(6), x: f(5)} + _ = map[int]int{f(f(9) + 1): f(8), 0: f(7), f(22): -1} + if results != "_1_0_2_4_3_6_5_9_10_8_7_22" { + fmt.Printf("unexpected: %s\n", results) + panic("fail") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17645.go b/gcc/testsuite/go.test/test/fixedbugs/issue17645.go new file mode 100644 index 00000000000..bb34e4ee97a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17645.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type Foo struct { + X int +} + +func main() { + var s []int + var _ string = append(s, Foo{""}) // ERROR "cannot use .. \(type untyped string\) as type int in field value|incompatible type" "cannot use Foo{...} \(type Foo\) as type int in append" "cannot use append\(s\, Foo{...}\) \(type \[\]int\) as type string in assignment" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17710.go b/gcc/testsuite/go.test/test/fixedbugs/issue17710.go new file mode 100644 index 00000000000..2843458c611 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17710.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "runtime" + +func f(x interface{}) { + runtime.KeepAlive(x) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17752.go b/gcc/testsuite/go.test/test/fixedbugs/issue17752.go new file mode 100644 index 00000000000..83283ad6605 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17752.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func f(m map[string]int) int { + return m["a"] +} + +func g(m map[[8]string]int) int { + return m[[8]string{"a", "a", "a", "a", "a", "a", "a", "a"}] +} + +func main() { + m := map[[8]string]int{} + g(m) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17758.go b/gcc/testsuite/go.test/test/fixedbugs/issue17758.go new file mode 100644 index 00000000000..8e40f9db733 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17758.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2020 The Go 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 foo() { + _ = func() {} +} + +func foo() { // ERROR "foo redeclared in this block|redefinition of .*foo.*" + _ = func() {} +} + +func main() {} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue17918.go b/gcc/testsuite/go.test/test/fixedbugs/issue17918.go new file mode 100644 index 00000000000..88ede6f7b71 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue17918.go @@ -0,0 +1,41 @@ +// compile + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 17918: slice out-of-bounds in ssa/cse + +package dead + +import ( + "fmt" + "time" +) + +var ( + units = []struct { + divisor time.Duration + unit rune + }{ + {1000000, 's'}, + {60, 'm'}, + {60, 'h'}, + {24, 'd'}, + {7, 'w'}, + } +) + +func foobar(d time.Duration) string { + d /= time.Microsecond + unit := 'u' + + for _, f := range units { + if d%f.divisor != 0 { + break + } + d /= f.divisor + unit = f.unit + } + return fmt.Sprintf("%d%c", d, unit) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18089.go b/gcc/testsuite/go.test/test/fixedbugs/issue18089.go new file mode 100644 index 00000000000..fe5c1d48306 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18089.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +type T struct { + x int + _ int +} + +func main() { + _ = T{0, 0} + + x := T{1, 1} + _ = x +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18092.go b/gcc/testsuite/go.test/test/fixedbugs/issue18092.go new file mode 100644 index 00000000000..a0f7eddda5a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18092.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func _() { + var ch chan bool + select { + default: + case <-ch { // GCCGO_ERROR "expected colon" + } // GC_ERROR "expecting :" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18231.go b/gcc/testsuite/go.test/test/fixedbugs/issue18231.go new file mode 100644 index 00000000000..77473040526 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18231.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 The Go 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 error message for composite literals with +// missing type is at the right place. + +package p + +type T struct { + f map[string]string +} + +var _ = T{ + f: { // ERROR "missing type in composite literal|may only omit types within" + "a": "b", + }, +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18393.go b/gcc/testsuite/go.test/test/fixedbugs/issue18393.go new file mode 100644 index 00000000000..454392721f0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18393.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2017 The Go 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 compiler directives are ignored if they +// don't start at the beginning of the line. + +package p + +//line issue18393.go:20 +import 42 // error on line 20 + + +/* //line not at start of line: ignored */ //line issue18393.go:30 +var x // error on line 24, not 30 + + +// ERROR "import path must be a string" + + + +// ERROR "syntax error: unexpected newline, expecting type|expected type" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18410.go b/gcc/testsuite/go.test/test/fixedbugs/issue18410.go new file mode 100644 index 00000000000..e9c6f862eba --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18410.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This checks partially initialized structure literals +// used to create value.method functions have their +// non-initialized fields properly zeroed/nil'd + +package main + +type X struct { + A, B, C *int +} + +//go:noinline +func (t X) Print() { + if t.B != nil { + panic("t.B must be nil") + } +} + +//go:noinline +func caller(f func()) { + f() +} + +//go:noinline +func test() { + var i, j int + x := X{A: &i, C: &j} + caller(func() { X{A: &i, C: &j}.Print() }) + caller(X{A: &i, C: &j}.Print) + caller(x.Print) +} + +func main() { + test() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/other.go b/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/other.go new file mode 100644 index 00000000000..27243d297bf --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/other.go @@ -0,0 +1,11 @@ +// Copyright 2017 The Go 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 other + +type Exported struct { + Member int +} + +func (e *Exported) member() int { return 1 } diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/test.go b/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/test.go new file mode 100644 index 00000000000..da9639dd72e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18419.dir/test.go @@ -0,0 +1,15 @@ +// errorcheck -0 -m -l + +// Copyright 2017 The Go 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 "./other" + +func InMyCode(e *other.Exported) { + e.member() // ERROR "e\.member undefined .cannot refer to unexported field or method other\.\(\*Exported\)\.member.|unexported field or method" +} + +func main() {} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18419.go b/gcc/testsuite/go.test/test/fixedbugs/issue18419.go new file mode 100644 index 00000000000..25544efd9b9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18419.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18595.go b/gcc/testsuite/go.test/test/fixedbugs/issue18595.go new file mode 100644 index 00000000000..d6f07b30e2f --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18595.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2017 The Go 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 makes sure that itabs are unique. +// More explicitly, we require that only one itab structure exists for the pair of +// a given compile-time interface type and underlying concrete type. +// Ensuring this invariant enables fixes for 18492 (improve type switch code). + +package main + +type I interface { + M() +} +type J interface { + M() +} + +type T struct{} + +func (*T) M() {} + +func main() { + test1() + test2() +} + +func test1() { + t := new(T) + var i1, i2 I + var j interface { + M() + } + i1 = t + j = t + i2 = j + if i1 != i2 { + panic("interfaces not equal") + } +} + +func test2() { + t := new(T) + i1 := (I)(t) + i2 := (I)((interface { + M() + })((J)(t))) + if i1 != i2 { + panic("interfaces not equal") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18636.go b/gcc/testsuite/go.test/test/fixedbugs/issue18636.go new file mode 100644 index 00000000000..2704fc46ee9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18636.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "runtime/debug" + +type Foo struct { + A [1 << 20]byte + B string +} + +func run(c chan bool) { + f := new(Foo) + *f = Foo{B: "hello"} + c <- true +} + +func main() { + debug.SetMaxStack(1 << 16) + c := make(chan bool) + go run(c) + <-c +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18640.go b/gcc/testsuite/go.test/test/fixedbugs/issue18640.go new file mode 100644 index 00000000000..091bbe596b2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18640.go @@ -0,0 +1,46 @@ +// compile + +// Copyright 2017 The Go 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 = b + b struct { + *a + } +) + +type ( + c struct { + *d + } + d = c +) + +// The compiler cannot handle these cases. Disabled for now. +// See issue #25838. +/* +type ( + e = f + f = g + g = []h + h i + i = j + j = e +) + +type ( + a1 struct{ *b1 } + b1 = c1 + c1 struct{ *b1 } +) + +type ( + a2 struct{ b2 } + b2 = c2 + c2 struct{ *b2 } +) +*/ diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18655.go b/gcc/testsuite/go.test/test/fixedbugs/issue18655.go new file mode 100644 index 00000000000..13762f1a94b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18655.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2017 The Go 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{} +type A = T +type B = T + +func (T) m() {} +func (T) m() {} // ERROR "redeclared|redefinition" +func (A) m() {} // ERROR "redeclared|redefinition" +func (A) m() {} // ERROR "redeclared|redefinition" +func (B) m() {} // ERROR "redeclared|redefinition" +func (B) m() {} // ERROR "redeclared|redefinition" + +func (*T) m() {} // ERROR "redeclared|redefinition" +func (*A) m() {} // ERROR "redeclared|redefinition" +func (*B) m() {} // ERROR "redeclared|redefinition" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18661.go b/gcc/testsuite/go.test/test/fixedbugs/issue18661.go new file mode 100644 index 00000000000..e64a771a83d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18661.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2017 The Go 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" + "os" +) + +var ( + e interface{} + s = struct{ a *int }{} + b = e == s +) + +func test(obj interface{}) { + if obj != struct{ a *string }{} { + } +} + +var x int + +func f() [2]string { + x++ + return [2]string{"abc", "def"} +} + +func main() { + var e interface{} = [2]string{"abc", "def"} + _ = e == f() + if x != 1 { + fmt.Println("x=", x) + os.Exit(1) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18725.go b/gcc/testsuite/go.test/test/fixedbugs/issue18725.go new file mode 100644 index 00000000000..c632dbad639 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18725.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2017 The Go 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 panicWhenNot(cond bool) { + if cond { + os.Exit(0) + } else { + panic("nilcheck elim failed") + } +} + +func main() { + e := (*string)(nil) + panicWhenNot(e == e) + // Should never reach this line. + panicWhenNot(*e == *e) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18808.go b/gcc/testsuite/go.test/test/fixedbugs/issue18808.go new file mode 100644 index 00000000000..c98386ee784 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18808.go @@ -0,0 +1,63 @@ +// run + +// Copyright 2017 The Go 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 lim = 0x80000000 + +//go:noinline +func eq(x uint32) { + if x == lim { + return + } + panic("x == lim returned false") +} + +//go:noinline +func neq(x uint32) { + if x != lim { + panic("x != lim returned true") + } +} + +//go:noinline +func gt(x uint32) { + if x > lim { + return + } + panic("x > lim returned false") +} + +//go:noinline +func gte(x uint32) { + if x >= lim { + return + } + panic("x >= lim returned false") +} + +//go:noinline +func lt(x uint32) { + if x < lim { + panic("x < lim returned true") + } +} + +//go:noinline +func lte(x uint32) { + if x <= lim { + panic("x <= lim returned true") + } +} + +func main() { + eq(lim) + neq(lim) + gt(lim+1) + gte(lim+1) + lt(lim+1) + lte(lim+1) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18906.go b/gcc/testsuite/go.test/test/fixedbugs/issue18906.go new file mode 100644 index 00000000000..544400be258 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18906.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2017 The Go 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 + +//go:noinline +func f(x int) { +} + +//go:noinline +func val() int8 { + return -1 +} + +var ( + array = [257]int{} + slice = array[1:] +) + +func init() { + for i := range array { + array[i] = i - 1 + } +} + +func main() { + x := val() + y := int(uint8(x)) + f(y) // try and force y to be calculated and spilled + if slice[y] != 255 { + panic("incorrect value") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18915.go b/gcc/testsuite/go.test/test/fixedbugs/issue18915.go new file mode 100644 index 00000000000..22f97c6b62b --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18915.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2017 The Go 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 error message for invalid conditions +// or tags are consistent with earlier Go versions. + +package p + +func _() { + if a := 10 { // ERROR "cannot use a := 10 as value|expected .*;|declared but not used" + } + + for b := 10 { // ERROR "cannot use b := 10 as value|parse error|declared but not used" + } + + switch c := 10 { // ERROR "cannot use c := 10 as value|expected .*;|declared but not used" + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue18994.go b/gcc/testsuite/go.test/test/fixedbugs/issue18994.go new file mode 100644 index 00000000000..aa307139f53 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue18994.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2017 The Go 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 18994: SSA didn't handle DOT STRUCTLIT for zero-valued +// STRUCTLIT. + +package main + +// large struct - not SSA-able +type T struct { + a, b, c, d, e, f, g, h int +} + +func main() { + x := T{}.a + if x != 0 { + panic("FAIL") + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19012.go b/gcc/testsuite/go.test/test/fixedbugs/issue19012.go new file mode 100644 index 00000000000..158618aa27e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19012.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2017 The Go 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 19012: if we have any unknown type at a call site, +// we must ensure that we return to the user a suppressed +// error message saying instead of including in +// the message. + +package main + +func f(x int, y uint) { + if true { + return "a" > 10 // ERROR "^too many arguments to return$|return with value in function with no return|mismatched types" + } + return "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|mismatched types" +} + +func main() { + f(2, 3 < "x", 10) // ERROR "too many arguments|invalid operation|incompatible type" + + f(10, 10, "a") // ERROR "too many arguments" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/a.go new file mode 100644 index 00000000000..361251d7505 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/a.go @@ -0,0 +1,9 @@ +// Copyright 2017 The Go 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 reflect + +import "reflect" + +type Type reflect.Type diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/main.go new file mode 100644 index 00000000000..e2ee7b8ca1d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19028.dir/main.go @@ -0,0 +1,26 @@ +// Copyright 2017 The Go 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 ( + "reflect" + fake "./a" // 2nd package with name "reflect" +) + +type T struct { + _ fake.Type +} + +func (T) f() {} +func (T) G() (_ int) { return } +func (T) H() (_, _ int) { return } + +func main() { + var x T + typ := reflect.TypeOf(x) + for i := 0; i < typ.NumMethod(); i++ { + _ = typ.Method(i) // must not crash + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19028.go b/gcc/testsuite/go.test/test/fixedbugs/issue19028.go new file mode 100644 index 00000000000..8d934d2d671 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19028.go @@ -0,0 +1,13 @@ +// rundir + +// Copyright 2017 The Go 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 failed when the compiler didn't use the +// correct code to identify the type reflect.Method. +// The failing code relied on Type.String() which had +// formatting that depended on whether a package (in +// this case "reflect") was imported more than once. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19040.go b/gcc/testsuite/go.test/test/fixedbugs/issue19040.go new file mode 100644 index 00000000000..67881df6243 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19040.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2017 The Go 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 the text of the panic that comes from +// a nil pointer passed to automatically generated method wrapper. + +package main + +import "fmt" + +type T int + +type I interface { + F() +} + +func (t T) F() {} + +var ( + t *T + i I = t +) + +func main() { + defer func() { + got := recover().(error).Error() + want := "value method main.T.F called using nil *T pointer" + if got != want { + fmt.Printf("panicwrap error text:\n\t%q\nwant:\n\t%q\n", got, want) + } + }() + i.F() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19056.go b/gcc/testsuite/go.test/test/fixedbugs/issue19056.go new file mode 100644 index 00000000000..d279eaa3cf6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19056.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 The Go 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 + +var _ = ... . // ERROR "unexpected ...|expected operand|expected .*;" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19078.go b/gcc/testsuite/go.test/test/fixedbugs/issue19078.go new file mode 100644 index 00000000000..b19e8749d7a --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19078.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2017 The Go 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 19078: liveness & zero-initialization of results +// when there is a defer. +package main + +import "unsafe" + +func main() { + // Construct an invalid pointer. We do this by + // making a pointer which points to the unused space + // between the last 48-byte object in a span and the + // end of the span (there are 32 unused bytes there). + p := new([48]byte) // make a 48-byte object + sink = &p // escape it, so it allocates for real + u := uintptr(unsafe.Pointer(p)) // get its address + u = u >> 13 << 13 // round down to page size + u += 1<<13 - 1 // add almost a page + + for i := 0; i < 1000000; i++ { + _ = identity(u) // installs u at return slot + _ = liveReturnSlot(nil) // incorrectly marks return slot as live + } +} + +//go:noinline +func liveReturnSlot(x *int) *int { + defer func() {}() // causes return slot to be marked live + sink = &x // causes x to be moved to the heap, triggering allocation + return x +} + +//go:noinline +func identity(x uintptr) uintptr { + return x +} + +var sink interface{} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19084.go b/gcc/testsuite/go.test/test/fixedbugs/issue19084.go new file mode 100644 index 00000000000..ba5306320b5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19084.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2017 The Go 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 19084: SSA doesn't handle CONVNOP STRUCTLIT + +package p + +type T struct { + a, b, c, d, e, f, g, h int // big, not SSA-able +} + +func f() { + _ = T(T{}) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19137.go b/gcc/testsuite/go.test/test/fixedbugs/issue19137.go new file mode 100644 index 00000000000..0539a850ca6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19137.go @@ -0,0 +1,51 @@ +// compile + +// Copyright 2017 The Go 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 19137: folding address into load/store causes +// odd offset on ARM64. + +package p + +type T struct { + p *int + a [2]byte + b [6]byte // not 4-byte aligned +} + +func f(b [6]byte) T { + var x [1000]int // a large stack frame + _ = x + return T{b: b} +} + +// Arg symbol's base address may be not at an aligned offset to +// SP. Folding arg's address into load/store may cause odd offset. +func move(a, b [20]byte) [20]byte { + var x [1000]int // a large stack frame + _ = x + return b // b is not 8-byte aligned to SP +} +func zero() ([20]byte, [20]byte) { + var x [1000]int // a large stack frame + _ = x + return [20]byte{}, [20]byte{} // the second return value is not 8-byte aligned to SP +} + +// Issue 21992: unaligned offset between 256 and 504 and handled +// incorrectly. +type T2 struct { + a [257]byte + // fields below are not 8-, 4-, 2-byte aligned + b [8]byte + c [4]byte + d [2]byte +} + +func f2(x *T2) { + x.b = [8]byte{} + x.c = [4]byte{} + x.d = [2]byte{} +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19182.go b/gcc/testsuite/go.test/test/fixedbugs/issue19182.go new file mode 100644 index 00000000000..e1f3ffb4749 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19182.go @@ -0,0 +1,37 @@ +// run +// +build !js + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "runtime" + "sync/atomic" + "time" +) + +var a uint64 = 0 + +func main() { + runtime.GOMAXPROCS(2) // With just 1, infinite loop never yields + + go func() { + for { + atomic.AddUint64(&a, uint64(1)) + } + }() + + time.Sleep(10 * time.Millisecond) // Short sleep is enough in passing case + i, val := 0, atomic.LoadUint64(&a) + for ; val == 0 && i < 100; val, i = atomic.LoadUint64(&a), i+1 { + time.Sleep(100 * time.Millisecond) + } + if val == 0 { + fmt.Printf("Failed to observe atomic increment after %d tries\n", i) + } + +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19201.go b/gcc/testsuite/go.test/test/fixedbugs/issue19201.go new file mode 100644 index 00000000000..e370d55df15 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19201.go @@ -0,0 +1,52 @@ +// run + +// Copyright 2017 The Go 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 ( + "encoding/binary" +) + +var ( + ch1 = make(chan int) + ch2 = make(chan int) + + bin = []byte("a\000\000\001") + want = binary.BigEndian.Uint32(bin) + + c consumer = noopConsumer{} +) + +type msg struct { + code uint32 +} + +type consumer interface { + consume(msg) +} + +type noopConsumer struct{} + +func (noopConsumer) consume(msg) {} + +func init() { + close(ch1) +} + +func main() { + var m msg + m.code = binary.BigEndian.Uint32(bin) + + select { + case <-ch1: + c.consume(m) + if m.code != want { + // can not use m.code here, or it will work + panic("BigEndian read failed") + } + case <-ch2: + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19217.go b/gcc/testsuite/go.test/test/fixedbugs/issue19217.go new file mode 100644 index 00000000000..96794064a40 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19217.go @@ -0,0 +1,39 @@ +// compile + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +import ( + "encoding/binary" +) + +type DbBuilder struct { + arr []int +} + +func (bld *DbBuilder) Finish() error { + defer bld.Finish() + + var hash []byte + for _, ixw := range bld.arr { + for { + if ixw != 0 { + panic("ixw != 0") + } + ixw-- + insertOne: + for { + for i := 0; i < 1; i++ { + if binary.LittleEndian.Uint16(hash[i:]) == 0 { + break insertOne + } + } + } + } + } + + return nil +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19275.go b/gcc/testsuite/go.test/test/fixedbugs/issue19275.go new file mode 100644 index 00000000000..f7e64fc9aec --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19275.go @@ -0,0 +1,72 @@ +// run + +// Copyright 2017 The Go 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" +) + +type PI struct { + Enabled bool +} + +type SI struct { + M map[string]*PI +} + +//go:noinline +func (s *SI) test(name string) (*int, error) { + n := new(int) + *n = 99 + if err := addUpdate(n, s.M[name].Enabled, "enabled"); err != nil { // this was miscompiled + return nil, fmt.Errorf(" error adding update for enable flag %t : %s", + s.M[name].Enabled, err) + } + return n, nil +} + +//go:noinline +func addUpdate(n *int, in interface{}, s ...string) error { + if *n != 99 { + println("FAIL, *n should be 99, not", *n) + } + return nil +} + +func main1() { + s := &SI{make(map[string]*PI)} + s.M["dog"] = &PI{} + s.test("dog") +} + +//go:noinline +func g(b *byte, i interface{}) error { + if *b != 17 { + println("FAIL, *b should be 17, not", *b) + } + return nil +} + +//go:noinline +func f(x *byte, m map[string]*bool) { + if err := g(x, *m["hello"]); err != nil { // this was miscompiled + return + } +} + +func main2() { + m := make(map[string]*bool) + x := false + m["hello"] = &x + b := byte(17) + f(&b, m) +} + +func main() { + main2() + main1() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19323.go b/gcc/testsuite/go.test/test/fixedbugs/issue19323.go new file mode 100644 index 00000000000..71365e10dd3 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19323.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2017 The Go 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 g() {} + +func f() { + g()[:] // ERROR "g.. used as value|attempt to slice object that is not" +} + +func g2() ([]byte, []byte) { return nil, nil } + +func f2() { + g2()[:] // ERROR "multiple-value g2.. in single-value context|attempt to slice object that is not" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19359.go b/gcc/testsuite/go.test/test/fixedbugs/issue19359.go new file mode 100644 index 00000000000..cc3ecc84f61 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19359.go @@ -0,0 +1,91 @@ +// run + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func set(m map[interface{}]interface{}, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("set failed: %v", r) + } + }() + m[key] = nil + return nil +} + +func del(m map[interface{}]interface{}, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("del failed: %v", r) + } + }() + delete(m, key) + return nil +} + +func addInt(m map[interface{}]int, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addInt failed: %v", r) + } + }() + m[key] += 2018 + return nil +} + +func addStr(m map[interface{}]string, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addStr failed: %v", r) + } + }() + m[key] += "hello, go" + return nil +} + +func appendInt(m map[interface{}][]int, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("appendInt failed: %v", r) + } + }() + m[key] = append(m[key], 2018) + return nil +} + +func appendStr(m map[interface{}][]string, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addStr failed: %v", r) + } + }() + m[key] = append(m[key], "hello, go") + return nil +} + +func main() { + m := make(map[interface{}]interface{}) + set(m, []int{1, 2, 3}) + set(m, "abc") // used to throw + del(m, []int{1, 2, 3}) + del(m, "abc") // used to throw + + mi := make(map[interface{}]int) + addInt(mi, []int{1, 2, 3}) + addInt(mi, "abc") // used to throw + + ms := make(map[interface{}]string) + addStr(ms, []int{1, 2, 3}) + addStr(ms, "abc") // used to throw + + mia := make(map[interface{}][]int) + appendInt(mia, []int{1, 2, 3}) + + msa := make(map[interface{}][]string) + appendStr(msa, "abc") // used to throw +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19482.go b/gcc/testsuite/go.test/test/fixedbugs/issue19482.go new file mode 100644 index 00000000000..4c2c19ec9d9 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19482.go @@ -0,0 +1,34 @@ +// errorcheck + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Compiler rejected initialization of structs to composite literals +// in a non-static setting (e.g. in a function) +// when the struct contained a field named _. + +package p + +type T struct { + _ string +} + +func ok() { + var x = T{"check"} + _ = x + _ = T{"et"} +} + +var ( + y = T{"stare"} + w = T{_: "look"} // ERROR "invalid field name _ in struct initializer|expected struct field name" + _ = T{"page"} + _ = T{_: "out"} // ERROR "invalid field name _ in struct initializer|expected struct field name" +) + +func bad() { + var z = T{_: "verse"} // ERROR "invalid field name _ in struct initializer|expected struct field name" + _ = z + _ = T{_: "itinerary"} // ERROR "invalid field name _ in struct initializer|expected struct field name" +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/div_arm.s b/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/div_arm.s new file mode 100644 index 00000000000..0bc33e92ce2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/div_arm.s @@ -0,0 +1,12 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +TEXT ·f(SB),0,$0-8 + MOVW x+0(FP), R1 + MOVW x+4(FP), R2 + DIVU R1, R2 + DIV R1, R2 + MODU R1, R2 + MOD R1, R2 + RET diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/main.go b/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/main.go new file mode 100644 index 00000000000..c115556f91d --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19507.dir/main.go @@ -0,0 +1,16 @@ +// +build arm + +// Copyright 2017 The Go 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 we can compile assembly with DIV and MOD in it. +// They get rewritten to runtime calls on GOARM=5. + +package main + +func f(x, y uint32) + +func main() { + f(5, 8) +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19507.go b/gcc/testsuite/go.test/test/fixedbugs/issue19507.go new file mode 100644 index 00000000000..543e17e50b2 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19507.go @@ -0,0 +1,8 @@ +// +build arm +// builddir + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19515.go b/gcc/testsuite/go.test/test/fixedbugs/issue19515.go new file mode 100644 index 00000000000..a1605bec963 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19515.go @@ -0,0 +1,51 @@ +// compile + +// Copyright 2017 The Go 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 19515: compiler panics on spilling int128 constant. + +package x + +type VScrollPanel struct { + x, y int +} + +type Color struct { + R, G, B, A float32 +} + +func maxF(a, b float32) float32 { + if a > b { + return 0 + } + return 1 +} + +type TransformMatrix [6]float32 + +type Paint struct { + xform TransformMatrix + feather float32 + innerColor Color + outerColor Color +} + +func BoxGradient(x, y, w, h, f float32, iColor, oColor Color) Paint { + return Paint{ + xform: TransformMatrix{9, 0, 0, 0, x, y}, + feather: maxF(1.0, f), + innerColor: iColor, + outerColor: oColor, + } +} + +func (v *VScrollPanel) Draw() { + x := float32(v.x) + y := float32(v.y) + + BoxGradient(x+x-2, y-1, 0, 0, 0, Color{}, Color{}) + BoxGradient(x+y-2, y-1, 0, 0, 0, Color{}, Color{}) +} + diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/a.go new file mode 100644 index 00000000000..3b7cd4b0e23 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/a.go @@ -0,0 +1,26 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type Mode uint + +func (m Mode) String() string { return "mode string" } +func (m *Mode) Addr() *Mode { return m } + +type Stringer interface { + String() string +} + +var global Stringer +var m Mode + +func init() { + // force compilation of the (*Mode).String() wrapper + global = &m +} + +func String() string { + return global.String() + Mode(0).String() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/b.go new file mode 100644 index 00000000000..e5e807f43de --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19548.dir/b.go @@ -0,0 +1,24 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./a" + +type Value interface { + a.Stringer + Addr() *a.Mode +} + +var global a.Mode + +func f() int { + var v Value + v = &global + return int(v.String()[0]) +} + +func main() { + f() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19548.go b/gcc/testsuite/go.test/test/fixedbugs/issue19548.go new file mode 100644 index 00000000000..e0e769338a5 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19548.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2017 The Go 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 interface wrappers can be compiled successfully +// in multiple translation units. +package ignore diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19555.go b/gcc/testsuite/go.test/test/fixedbugs/issue19555.go new file mode 100644 index 00000000000..53b2ebde51e --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19555.go @@ -0,0 +1,36 @@ +// compile + +// Copyright 2017 The Go 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 NodeLink struct{} + +// A role our end of NodeLink is intended to play +type LinkRole int64 + +const ( + LinkServer LinkRole = iota // link created as server + LinkClient // link created as client + + // for testing: + linkNoRecvSend LinkRole = 1 << 16 // do not spawn serveRecv & serveSend + linkFlagsMask LinkRole = (1<<32 - 1) << 16 +) + +func NewNodeLink(role LinkRole) *NodeLink { + var nextConnId uint32 + switch role &^ linkFlagsMask { + case LinkServer: + nextConnId = 0 // all initiated by us connId will be even + case LinkClient: + nextConnId = 1 // ----//---- odd + default: + panic("invalid conn role") + } + + _ = nextConnId + return nil +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19632.go b/gcc/testsuite/go.test/test/fixedbugs/issue19632.go new file mode 100644 index 00000000000..41cb1ffa1de --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19632.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2017 The Go 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 we don't crash due to "lost track of variable in +// liveness" errors against unused variables. + +package p + +import "strings" + +// Minimized test case from github.com/mvdan/sh/syntax. +func F() { + var _ = []string{ + strings.Repeat("\n\n\t\t \n", 10) + + "# " + strings.Repeat("foo bar ", 10) + "\n" + + strings.Repeat("longlit_", 10) + "\n", + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19658.go b/gcc/testsuite/go.test/test/fixedbugs/issue19658.go new file mode 100644 index 00000000000..b2539629df0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19658.go @@ -0,0 +1,99 @@ +// +build !nacl,!js +// run + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// ensure that panic(x) where x is a numeric type displays a readable number +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" +) + +const fn = ` +package main + +import "errors" +type S struct { + +} +func (s S) String() string { + return "s-stringer" +} +func main() { + _ = errors.New + panic(%s(%s)) +} +` + +func main() { + tempDir, err := ioutil.TempDir("", "") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(tempDir) + tmpFile := filepath.Join(tempDir, "tmp.go") + + for _, tc := range []struct { + Type string + Input string + Expect string + }{{"", "nil", "panic: nil"}, + {"errors.New", `"test"`, "panic: test"}, + {"S", "S{}", "panic: s-stringer"}, + {"byte", "8", "panic: 8"}, + {"rune", "8", "panic: 8"}, + {"int", "8", "panic: 8"}, + {"int8", "8", "panic: 8"}, + {"int16", "8", "panic: 8"}, + {"int32", "8", "panic: 8"}, + {"int64", "8", "panic: 8"}, + {"uint", "8", "panic: 8"}, + {"uint8", "8", "panic: 8"}, + {"uint16", "8", "panic: 8"}, + {"uint32", "8", "panic: 8"}, + {"uint64", "8", "panic: 8"}, + {"uintptr", "8", "panic: 8"}, + {"bool", "true", "panic: true"}, + {"complex64", "8 + 16i", "panic: (+8.000000e+000+1.600000e+001i)"}, + {"complex128", "8+16i", "panic: (+8.000000e+000+1.600000e+001i)"}, + {"string", `"test"`, "panic: test"}} { + + b := bytes.Buffer{} + fmt.Fprintf(&b, fn, tc.Type, tc.Input) + + err = ioutil.WriteFile(tmpFile, b.Bytes(), 0644) + if err != nil { + log.Fatal(err) + } + + cmd := exec.Command("go", "run", tmpFile) + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + cmd.Env = os.Environ() + cmd.Run() // ignore err as we expect a panic + + out := buf.Bytes() + panicIdx := bytes.Index(out, []byte("panic: ")) + if panicIdx == -1 { + log.Fatalf("expected a panic in output for %s, got: %s", tc.Type, out) + } + eolIdx := bytes.IndexByte(out[panicIdx:], '\n') + panicIdx + if panicIdx == -1 { + log.Fatalf("expected a newline in output for %s after the panic, got: %s", tc.Type, out) + } + out = out[0:eolIdx] + if string(out) != tc.Expect { + log.Fatalf("expected '%s' for panic(%s(%s)), got %s", tc.Expect, tc.Type, tc.Input, out) + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19667.go b/gcc/testsuite/go.test/test/fixedbugs/issue19667.go new file mode 100644 index 00000000000..e33e3504875 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19667.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 The Go 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 we don't crash when reporting this error. + +package p + +func f() { + if err := http.ListenAndServe( // GCCGO_ERROR "undefined name" +} // ERROR "unexpected }, expecting expression|expected operand|missing .*\)|expected .*;|expected .*{" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19671.go b/gcc/testsuite/go.test/test/fixedbugs/issue19671.go new file mode 100644 index 00000000000..475c3e0afc6 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19671.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2017 The Go 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 when compiling assignments involving [0]T, +// where T is not SSA-able. + +package a + +func f() { + var i int + arr := [0][2]int{} + arr[i][0] = 0 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19678.go b/gcc/testsuite/go.test/test/fixedbugs/issue19678.go new file mode 100644 index 00000000000..81ef331ee65 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19678.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2017 The Go 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 when compiling functions containing +// forward refs in dead code. + +package p + +var f func(int) + +func g() { +l1: + i := 0 + goto l1 +l2: + f(i) + goto l2 +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19679.go b/gcc/testsuite/go.test/test/fixedbugs/issue19679.go new file mode 100644 index 00000000000..636b27ffef8 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19679.go @@ -0,0 +1,38 @@ +// compile + +// Copyright 2017 The Go 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 when a type switch was present in dead code +// in an inlineable function. + +package p + +func Then() { + var i interface{} + if false { + switch i.(type) { + } + } +} + +func Else() { + var i interface{} + if true { + _ = i + } else { + switch i.(type) { + } + } +} + +func Switch() { + var i interface{} + switch 5 { + case 3: + switch i.(type) { + } + case 5: + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19696.go b/gcc/testsuite/go.test/test/fixedbugs/issue19696.go new file mode 100644 index 00000000000..4cb2789091c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19696.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2017 The Go 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 when compiling assignments involving [0]T, +// where T is not SSA-able. + +package p + +type s struct { + a, b, c, d, e int +} + +func f() { + var i int + arr := [0]s{} + arr[i].a++ +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19699b.go b/gcc/testsuite/go.test/test/fixedbugs/issue19699b.go new file mode 100644 index 00000000000..4afc0ca8330 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19699b.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2017 The Go 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() bool { + if false { + } else { + return true + } +} // ERROR "missing return at end of function" diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19705.go b/gcc/testsuite/go.test/test/fixedbugs/issue19705.go new file mode 100644 index 00000000000..6157945bbbc --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19705.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2017 The Go 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 f1() { + f2() +} + +func f2() { + if false { + _ = func() {} + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19710.go b/gcc/testsuite/go.test/test/fixedbugs/issue19710.go new file mode 100644 index 00000000000..c42ea7c2ced --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19710.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2017 The Go 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 19710: mishandled defer delete(...) + +package main + +func main() { + if n := len(f()); n != 0 { + println("got", n, "want 0") + panic("bad defer delete") + } +} + +func f() map[int]bool { + m := map[int]bool{} + for i := 0; i < 3; i++ { + m[i] = true + defer delete(m, i) + } + return m +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19743.go b/gcc/testsuite/go.test/test/fixedbugs/issue19743.go new file mode 100644 index 00000000000..5089cc61d82 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19743.go @@ -0,0 +1,31 @@ +// errorcheck -0 -m -l + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +// Escape analysis needs to treat the uintptr-typed reflect.*Header fields as pointers. + +import ( + "reflect" + "unsafe" +) + +type immutableBytes []byte + +// Bug was failure to leak param b. +func toString(b immutableBytes) string { // ERROR "leaking param: b$" + var s string + if len(b) == 0 { + return s + } + + strHeader := (*reflect.StringHeader)(unsafe.Pointer(&s)) + strHeader.Data = (*reflect.SliceHeader)(unsafe.Pointer(&b)).Data + + l := len(b) + strHeader.Len = l + return s +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/a.go b/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/a.go new file mode 100644 index 00000000000..64538e5bdf0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/a.go @@ -0,0 +1,15 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type T struct{ _ int } +func (t T) M() {} + +type I interface { M() } + +func F() { + var t I = &T{} + t.M() // call to the wrapper (*T).M +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/b.go b/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/b.go new file mode 100644 index 00000000000..d39f125f37c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19764.dir/b.go @@ -0,0 +1,13 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./a" + +func main() { + var x a.I = &a.T{} + x.M() // call to the wrapper (*T).M + a.F() // make sure a.F is not dead, which also calls (*T).M inside package a +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19764.go b/gcc/testsuite/go.test/test/fixedbugs/issue19764.go new file mode 100644 index 00000000000..26fb00be2d0 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19764.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2017 The Go 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 19764: test that the linker's trampoline insertion +// pass is happy with direct calls to interface wrappers that +// may be defined in multiple packages. +package ignore diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19783.go b/gcc/testsuite/go.test/test/fixedbugs/issue19783.go new file mode 100644 index 00000000000..8d6494eaa47 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19783.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2017 The Go 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 Spin() { +l1: + for true { + goto l1 + l2: + if true { + goto l2 + } + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19799.go b/gcc/testsuite/go.test/test/fixedbugs/issue19799.go new file mode 100644 index 00000000000..cb675d7b0d1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19799.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2017 The Go 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" + "runtime" +) + +func foo(x int) int { + return x + 1 +} + +func test() { + defer func() { + if r := recover(); r != nil { + pcs := make([]uintptr, 10) + n := runtime.Callers(0, pcs) + pcs = pcs[:n] + frames := runtime.CallersFrames(pcs) + for { + f, more := frames.Next() + if f.Function == "main.foo" { + println("did not expect to see call to foo in stack trace") + os.Exit(1) + } + if !more { + break + } + } + } + }() + var v []int + foo(v[0]) +} + +func bar(x ...int) int { + return x[0] + 1 +} + +func testVariadic() { + defer func() { + if r := recover(); r != nil { + pcs := make([]uintptr, 10) + n := runtime.Callers(0, pcs) + pcs = pcs[:n] + frames := runtime.CallersFrames(pcs) + for { + f, more := frames.Next() + if f.Function == "main.bar" { + println("did not expect to see call to bar in stack trace") + os.Exit(1) + } + if !more { + break + } + } + } + }() + var v []int + bar(v[0]) +} + +func main() { + test() + testVariadic() +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19880.go b/gcc/testsuite/go.test/test/fixedbugs/issue19880.go new file mode 100644 index 00000000000..3d83cf3a12c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19880.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 The Go 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 { + f [1]int +} + +func a() { + _ = T // ERROR "type T is not an expression|invalid use of type" +} + +func b() { + var v [len(T{}.f)]int // ok + _ = v +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19911.go b/gcc/testsuite/go.test/test/fixedbugs/issue19911.go new file mode 100644 index 00000000000..af7f59814e1 --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19911.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2017 The Go 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" + "strings" +) + +type ET struct{} + +func (*ET) Error() string { return "err" } + +func main() { + check("false", fmt.Sprintf("(*ET)(nil) == error(nil): %v", (*ET)(nil) == error(nil))) + check("true", fmt.Sprintf("(*ET)(nil) != error(nil): %v", (*ET)(nil) != error(nil))) + + nilET := (*ET)(nil) + nilError := error(nil) + + check("false", fmt.Sprintf("nilET == nilError: %v", nilET == nilError)) + check("true", fmt.Sprintf("nilET != nilError: %v", nilET != nilError)) +} + +func check(want, gotfull string) { + got := gotfull[strings.Index(gotfull, ": ")+len(": "):] + if got != want { + panic("want " + want + " got " + got + " from " + gotfull) + } +} diff --git a/gcc/testsuite/go.test/test/fixedbugs/issue19977.go b/gcc/testsuite/go.test/test/fixedbugs/issue19977.go new file mode 100644 index 00000000000..6e4a9cc422c --- /dev/null +++ b/gcc/testsuite/go.test/test/fixedbugs/issue19977.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2017 The Go 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 19977: multiple error messages when type switching on an undefined + +package foo + +func Foo() { + switch x := a.(type) { // ERROR "undefined: a|reference to undefined name .*a" + default: + _ = x + } +} -- 2.30.2