summaryrefslogtreecommitdiff
path: root/gcc/testsuite/go.go-torture/execute
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/go.go-torture/execute
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/go.go-torture/execute')
-rw-r--r--gcc/testsuite/go.go-torture/execute/array-1.go10
-rw-r--r--gcc/testsuite/go.go-torture/execute/array-2.go19
-rw-r--r--gcc/testsuite/go.go-torture/execute/chan-1.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/const-1.go6
-rw-r--r--gcc/testsuite/go.go-torture/execute/const-2.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/execute.exp33
-rw-r--r--gcc/testsuite/go.go-torture/execute/expr-1.go11
-rw-r--r--gcc/testsuite/go.go-torture/execute/for-1.go9
-rw-r--r--gcc/testsuite/go.go-torture/execute/for-2.go52
-rw-r--r--gcc/testsuite/go.go-torture/execute/function-1.go9
-rw-r--r--gcc/testsuite/go.go-torture/execute/function-2.go9
-rw-r--r--gcc/testsuite/go.go-torture/execute/go-1.go11
-rw-r--r--gcc/testsuite/go.go-torture/execute/go-2.go11
-rw-r--r--gcc/testsuite/go.go-torture/execute/go-3.go14
-rw-r--r--gcc/testsuite/go.go-torture/execute/goto-1.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/map-1.go46
-rw-r--r--gcc/testsuite/go.go-torture/execute/method-1.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/nested-1.go4
-rw-r--r--gcc/testsuite/go.go-torture/execute/pointer-1.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/return-1.go4
-rw-r--r--gcc/testsuite/go.go-torture/execute/return-2.go18
-rw-r--r--gcc/testsuite/go.go-torture/execute/return-3.go16
-rw-r--r--gcc/testsuite/go.go-torture/execute/select-1.go28
-rw-r--r--gcc/testsuite/go.go-torture/execute/string-1.go15
-rw-r--r--gcc/testsuite/go.go-torture/execute/string-2.go16
-rw-r--r--gcc/testsuite/go.go-torture/execute/struct-1.go8
-rw-r--r--gcc/testsuite/go.go-torture/execute/struct-2.go7
-rw-r--r--gcc/testsuite/go.go-torture/execute/switch-1.go68
-rw-r--r--gcc/testsuite/go.go-torture/execute/var-1.go6
-rw-r--r--gcc/testsuite/go.go-torture/execute/var-2.go6
-rw-r--r--gcc/testsuite/go.go-torture/execute/var-3.go6
31 files changed, 477 insertions, 0 deletions
diff --git a/gcc/testsuite/go.go-torture/execute/array-1.go b/gcc/testsuite/go.go-torture/execute/array-1.go
new file mode 100644
index 000000000..7b34eca19
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/array-1.go
@@ -0,0 +1,10 @@
+package main
+var a [2]int;
+func fn() {
+ a[0] = 1;
+ a[1] = 1;
+}
+func main() {
+ fn();
+ if a[0] != a[1] { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/array-2.go b/gcc/testsuite/go.go-torture/execute/array-2.go
new file mode 100644
index 000000000..516a131e4
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/array-2.go
@@ -0,0 +1,19 @@
+package main
+
+func fn(a []int) int {
+ alen := len(a);
+ for i := 0; i < alen; i++ {
+ a[i] = i
+ }
+ return alen;
+}
+
+func main() {
+ var a [2]int;
+ if fn(a[0:]) != 2 {
+ panic(0);
+ }
+ if a[0] != 0 || a[1] != 1 {
+ panic(1);
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/chan-1.go b/gcc/testsuite/go.go-torture/execute/chan-1.go
new file mode 100644
index 000000000..c3d4ddb11
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/chan-1.go
@@ -0,0 +1,7 @@
+package main
+
+func main() {
+ c := make(chan int, 1);
+ c <- 0;
+ if <-c != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/const-1.go b/gcc/testsuite/go.go-torture/execute/const-1.go
new file mode 100644
index 000000000..2292692ea
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/const-1.go
@@ -0,0 +1,6 @@
+package main
+
+func main() {
+ const c = 2;
+ if c != 2 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/const-2.go b/gcc/testsuite/go.go-torture/execute/const-2.go
new file mode 100644
index 000000000..a7301a5c5
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/const-2.go
@@ -0,0 +1,7 @@
+package main
+
+const c = 3;
+
+func main() {
+ if c != 3 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/execute.exp b/gcc/testsuite/go.go-torture/execute/execute.exp
new file mode 100644
index 000000000..350d75114
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/execute.exp
@@ -0,0 +1,33 @@
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This is based on a file written by Rob Savoye (rob@cygnus.com) and
+# Jeffrey Wheat (cassidy@cygnus.com).
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib go-torture.exp
+
+foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.go]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $testcase] then {
+ continue
+ }
+ go-torture-execute $testcase
+}
diff --git a/gcc/testsuite/go.go-torture/execute/expr-1.go b/gcc/testsuite/go.go-torture/execute/expr-1.go
new file mode 100644
index 000000000..076388a6e
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/expr-1.go
@@ -0,0 +1,11 @@
+package main
+
+func main() {
+ var v1 = 1;
+ var v2 = 1;
+ var v3 = (v1 + v2) / (v1 + v2);
+ var v4 = (v3 * v3) % (v3 * v3);
+ if v4 != 0 {
+ panic(0)
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/for-1.go b/gcc/testsuite/go.go-torture/execute/for-1.go
new file mode 100644
index 000000000..7aa91f004
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/for-1.go
@@ -0,0 +1,9 @@
+package main
+
+func main() {
+ sum := 0;
+ for i := 0; i < 10; i++ {
+ sum += i;
+ }
+ if sum != 45 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/for-2.go b/gcc/testsuite/go.go-torture/execute/for-2.go
new file mode 100644
index 000000000..af790edf8
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/for-2.go
@@ -0,0 +1,52 @@
+package main
+
+func f1() {
+ j := 0;
+ for i := 0; i < 10; i++ {
+ if i > 2 {
+ break;
+ }
+ j = i;
+ }
+ if (j != 2) {
+ panic(0);
+ }
+}
+
+func f2() {
+ for i := 0; i < 10; i++ {
+ if i >= 0 {
+ continue;
+ }
+ panic(1);
+ }
+}
+
+func f3() {
+ lab1:
+ for i := 0; i < 10; i++ {
+ for j := 0; j < 10; j++ {
+ if j > 2 {
+ break lab1;
+ }
+ }
+ panic(2);
+ }
+}
+
+func f4() {
+ lab1:
+ for i := 0; i < 10; i++ {
+ for j := 0; j < 10; j++ {
+ continue lab1;
+ }
+ panic(3);
+ }
+}
+
+func main() {
+ f1();
+ f2();
+ f3();
+ f4()
+}
diff --git a/gcc/testsuite/go.go-torture/execute/function-1.go b/gcc/testsuite/go.go-torture/execute/function-1.go
new file mode 100644
index 000000000..06244ac15
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/function-1.go
@@ -0,0 +1,9 @@
+package main
+
+func subr() int {
+ return 0
+}
+
+func main() {
+ if subr() != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/function-2.go b/gcc/testsuite/go.go-torture/execute/function-2.go
new file mode 100644
index 000000000..8b9aa878e
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/function-2.go
@@ -0,0 +1,9 @@
+package main
+
+func subr(p int) int {
+ return p
+}
+
+func main() {
+ if subr(0) != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/go-1.go b/gcc/testsuite/go.go-torture/execute/go-1.go
new file mode 100644
index 000000000..7d9dbd469
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/go-1.go
@@ -0,0 +1,11 @@
+package main
+
+func send_one(c chan <- int) {
+ c <- 0;
+}
+
+func main() {
+ c := make(chan int);
+ go send_one(c);
+ if <-c != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/go-2.go b/gcc/testsuite/go.go-torture/execute/go-2.go
new file mode 100644
index 000000000..8ce5fc879
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/go-2.go
@@ -0,0 +1,11 @@
+package main
+
+func send_one(c chan <- int, val int) {
+ c <- val;
+}
+
+func main() {
+ c := make(chan int);
+ go send_one(c, 0);
+ if <-c != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/go-3.go b/gcc/testsuite/go.go-torture/execute/go-3.go
new file mode 100644
index 000000000..af8fa385e
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/go-3.go
@@ -0,0 +1,14 @@
+package main
+
+type I interface { send(chan <- int) }
+
+type S struct { v int }
+func (p *S) send(c chan <- int) { c <- p.v }
+
+func main() {
+ s := S{0};
+ var i I = &s;
+ c := make(chan int);
+ go i.send(c);
+ if <- c != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/goto-1.go b/gcc/testsuite/go.go-torture/execute/goto-1.go
new file mode 100644
index 000000000..0a10c2ef2
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/goto-1.go
@@ -0,0 +1,7 @@
+package main
+
+func main() {
+ goto lab;
+ panic(0);
+ lab:
+}
diff --git a/gcc/testsuite/go.go-torture/execute/map-1.go b/gcc/testsuite/go.go-torture/execute/map-1.go
new file mode 100644
index 000000000..8307c6c98
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/map-1.go
@@ -0,0 +1,46 @@
+package main
+
+func main() {
+ v := make(map[int] int);
+ v[0] = 0;
+ v[1000000] = 1;
+ if v[0] != 0 {
+ panic(1)
+ }
+ val, present := v[0];
+ if !present || val != 0 {
+ panic(2)
+ }
+ val = 5;
+ val, present = v[1];
+ if present || val != 0 {
+ panic(3);
+ }
+ if v[2] != 0 {
+ panic(4)
+ }
+ val, present = v[2];
+ if present {
+ panic(5)
+ }
+ if len(v) != 2 {
+ panic(6)
+ }
+ v[0] = 0, false;
+ if len(v) != 1 {
+ panic(7)
+ }
+
+ w := make(map[string] string);
+ if len(w) != 0 {
+ panic(8)
+ }
+ w["Hello"] = "world";
+ w["Goodbye"] = "sweet prince";
+ if w["Hello"] != "world" {
+ panic(9)
+ }
+ if w["Hej"] != "" {
+ panic(10)
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/method-1.go b/gcc/testsuite/go.go-torture/execute/method-1.go
new file mode 100644
index 000000000..e4c17c174
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/method-1.go
@@ -0,0 +1,7 @@
+package main
+type s struct { i int };
+func (v *s) val() int { return v.i }
+func main() {
+ p := new(s);
+ if p.val() != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/nested-1.go b/gcc/testsuite/go.go-torture/execute/nested-1.go
new file mode 100644
index 000000000..cbd96f23a
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/nested-1.go
@@ -0,0 +1,4 @@
+package main
+func main() {
+ if func (i int) int { return i} (0) != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/pointer-1.go b/gcc/testsuite/go.go-torture/execute/pointer-1.go
new file mode 100644
index 000000000..f6b30a1a0
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/pointer-1.go
@@ -0,0 +1,7 @@
+package main
+
+func main() {
+ p := new(int);
+ *p = 0;
+ if *p != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/return-1.go b/gcc/testsuite/go.go-torture/execute/return-1.go
new file mode 100644
index 000000000..da29a2cad
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/return-1.go
@@ -0,0 +1,4 @@
+package main
+
+func main() {
+}
diff --git a/gcc/testsuite/go.go-torture/execute/return-2.go b/gcc/testsuite/go.go-torture/execute/return-2.go
new file mode 100644
index 000000000..08b2e61a0
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/return-2.go
@@ -0,0 +1,18 @@
+package main
+
+func fn() (i, j int) {
+ i = 1;
+ j = 2;
+ return;
+}
+
+func main() {
+ var i, j = fn();
+ var ret int;
+ if i == 1 && j == 2 {
+ ret = 0;
+ } else {
+ ret = 1;
+ }
+ if ret != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/return-3.go b/gcc/testsuite/go.go-torture/execute/return-3.go
new file mode 100644
index 000000000..f7fe09c42
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/return-3.go
@@ -0,0 +1,16 @@
+package main
+
+func fn() (i, j int) {
+ return 1, 2
+}
+
+func main() {
+ var i, j = fn();
+ var ret int;
+ if i == 1 && j == 2 {
+ ret = 0;
+ } else {
+ ret = 1;
+ }
+ if ret != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/select-1.go b/gcc/testsuite/go.go-torture/execute/select-1.go
new file mode 100644
index 000000000..8fc6963be
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/select-1.go
@@ -0,0 +1,28 @@
+package main
+
+func main() {
+ ch1 := make(chan int);
+ ch2 := make(chan int);
+ go func (ch1, ch2 chan int) { ch1 <- 1; ch2 <- 2; } (ch1, ch2);
+ count := 0;
+ var v int;
+ for count != 2 {
+ select
+ {
+ case v := <- ch1:
+ if v != 1 {
+ panic(0)
+ }
+ count++
+
+ case v = <- ch2:
+ if v != 2 {
+ panic(1)
+ }
+ count++
+ }
+ }
+ if v != 2 {
+ panic(2)
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/string-1.go b/gcc/testsuite/go.go-torture/execute/string-1.go
new file mode 100644
index 000000000..f999d8752
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/string-1.go
@@ -0,0 +1,15 @@
+package main
+
+func fn(s string) int {
+ if s[0] != 'a' || s[1] != 'b' || s[2] != 'c' {
+ panic(0);
+ }
+ return len(s);
+}
+
+func main() {
+ s := "abc";
+ if fn(s) != 3 {
+ panic(1);
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/string-2.go b/gcc/testsuite/go.go-torture/execute/string-2.go
new file mode 100644
index 000000000..72b0f2334
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/string-2.go
@@ -0,0 +1,16 @@
+package main
+
+func fn(s string) string {
+ if len(s) != 3 {
+ panic(0)
+ }
+ i := len(s) - 1;
+ return s + s[0 : i];
+}
+
+func main() {
+ s := fn("abc");
+ if s != "abcab" {
+ panic(1)
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/struct-1.go b/gcc/testsuite/go.go-torture/execute/struct-1.go
new file mode 100644
index 000000000..edf38b2bf
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/struct-1.go
@@ -0,0 +1,8 @@
+package main
+
+func main() {
+ type s struct { x int; };
+ var ret s;
+ ret.x = 1;
+ if ret.x != 1 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/struct-2.go b/gcc/testsuite/go.go-torture/execute/struct-2.go
new file mode 100644
index 000000000..cc01f6b9c
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/struct-2.go
@@ -0,0 +1,7 @@
+package main
+
+func main() {
+ type s struct { x int; y int; };
+ var ret s = s{1, 2};
+ if ret.y - (ret.x + ret.x) != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/switch-1.go b/gcc/testsuite/go.go-torture/execute/switch-1.go
new file mode 100644
index 000000000..fdc93ce60
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/switch-1.go
@@ -0,0 +1,68 @@
+package main
+
+func f1(i int) bool {
+ switch j := i; j {
+ case 3: fallthrough
+ case 1: return true
+ case 2: return false
+ default: return false
+ case 4: return true
+ }
+}
+
+func f2(i int) int {
+ switch {
+ case i < 0: return -1
+ case i > 0: return 1
+ default: return 0
+ case i != 0: return 1000
+ }
+ panic(0)
+}
+
+func f3(i int) int {
+ lab:
+ switch i {
+ case 1: break
+ case 2: return 2
+ case 3, 4:
+ switch i {
+ case 3: break lab
+ case 4: break
+ }
+ return 4
+ }
+ return 1
+}
+
+func main() {
+ if !f1(1) {
+ panic(1);
+ }
+ if f1(2) {
+ panic(2);
+ }
+ if !f1(3) {
+ panic(3);
+ }
+ if !f1(4) {
+ panic(4);
+ }
+ if f1(5) {
+ panic(5);
+ }
+
+ if f2(-100) != -1 {
+ panic(6);
+ }
+ if f2(1000) != 1 {
+ panic(7);
+ }
+ if f2(0) != 0 {
+ panic(8);
+ }
+
+ if f3(1) != 1 || f3(2) != 2 || f3(3) != 1 || f3(4) != 4 {
+ panic(9);
+ }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/var-1.go b/gcc/testsuite/go.go-torture/execute/var-1.go
new file mode 100644
index 000000000..d4b20b6c0
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/var-1.go
@@ -0,0 +1,6 @@
+package main
+
+func main() {
+ var ret = 0;
+ if ret != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/var-2.go b/gcc/testsuite/go.go-torture/execute/var-2.go
new file mode 100644
index 000000000..dd0ec4ee3
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/var-2.go
@@ -0,0 +1,6 @@
+package main
+
+func main() {
+ var ret int;
+ if ret != 0 { panic(0) }
+}
diff --git a/gcc/testsuite/go.go-torture/execute/var-3.go b/gcc/testsuite/go.go-torture/execute/var-3.go
new file mode 100644
index 000000000..80b10041a
--- /dev/null
+++ b/gcc/testsuite/go.go-torture/execute/var-3.go
@@ -0,0 +1,6 @@
+package main
+
+func main() {
+ ret := 0;
+ if ret != 0 { panic(0) }
+}