re PR c++/69793 (ICE on invalid code in "cp_lexer_peek_nth_token")
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 18 May 2016 16:26:35 +0000 (16:26 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 18 May 2016 16:26:35 +0000 (16:26 +0000)
/cp
2016-05-18  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/69793
* g++.dg/template/crash122.C: New.

From-SVN: r236414

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

index 4dc67551c851c149164d900e7a630630aa937e17..f459e50474baf6d04099092b1f2174075da8b627 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <paolo.carlini@oracle.com>
 
        PR c++/70466
index 539f16540634745411d21ede786eefb6aa512e69..3abba12fd3ee1e379bc6fe41152c03fa010473a3 100644 (file)
@@ -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);
index e06f7e4734a6f0764164b30e8833e0dc21a1317a..0434803c5995007c957d9b561e37bb95df2d90e8 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/69793
+       * g++.dg/template/crash122.C: New.
+
 2016-05-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        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 (file)
index 0000000..028aec3
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/69793
+
+class fpos;
+template < state > bool operator!= (fpos,; operator!= // { dg-error "declared|expected|type" }