This patch to the Go frontend gives a better error message when the
condition is omitted from an if statement. Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r a05deef47b01 go/parse.cc
--- a/go/parse.cc Mon Mar 28 15:48:35 2011 -0700
+++ b/go/parse.cc Mon Mar 28 15:52:15 2011 -0700
@@ -3779,6 +3779,12 @@
if (!this->expression_may_start_here())
cond = Expression::make_error(this->location());
}
+ if (cond == NULL && this->peek_token()->is_op(OPERATOR_LCURLY))
+ {
+ error_at(this->location(),
+ "missing condition in if statement");
+ cond = Expression::make_error(this->location());
+ }
if (cond == NULL)
cond = this->expression(PRECEDENCE_NORMAL, false, false, NULL);
}