summaryrefslogtreecommitdiffstats
path: root/test/syntax
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
commit43a123c1ae6613b3efeed291fa552ecd909d3acf (patch)
treefd92518b7024bc74031f78a1cf9e454b65e73665 /test/syntax
parentInitial commit. (diff)
downloadgolang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.tar.xz
golang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.zip
Adding upstream version 1.20.14.upstream/1.20.14upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/syntax')
-rw-r--r--test/syntax/chan.go17
-rw-r--r--test/syntax/chan1.go17
-rw-r--r--test/syntax/composite.go11
-rw-r--r--test/syntax/ddd.go11
-rw-r--r--test/syntax/else.go12
-rw-r--r--test/syntax/if.go18
-rw-r--r--test/syntax/import.go14
-rw-r--r--test/syntax/initvar.go15
-rw-r--r--test/syntax/semi1.go14
-rw-r--r--test/syntax/semi2.go14
-rw-r--r--test/syntax/semi3.go14
-rw-r--r--test/syntax/semi4.go12
-rw-r--r--test/syntax/semi5.go13
-rw-r--r--test/syntax/semi6.go11
-rw-r--r--test/syntax/semi7.go14
-rw-r--r--test/syntax/topexpr.go20
-rw-r--r--test/syntax/typesw.go13
-rw-r--r--test/syntax/vareq.go10
-rw-r--r--test/syntax/vareq1.go10
19 files changed, 260 insertions, 0 deletions
diff --git a/test/syntax/chan.go b/test/syntax/chan.go
new file mode 100644
index 0000000..6f9d77d
--- /dev/null
+++ b/test/syntax/chan.go
@@ -0,0 +1,17 @@
+// 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 main
+
+type xyz struct {
+ ch chan
+} // ERROR "unexpected .*}.* in channel type|missing channel element type"
+
+func Foo(y chan) { // ERROR "unexpected .*\).* in channel type|missing channel element type"
+}
+
+func Bar(x chan, y int) { // ERROR "unexpected comma in channel type|missing channel element type"
+}
diff --git a/test/syntax/chan1.go b/test/syntax/chan1.go
new file mode 100644
index 0000000..88a5b47
--- /dev/null
+++ b/test/syntax/chan1.go
@@ -0,0 +1,17 @@
+// 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 main
+
+var c chan int
+var v int
+
+func main() {
+ if c <- v { // ERROR "cannot use c <- v as value|send statement used as value"
+ }
+}
+
+var _ = c <- v // ERROR "unexpected <-|send statement used as value"
diff --git a/test/syntax/composite.go b/test/syntax/composite.go
new file mode 100644
index 0000000..b4e03f3
--- /dev/null
+++ b/test/syntax/composite.go
@@ -0,0 +1,11 @@
+// errorcheck
+
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var a = []int{
+ 3 // ERROR "need trailing comma before newline in composite literal|possibly missing comma or }"
+}
diff --git a/test/syntax/ddd.go b/test/syntax/ddd.go
new file mode 100644
index 0000000..8d1e4d1
--- /dev/null
+++ b/test/syntax/ddd.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 main
+
+func f() {
+ g(f..3) // ERROR "unexpected literal \.3, expected name or \("
+}
diff --git a/test/syntax/else.go b/test/syntax/else.go
new file mode 100644
index 0000000..9537329
--- /dev/null
+++ b/test/syntax/else.go
@@ -0,0 +1,12 @@
+// errorcheck
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+ if true {
+ } else ; // ERROR "else must be followed by if or statement block|expected .if. or .{."
+}
diff --git a/test/syntax/if.go b/test/syntax/if.go
new file mode 100644
index 0000000..c208a9f
--- /dev/null
+++ b/test/syntax/if.go
@@ -0,0 +1,18 @@
+// errorcheck
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func x() {
+}
+
+func main() {
+ if { // ERROR "missing condition"
+ }
+
+ if x(); { // ERROR "missing condition"
+ }
+}
diff --git a/test/syntax/import.go b/test/syntax/import.go
new file mode 100644
index 0000000..8010bed
--- /dev/null
+++ b/test/syntax/import.go
@@ -0,0 +1,14 @@
+// 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 main
+
+import (
+ "io", // ERROR "unexpected comma"
+ "os"
+)
+
+
diff --git a/test/syntax/initvar.go b/test/syntax/initvar.go
new file mode 100644
index 0000000..74623f5
--- /dev/null
+++ b/test/syntax/initvar.go
@@ -0,0 +1,15 @@
+// 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 main
+
+func main() {
+ if var x = 0; x < 10 {} // ERROR "var declaration not allowed in if initializer"
+
+ switch var x = 0; x {} // ERROR "var declaration not allowed in switch initializer"
+
+ for var x = 0; x < 10; {} // ERROR "var declaration not allowed in for initializer"
+}
diff --git a/test/syntax/semi1.go b/test/syntax/semi1.go
new file mode 100644
index 0000000..8eed05c
--- /dev/null
+++ b/test/syntax/semi1.go
@@ -0,0 +1,14 @@
+// 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 main
+
+func main() {
+ if x; y // ERROR "expected .*{.* after if clause|undefined"
+ {
+ z // GCCGO_ERROR "undefined"
+
+
diff --git a/test/syntax/semi2.go b/test/syntax/semi2.go
new file mode 100644
index 0000000..9216789
--- /dev/null
+++ b/test/syntax/semi2.go
@@ -0,0 +1,14 @@
+// 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 main
+
+func main() {
+ switch x; y // ERROR "missing .*{.* after switch clause|undefined"
+ {
+ z
+
+
diff --git a/test/syntax/semi3.go b/test/syntax/semi3.go
new file mode 100644
index 0000000..d064ce6
--- /dev/null
+++ b/test/syntax/semi3.go
@@ -0,0 +1,14 @@
+// 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 main
+
+func main() {
+ for x; y; z // ERROR "expected .*{.* after for clause|undefined"
+ {
+ z // GCCGO_ERROR "undefined"
+
+
diff --git a/test/syntax/semi4.go b/test/syntax/semi4.go
new file mode 100644
index 0000000..62a511e
--- /dev/null
+++ b/test/syntax/semi4.go
@@ -0,0 +1,12 @@
+// 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 main
+
+func main() {
+ for x // GCCGO_ERROR "undefined"
+ { // ERROR "unexpected {, expected for loop condition|expecting .*{.* after for clause"
+ z // GCCGO_ERROR "undefined"
diff --git a/test/syntax/semi5.go b/test/syntax/semi5.go
new file mode 100644
index 0000000..c54a994
--- /dev/null
+++ b/test/syntax/semi5.go
@@ -0,0 +1,13 @@
+// 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 main
+
+func main()
+{ // ERROR "unexpected semicolon or newline before .?{.?"
+
+
+
diff --git a/test/syntax/semi6.go b/test/syntax/semi6.go
new file mode 100644
index 0000000..9bc730d
--- /dev/null
+++ b/test/syntax/semi6.go
@@ -0,0 +1,11 @@
+// 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 main
+
+type T1 // ERROR "newline in type declaration"
+
+type T2 /* // ERROR "(semicolon.*|EOF) in type declaration" */ \ No newline at end of file
diff --git a/test/syntax/semi7.go b/test/syntax/semi7.go
new file mode 100644
index 0000000..a1948b0
--- /dev/null
+++ b/test/syntax/semi7.go
@@ -0,0 +1,14 @@
+// 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 main
+
+func main() {
+ if x { } // GCCGO_ERROR "undefined"
+ else { } // ERROR "unexpected semicolon or newline before .?else.?|unexpected else"
+}
+
+
diff --git a/test/syntax/topexpr.go b/test/syntax/topexpr.go
new file mode 100644
index 0000000..be080d2
--- /dev/null
+++ b/test/syntax/topexpr.go
@@ -0,0 +1,20 @@
+// 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 main
+
+fmt.Printf("hello") // ERROR "non-declaration statement outside function body|expected declaration"
+
+func main() {
+}
+
+x++ // ERROR "non-declaration statement outside function body|expected declaration"
+
+func init() {
+}
+
+x,y := 1, 2 // ERROR "non-declaration statement outside function body|expected declaration"
+
diff --git a/test/syntax/typesw.go b/test/syntax/typesw.go
new file mode 100644
index 0000000..3781933
--- /dev/null
+++ b/test/syntax/typesw.go
@@ -0,0 +1,13 @@
+// errorcheck
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+ switch main() := interface{}(nil).(type) { // ERROR "invalid variable name|cannot use .* as value"
+ default:
+ }
+}
diff --git a/test/syntax/vareq.go b/test/syntax/vareq.go
new file mode 100644
index 0000000..0d4bb78
--- /dev/null
+++ b/test/syntax/vareq.go
@@ -0,0 +1,10 @@
+// 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 main
+
+func main() {
+ var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|expected ';' or '}' or newline"
diff --git a/test/syntax/vareq1.go b/test/syntax/vareq1.go
new file mode 100644
index 0000000..a2f9f34
--- /dev/null
+++ b/test/syntax/vareq1.go
@@ -0,0 +1,10 @@
+// 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 main
+
+var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|unexpected { after top level declaration|expected ';' or newline after top level declaration"
+