OSDN Git Service

PR c++/13269
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Dec 2003 01:49:41 +0000 (01:49 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Dec 2003 01:49:41 +0000 (01:49 +0000)
* parser.c (cp_parser_function_definition_after_declarator): Stop
scanning tokens when reaching EOF.

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

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

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

index 43389e8..d00f67c 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 a74e33a..fd25aa2 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 83352dc..8862f10 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 "" }
+