OSDN Git Service

Better handling of unexpected EOF in parser.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Sep 2011 21:06:42 +0000 (21:06 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Sep 2011 21:06:42 +0000 (21:06 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179060 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/parse.cc

index b91bfbd..d914beb 100644 (file)
@@ -1299,6 +1299,13 @@ Parse::declaration_may_start_here()
 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