summaryrefslogtreecommitdiff
path: root/gcc/testsuite/go.test/test/switch.go
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-12 15:23:33 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-12 15:23:33 +0000
commit9456798d72d0e81a2a553287f436dcb05cff175a (patch)
tree1e80106d0c4f828b72deb6e782c20d788c0dd818 /gcc/testsuite/go.test/test/switch.go
parente89aee4174fe58eaba553027558144a0f423960c (diff)
downloadgcc-9456798d72d0e81a2a553287f436dcb05cff175a.tar.gz
[./]
2013-11-12 Basile Starynkevitch <basile@starynkevitch.net> {{merge with trunk GCC 4.9 svn rev 204695; previous trunk merge was 202773; very unstable...}} [gcc/] 2013-11-11 Basile Starynkevitch <basile@starynkevitch.net> {{merge with trunk GCC 4.9 svn rev 204695; very unstable}} * melt-runtime.h (MELT_VERSION_STRING): Bump to "1.0.1+". * melt-run.proto.h: Update copyright years. include tree-cfg.h instead of tree-flow.h for GCC 4.9. * melt-runtime.cc: Include tree-cfg.h not tree-flow.h for GCC 4.9. (meltgc_walk_gimple_seq): Fatal error with GCC 4.9 since the walk_use_def_chains function disappeared from GCC... * melt/xtramelt-ana-gimple.melt (walk_gimple_seq) (walk_gimple_seq_unique_tree): issue some #warning-s for GCC 4.9 because walk_use_def_chains function disappeared from GCC... * melt/xtramelt-probe.melt (probe_docmd): Issue an error since currently the MELT probe is not usable with GCC 4.9.... git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@204705 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/go.test/test/switch.go')
-rw-r--r--gcc/testsuite/go.test/test/switch.go79
1 files changed, 72 insertions, 7 deletions
diff --git a/gcc/testsuite/go.test/test/switch.go b/gcc/testsuite/go.test/test/switch.go
index fd8748b9bce..5e1d85bb687 100644
--- a/gcc/testsuite/go.test/test/switch.go
+++ b/gcc/testsuite/go.test/test/switch.go
@@ -305,11 +305,40 @@ func main() {
assert(false, "i should be true")
}
+ // switch on interface with constant cases differing by type.
+ // was rejected by compiler: see issue 4781
+ type T int
+ type B bool
+ type F float64
+ type S string
+ switch i := interface{}(float64(1.0)); i {
+ case nil:
+ assert(false, "i should be float64(1.0)")
+ case (*int)(nil):
+ assert(false, "i should be float64(1.0)")
+ case 1:
+ assert(false, "i should be float64(1.0)")
+ case T(1):
+ assert(false, "i should be float64(1.0)")
+ case F(1.0):
+ assert(false, "i should be float64(1.0)")
+ case 1.0:
+ assert(true, "true")
+ case "hello":
+ assert(false, "i should be float64(1.0)")
+ case S("hello"):
+ assert(false, "i should be float64(1.0)")
+ case true, B(false):
+ assert(false, "i should be float64(1.0)")
+ case false, B(true):
+ assert(false, "i should be float64(1.0)")
+ }
+
// switch on array.
switch ar := [3]int{1, 2, 3}; ar {
- case [3]int{1,2,3}:
+ case [3]int{1, 2, 3}:
assert(true, "[1 2 3]")
- case [3]int{4,5,6}:
+ case [3]int{4, 5, 6}:
assert(false, "ar should be [1 2 3]")
default:
assert(false, "ar should be [1 2 3]")
@@ -327,12 +356,48 @@ func main() {
assert(false, "c1 did not match itself")
}
+ // empty switch
+ switch {
+ }
+
+ // empty switch with default case.
+ fired = false
+ switch {
+ default:
+ fired = true
+ }
+ assert(fired, "fail")
+
+ // Default and fallthrough.
+ count = 0
+ switch {
+ default:
+ count++
+ fallthrough
+ case false:
+ count++
+ }
+ assert(count == 2, "fail")
+
+ // fallthrough to default, which is not at end.
+ count = 0
+ switch i5 {
+ case 5:
+ count++
+ fallthrough
+ default:
+ count++
+ case 6:
+ count++
+ }
+ assert(count == 2, "fail")
+
i := 0
switch x := 5; {
- case i < x:
- os.Exit(0)
- case i == x:
- case i > x:
- os.Exit(1)
+ case i < x:
+ os.Exit(0)
+ case i == x:
+ case i > x:
+ os.Exit(1)
}
}