re PR c++/13269 (compiler hangs on invalid code)
authorMark Mitchell <mark@codesourcery.com>
Tue, 16 Dec 2003 01:49:41 +0000 (01:49 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 16 Dec 2003 01:49:41 +0000 (01:49 +0000)
PR c++/13269
* parser.c (cp_parser_function_definition_after_declarator): Stop
scanning tokens when reaching EOF.

PR c++/13269
* g++.dg/parse/error5.C: New test.

From-SVN: r74661

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

index 43389e8cbe2240ef9dda78c8b7c92ad1b8816531..d00f67cc5ec183f4b01d90eea42e88d96c4cdf31 100644 (file)
@@ -1,5 +1,9 @@
 2003-12-15  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13269
+       * parser.c (cp_parser_function_definition_after_declarator): Stop
+       scanning tokens when reaching EOF.
+
        PR c++/12989
        * typeck.c (cxx_sizeof_or_alignof_expr): Robustify.
 
index a74e33a59e99bb88bf31440f530f1b5314bccc79..fd25aa2a7a942f7fd5363c62f55197f79f11978f 100644 (file)
@@ -13807,7 +13807,8 @@ cp_parser_function_definition_after_declarator (cp_parser* parser,
       /* Issue an error message.  */
       error ("named return values are no longer supported");
       /* Skip tokens until we reach the start of the function body.  */
-      while (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
+      while (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)
+            && cp_lexer_next_token_is_not (parser->lexer, CPP_EOF))
        cp_lexer_consume_token (parser->lexer);
     }
   /* The `extern' in `extern "C" void f () { ... }' does not apply to
index 83352dcfb70efab27513e79a99d447443964f86f..8862f109ff203d50a46d0bbf361da37b3ede24af 100644 (file)
@@ -1,5 +1,8 @@
 2003-12-15  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13269
+       * g++.dg/parse/error5.C: New test.
+
        PR c++/12989
        * g++.dg/expr/sizeof1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/parse/error5.C b/gcc/testsuite/g++.dg/parse/error5.C
new file mode 100644 (file)
index 0000000..81356ce
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/13269
+
+class Foo { int foo() return 0; } }; // { dg-error "" }
+