This small patch improves the handling of one case of unexpected EOF in
the Go frontend parser.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 5a1ab3177e67 go/parse.cc
--- a/go/parse.cc	Wed Sep 21 13:20:32 2011 -0700
+++ b/go/parse.cc	Wed Sep 21 14:05:15 2011 -0700
@@ -1299,6 +1299,13 @@
 void
 Parse::decl(void (Parse::*pfn)(void*), void* varg)
 {
+  if (this->peek_token()->is_eof())
+    {
+      if (!saw_errors())
+	error_at(this->location(), "unexpected end of file");
+      return;
+    }
+
   if (!this->peek_token()->is_op(OPERATOR_LPAREN))
     (this->*pfn)(varg);
   else

Reply via email to