PR c++/23440
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Oct 2005 22:22:30 +0000 (22:22 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Oct 2005 22:22:30 +0000 (22:22 +0000)
* parser.c (cp_parser_statement): If the parser reached CPP_EOF,
only complain about missing statement.

* g++.dg/parse/for1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105520 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/for1.C [new file with mode: 0644]

index 08344ee..6223540 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23440
+       * parser.c (cp_parser_statement): If the parser reached CPP_EOF,
+       only complain about missing statement.
+
 2005-10-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/24386
index 45fc69f..300c266 100644 (file)
@@ -6087,6 +6087,11 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr)
       cp_lexer_handle_pragma (parser->lexer);
       return;
     }
+  else if (token->type == CPP_EOF)
+    {
+      cp_parser_error (parser, "expected statement");
+      return;
+    }
 
   /* Everything else must be a declaration-statement or an
      expression-statement.  Try for the declaration-statement
index 5e1d0af..0815420 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/23440
+       * g++.dg/parse/for1.C: New test.
+
 2005-10-17  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/23446
diff --git a/gcc/testsuite/g++.dg/parse/for1.C b/gcc/testsuite/g++.dg/parse/for1.C
new file mode 100644 (file)
index 0000000..1e310ee
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/23440
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+// { dg-options "" }
+
+# 0 "for1.C"
+void foo() { for (;;)  // { dg-error "at end of input" "" { target *-*-* } 0 }