This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 13269


This patch fixes a thinko in the error-recovery code for named return
values in the new C++ parser.

Applied as obvious on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

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.

2003-12-15  Mark Mitchell  <mark@codesourcery.com>

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

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.132
diff -c -5 -p -r1.132 parser.c
*** cp/parser.c	15 Dec 2003 16:59:46 -0000	1.132
--- cp/parser.c	16 Dec 2003 01:46:14 -0000
*************** cp_parser_function_definition_after_decl
*** 13805,13815 ****
  	 returned.  */
        cp_parser_identifier (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))
  	cp_lexer_consume_token (parser->lexer);
      }
    /* The `extern' in `extern "C" void f () { ... }' does not apply to
       anything declared inside `f'.  */
    saved_in_unbraced_linkage_specification_p 
--- 13805,13816 ----
  	 returned.  */
        cp_parser_identifier (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)
! 	     && 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
       anything declared inside `f'.  */
    saved_in_unbraced_linkage_specification_p 
Index: testsuite/g++.dg/parse/error5.C
===================================================================
RCS file: testsuite/g++.dg/parse/error5.C
diff -N testsuite/g++.dg/parse/error5.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/error5.C	16 Dec 2003 01:46:21 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/13269
+ 
+ class Foo { int foo() return 0; } }; // { dg-error "" }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]