From: Paolo Carlini Date: Wed, 18 May 2016 16:26:35 +0000 (+0000) Subject: re PR c++/69793 (ICE on invalid code in "cp_lexer_peek_nth_token") X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c584aca60cbface2621ebf1ccc943df1b7af52ca;p=gcc.git re PR c++/69793 (ICE on invalid code in "cp_lexer_peek_nth_token") /cp 2016-05-18 Paolo Carlini PR c++/69793 * parser.c (cp_parser_template_id): Don't call cp_lexer_peek_nth_token when the previous cp_lexer_peek_token returns CPP_EOF. /testsuite 2016-05-18 Paolo Carlini PR c++/69793 * g++.dg/template/crash122.C: New. From-SVN: r236414 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4dc67551c85..f459e50474b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-05-18 Paolo Carlini + + PR c++/69793 + * parser.c (cp_parser_template_id): Don't call cp_lexer_peek_nth_token + when the previous cp_lexer_peek_token returns CPP_EOF. + 2016-05-18 Paolo Carlini PR c++/70466 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 539f1654063..3abba12fd3e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14835,11 +14835,11 @@ cp_parser_template_id (cp_parser *parser, /* If we find the sequence `[:' after a template-name, it's probably a digraph-typo for `< ::'. Substitute the tokens and check if we can parse correctly the argument list. */ - next_token = cp_lexer_peek_token (parser->lexer); - next_token_2 = cp_lexer_peek_nth_token (parser->lexer, 2); - if (next_token->type == CPP_OPEN_SQUARE + if (((next_token = cp_lexer_peek_token (parser->lexer))->type + == CPP_OPEN_SQUARE) && next_token->flags & DIGRAPH - && next_token_2->type == CPP_COLON + && ((next_token_2 = cp_lexer_peek_nth_token (parser->lexer, 2))->type + == CPP_COLON) && !(next_token_2->flags & PREV_WHITE)) { cp_parser_parse_tentatively (parser); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e06f7e4734a..0434803c599 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-18 Paolo Carlini + + PR c++/69793 + * g++.dg/template/crash122.C: New. + 2016-05-18 Paolo Carlini PR c++/70466 diff --git a/gcc/testsuite/g++.dg/template/crash122.C b/gcc/testsuite/g++.dg/template/crash122.C new file mode 100644 index 00000000000..028aec3e414 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash122.C @@ -0,0 +1,4 @@ +// PR c++/69793 + +class fpos; +template < state > bool operator!= (fpos,; operator!= // { dg-error "declared|expected|type" }