aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2022-04-19 13:46:15 -0700
committerRobert Griesemer <gri@golang.org>2022-04-19 23:20:21 +0000
commit104742fddae061b52c38e221697cf20ebd09bf10 (patch)
tree772c34b344b3f2e8c0c7e16c880bec284e1cd539 /test
parent302f5ed21dad2cb99f3f63fd99228dc3ab480772 (diff)
downloadgo-104742fddae061b52c38e221697cf20ebd09bf10.tar.gz
go-104742fddae061b52c38e221697cf20ebd09bf10.zip
cmd/compile/internal/types2: use correct value of iota
Fixes #52438. Change-Id: I5cbf8c448dba037e9e0c5fe8f209401d6bf7d43f Reviewed-on: https://go-review.googlesource.com/c/go/+/401134 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue52438.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/fixedbugs/issue52438.go b/test/fixedbugs/issue52438.go
new file mode 100644
index 00000000000..375e727ee30
--- /dev/null
+++ b/test/fixedbugs/issue52438.go
@@ -0,0 +1,39 @@
+// run
+
+// Copyright 2022 The Go 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 c1 = iota
+const c2 = iota
+
+const c3 = 0 + iota<<8
+const c4 = 1 + iota<<8
+
+func main() {
+ if c1 != 0 {
+ panic(c1)
+ }
+ if c2 != 0 {
+ panic(c2)
+ }
+
+ if c3 != 0 {
+ panic(c3)
+ }
+ if c4 != 1 {
+ panic(c4)
+ }
+
+ const c5 = iota
+ const c6 = iota
+
+ if c5 != 0 {
+ panic(c5)
+ }
+ if c6 != 0 {
+ panic(c6)
+ }
+}