From 3fd4f9242d9b7d2032126dc4851b4fdf5628dc35 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 5 Nov 2019 16:59:41 +0000 Subject: [PATCH] [PR c++/92370] ICE with VC marker https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00323.html cp/ PR c++/92370 * parser.c (cp_parser_error_1): Check EOF and UNKNOWN_LOCATION when skipping over version control marker. testsuite/ PR c++/92370 * g++.dg/pr92370.C: New. From-SVN: r277853 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 8 ++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr92370.C | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr92370.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2bc6037037c..4d9d56755f3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-11-05 Nathan Sidwell + + PR c++/92370 + * parser.c (cp_parser_error_1): Check EOF and UNKNOWN_LOCATION + when skipping over version control marker. + 2019-11-05 Jakub Jelinek PR c++/92343 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3ed282fd4b2..bce7161a086 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2890,12 +2890,16 @@ cp_parser_error_1 (cp_parser* parser, const char* gmsgid, error_at (loc, "version control conflict marker in file"); expanded_location token_exploc = expand_location (token->location); /* Consume tokens until the end of the source line. */ - while (1) + for (;;) { cp_lexer_consume_token (parser->lexer); cp_token *next = cp_lexer_peek_token (parser->lexer); - if (next == NULL) + if (next->type == CPP_EOF) break; + if (next->location == UNKNOWN_LOCATION + || loc == UNKNOWN_LOCATION) + break; + expanded_location next_exploc = expand_location (next->location); if (next_exploc.file != token_exploc.file) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 248d1807746..37c446913c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-05 Nathan Sidwell + + PR c++/92370 + * g++.dg/pr92370.C: New. + 2019-11-04 Martin Sebor PR middle-end/92341 diff --git a/gcc/testsuite/g++.dg/pr92370.C b/gcc/testsuite/g++.dg/pr92370.C new file mode 100644 index 00000000000..8f0019a884e --- /dev/null +++ b/gcc/testsuite/g++.dg/pr92370.C @@ -0,0 +1,3 @@ +// PR 92370 ICE with conlict marker + +<<<<<<<>>>>>>> // { dg-error "conflict marker" }