]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/parser: don't crash after unexpected token
authorRobert Griesemer <gri@golang.org>
Mon, 13 Feb 2017 17:22:46 +0000 (09:22 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 13 Feb 2017 18:03:43 +0000 (18:03 +0000)
Added missing nil-check. We will get rid of the gcCompat corrections
shortly but it's still worthwhile having the new test case added.

Fixes #19056.

Change-Id: I35bd938a4d789058da15724e34c05e5e631ecad0
Reviewed-on: https://go-review.googlesource.com/36908
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/syntax/parser.go
test/fixedbugs/issue19056.go [new file with mode: 0644]

index a11be9717c763ab411390f7950f02cfff7643e76..79d6c8c14dd3047ad81db9be37137a486a7afd7c 100644 (file)
@@ -799,7 +799,7 @@ loop:
                                p.syntax_error("expecting name or (")
                                p.advance(_Semi, _Rparen)
                        }
-                       if gcCompat {
+                       if gcCompat && x != nil {
                                x.init(p)
                        }
 
diff --git a/test/fixedbugs/issue19056.go b/test/fixedbugs/issue19056.go
new file mode 100644 (file)
index 0000000..e4e8d07
--- /dev/null
@@ -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 ..."