diff mbox series

Go patch committed: Improve error messages for expected curly brace

Message ID CAOyqgcXaTfUEHT7C-zQ3KyySjmGtzsOMkE=4a3FtWgiyMFhWdQ@mail.gmail.com
State New
Headers show
Series Go patch committed: Improve error messages for expected curly brace | expand

Commit Message

Ian Lance Taylor Nov. 30, 2020, 8:14 p.m. UTC
This Go frontend patch improves the error messages for an expected
curly brace.  This is for https://golang.org/issue/17328.  This
requires updating some tests to the current sources in the main repo.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
5ba975e6680cc5f9c2be7ee34b1cacdba3eb3347
diff mbox series

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e2fc0b5560b..41246030f13 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-213abeedc85ed638a878f9457e422897fda3a111
+45461eeba1db1a3b4194dc8ecc331c0e92f5ad4c
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 1dac0029feb..c9a5485049f 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -4422,7 +4422,7 @@  Parse::if_stat()
     {
       Location semi_loc = this->location();
       if (this->advance_token()->is_op(OPERATOR_LCURLY))
-	go_error_at(semi_loc, "missing %<{%> after if clause");
+	go_error_at(semi_loc, "unexpected semicolon or newline, expecting %<{%> after if clause");
       // Otherwise we will get an error when we call this->block
       // below.
     }
@@ -5359,7 +5359,7 @@  Parse::for_stat(Label* label)
     {
       Location semi_loc = this->location();
       if (this->advance_token()->is_op(OPERATOR_LCURLY))
-	go_error_at(semi_loc, "missing %<{%> after for clause");
+	go_error_at(semi_loc, "unexpected semicolon or newline, expecting %<{%> after for clause");
       // Otherwise we will get an error when we call this->block
       // below.
     }
@@ -5430,7 +5430,7 @@  Parse::for_clause(Expression** cond, Block** post)
     *cond = NULL;
   else if (this->peek_token()->is_op(OPERATOR_LCURLY))
     {
-      go_error_at(this->location(), "missing %<{%> after for clause");
+      go_error_at(this->location(), "unexpected semicolon or newline, expecting %<{%> after for clause");
       *cond = NULL;
       *post = NULL;
       return;
diff --git a/gcc/testsuite/go.test/test/syntax/semi1.go b/gcc/testsuite/go.test/test/syntax/semi1.go
index 6e0428121ff..8eed05c1ca1 100644
--- a/gcc/testsuite/go.test/test/syntax/semi1.go
+++ b/gcc/testsuite/go.test/test/syntax/semi1.go
@@ -1,13 +1,13 @@ 
 // errorcheck
 
-// Copyright 2010 The Go Authors.  All rights reserved.
+// 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 "missing .*{.* after if clause|undefined"
+	if x; y		// ERROR "expected .*{.* after if clause|undefined"
 	{
 		z	// GCCGO_ERROR "undefined"
 
diff --git a/gcc/testsuite/go.test/test/syntax/semi3.go b/gcc/testsuite/go.test/test/syntax/semi3.go
index ca070d8a577..d064ce631c9 100644
--- a/gcc/testsuite/go.test/test/syntax/semi3.go
+++ b/gcc/testsuite/go.test/test/syntax/semi3.go
@@ -1,13 +1,13 @@ 
 // errorcheck
 
-// Copyright 2010 The Go Authors.  All rights reserved.
+// 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 "missing .*{.* after for clause|undefined"
+	for x; y; z	// ERROR "expected .*{.* after for clause|undefined"
 	{
 		z	// GCCGO_ERROR "undefined"
 
diff --git a/gcc/testsuite/go.test/test/syntax/semi4.go b/gcc/testsuite/go.test/test/syntax/semi4.go
index 99c2d22561b..08c354751b6 100644
--- a/gcc/testsuite/go.test/test/syntax/semi4.go
+++ b/gcc/testsuite/go.test/test/syntax/semi4.go
@@ -1,6 +1,6 @@ 
 // errorcheck
 
-// Copyright 2010 The Go Authors.  All rights reserved.
+// 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.
 
@@ -8,7 +8,5 @@  package main
 
 func main() {
 	for x		// GCCGO_ERROR "undefined"
-	{		// ERROR "missing .*{.* after for clause"
+	{		// ERROR "unexpected {, expecting for loop condition|expecting .*{.* after for clause"
 		z	// GCCGO_ERROR "undefined"
-
-