public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Schmidt <bschmidt@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>,
	gcc-patches@gcc.gnu.org,
	       Joseph Myers <joseph@codesourcery.com>,
	       Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH] Better error messages for merge-conflict markers (v3)
Date: Wed, 04 Nov 2015 13:56:00 -0000	[thread overview]
Message-ID: <563A0E7D.3070804@redhat.com> (raw)
In-Reply-To: <1446218187-720-1-git-send-email-dmalcolm@redhat.com>

On 10/30/2015 04:16 PM, David Malcolm wrote:
> 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
>   ^
>
> It's something of a "fit and finish" cosmetic item, but these
> things add up.

This seems like fairly low impact but also low cost, so I'm fine with it 
in principle. I wonder whether the length of the marker is the same 
across all versions of patch (and VC tools)?

> +static bool
> +c_parser_peek_conflict_marker (c_parser *parser, enum cpp_ttype tok1_kind)
> +{
> +  c_token *token2 = c_parser_peek_2nd_token (parser);
> +  if (token2->type != tok1_kind)
> +    return false;
> +  c_token *token3 = c_parser_peek_nth_token (parser, 3);
> +  if (token3->type != tok1_kind)
> +    return false;
> +  c_token *token4 = c_parser_peek_nth_token (parser, 4);
> +  if (token4->type != conflict_marker_get_final_tok_kind (tok1_kind))
> +    return false;
> +  return true;
> +}

Just thinking out loud - I guess it would be too much to hope for to 
share lexers between frontends so that we need only one copy of this?

> +extern short some_var; /* this line would lead to a warning */

Would or does? I don't see anything suppressing it?

There seems to be no testcase verifying what happens if the marker is 
not at the start of the line (IMO it should not be interpreted as a marker).

It would be good to have buy-in from the frontend maintainers (Joseph 
commented on v1 and as far as I can see you've addressed his feedback). 
If you do not hear back from them by the end of the week, I'll approve 
it if the start-of-line thing is sorted.


Bernd

  parent reply	other threads:[~2015-11-04 13:56 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
2015-11-03  4:05   ` Trevor Saunders
2015-11-04 13:56 ` Bernd Schmidt [this message]
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=563A0E7D.3070804@redhat.com \
    --to=bschmidt@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    /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).