From def88a88c4a6096e2204ca9b2776f1ef00b762b8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini <paolo.carlini@oracle.com> Date: Mon, 2 Feb 2009 00:41:52 +0000 Subject: [PATCH] re PR c++/39053 (ICE with broken function declaration) /cp 2009-02-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/39053 * parser.c (cp_parser_pure_specifier): If there are no tokens left do not call cp_lexer_consume_token. /testsuite 2009-02-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/39053 * g++.dg/parse/crash52.C: New. From-SVN: r143861 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 8 +++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/crash52.C | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/crash52.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f48474cfe3ab..eeec03d466fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-02-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/39053 + * parser.c (cp_parser_pure_specifier): If there are no tokens left + do not call cp_lexer_consume_token. + 2009-01-30 Jakub Jelinek <jakub@redhat.com> PR c++/39028 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5be231881550..5675e9bca12a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15997,7 +15997,13 @@ cp_parser_pure_specifier (cp_parser* parser) if (!cp_parser_require (parser, CPP_EQ, "%<=%>")) return error_mark_node; /* Look for the `0' token. */ - token = cp_lexer_consume_token (parser->lexer); + token = cp_lexer_peek_token (parser->lexer); + + if (token->type == CPP_EOF + || token->type == CPP_PRAGMA_EOL) + return error_mark_node; + + cp_lexer_consume_token (parser->lexer); /* Accept = default or = delete in c++0x mode. */ if (token->keyword == RID_DEFAULT diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02244e51b5db..d5040061715f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-02-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/39053 + * g++.dg/parse/crash52.C: New. + 2009-01-30 Richard Guenther <rguenther@suse.de> PR tree-optimization/39041 diff --git a/gcc/testsuite/g++.dg/parse/crash52.C b/gcc/testsuite/g++.dg/parse/crash52.C new file mode 100644 index 000000000000..bc7f03c8d972 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash52.C @@ -0,0 +1,3 @@ +// PR c++/39053 + +void foo() = // { dg-error "initialized|expected" } -- GitLab