compiler: improve error messages for expected curly brace
For golang/go#17328
Change-Id: Id0c153e76de2db5d15e768823d67646a4bde0e23
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273890
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/go/parse.cc b/go/parse.cc
index 1dac002..c9a5485 100644
--- a/go/parse.cc
+++ b/go/parse.cc
@@ -4422,7 +4422,7 @@
{
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 @@
{
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 @@
*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;