C++: less verbose error-recovery for version conflict markers
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
This commit is contained in:
parent
b8be145128
commit
eacb16dc79
3 changed files with 36 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
|
@ -2862,6 +2862,20 @@ cp_parser_error_1 (cp_parser* parser, const char* gmsgid,
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
17
gcc/testsuite/g++.dg/conflict-markers-2.C
Normal file
17
gcc/testsuite/g++.dg/conflict-markers-2.C
Normal file
|
@ -0,0 +1,17 @@
|
|||
// { 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 ();
|
||||
}
|
Loading…
Add table
Reference in a new issue