gcc/cp/ChangeLog:
* parser.c (cp_parser_error_1): After issuing a conflict marker
error, consume tokens until the end of the source line.
gcc/testsuite/ChangeLog:
* g++.dg/conflict-markers-2.C: New test.
From-SVN: r262232
+2018-06-28 David Malcolm <dmalcolm@redhat.com>
+
+ * parser.c (cp_parser_error_1): After issuing a conflict marker
+ error, consume tokens until the end of the source line.
+
2018-06-28 Jason Merrill <jason@redhat.com>
PR c++/86342 - -Wdeprecated-copy and system headers.
if (cp_lexer_peek_conflict_marker (parser->lexer, token->type, &loc))
{
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)
+ {
+ cp_lexer_consume_token (parser->lexer);
+ cp_token *next = cp_lexer_peek_token (parser->lexer);
+ if (next == NULL)
+ break;
+ expanded_location next_exploc = expand_location (next->location);
+ if (next_exploc.file != token_exploc.file)
+ break;
+ if (next_exploc.line != token_exploc.line)
+ break;
+ }
return;
}
}
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+extern void f1 (void);
+extern void f2 (void);
+extern void f3 (void);
+extern void f4 (void);
+
+void test ()
+{
+ f1 ();
+<<<<<<< HEAD // { dg-error "conflict marker" }
+ f2 ();
+======= // { dg-error "conflict marker" }
+ f3 ();
+>>>>>>> 252be53... Some commit message // { dg-error "conflict marker" }
+ f4 ();
+}