public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Better error messages for merge-conflict markers (v3)
Date: Mon, 02 Nov 2015 22:52:00 -0000	[thread overview]
Message-ID: <5637E91D.4000506@redhat.com> (raw)
In-Reply-To: <1446218187-720-1-git-send-email-dmalcolm@redhat.com>

On 10/30/2015 09:16 AM, David Malcolm wrote:
> This is a rebased version of this patch from back in April:
>    v2: https://gcc.gnu.org/ml/gcc-patches/2015-04/msg00944.html
> which in turn is a rewrite of this one:
>    v1: https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01087.html
>
> The idea is to more gracefully handle merger conflict markers
> in the source code being compiled.  Specifically, in the C and
> C++ frontends, if we're about to emit an error, see if the
> source code is at a merger conflict marker, and if so, emit
> a more specific message, so that the user gets this:
>
> foo.c:1:1: error: source file contains patch conflict marker
>   <<<<<<< HEAD
>   ^
>
> rather than this gobbledegook:
>
> foo.c:1:1: error: expected identifier or '(' before '<<' token
>   <<<<<<< HEAD
>   ^
>
> It's something of a "fit and finish" cosmetic item, but these
> things add up.
>
> Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu;
> adds 82 new PASSes to g++.sum and 27 new PASSes to gcc.sum.
>
> OK for trunk?
>
> This implementation works by looking at the token stream, which
> is slightly clunky; an alternative way of doing it would be to directly
> look at the line the error occurs in and to see if it begins with a
> conflict marker.  Would that be preferable?
>
> gcc/c-family/ChangeLog:
> 	* c-common.h (conflict_marker_get_final_tok_kind): New prototype.
> 	* c-lex.c (conflict_marker_get_final_tok_kind): New function.
>
> gcc/c/ChangeLog:
> 	* c-parser.c (struct c_parser): Expand array "tokens_buf" from 2
> 	to 4.
> 	(c_parser_peek_nth_token): New function.
> 	(c_parser_peek_conflict_marker): New function.
> 	(c_parser_error): Detect patch conflict markers and report them as
> 	such.
>
> gcc/cp/ChangeLog:
> 	* parser.c (cp_lexer_peek_conflict_marker): New function.
> 	(cp_parser_error): Detect patch conflict markers and report them
> 	as such.
I'm still having a hard time seeing this one as all that useful.  It's 
not like it's terribly hard to see the <<<<<< HEAD and realize that 
there's a conflict marker mucking things up.

I'm willing to step aside if other folks thing this is really useful and 
want to review the changes.

jeff

  reply	other threads:[~2015-11-02 22:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 15:02 David Malcolm
2015-11-02 22:52 ` Jeff Law [this message]
2015-11-03  4:05   ` Trevor Saunders
2015-11-04 13:56 ` Bernd Schmidt
2015-12-09 16:39   ` [PATCH] Better error recovery for merge-conflict markers (v4) David Malcolm
2015-12-09 17:44     ` Bernd Schmidt
2015-12-09 20:18       ` Jeff Law
2015-12-16 18:23       ` David Malcolm
2015-12-15 19:11   ` [PATCH] Better error recovery for merge-conflict markers (v5) David Malcolm
2015-12-15 23:52     ` Bernd Schmidt
2015-12-16 18:33       ` David Malcolm
2015-12-09 23:50 ` [PATCH] Better error messages for merge-conflict markers (v3) Martin Sebor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5637E91D.4000506@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).