public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: "Daniel Marjamäki" <daniel.marjamaki@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Improve syntax error
Date: Sat, 05 Jan 2019 08:50:00 -0000	[thread overview]
Message-ID: <20190105085023.GJ14180@gate.crashing.org> (raw)
In-Reply-To: <CAMabPZS3dX=s8vhoqK3zkLG+muc8XGEcWgs-tUs0x5sCBNmKGQ@mail.gmail.com>

Hi Daniel,

Some mostly boring comments:

On Fri, Jan 04, 2019 at 09:25:10PM +0100, Daniel Marjamäki wrote:
> The first reason is the hard problem, but maybe we can ignore this now also:
> 
> void f()
> {
>     }  // <- looking at the indentation, it seems preferable to warn about this
> }

I think the indentation warnings should catch that?

> diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
> index 972b629c092..eabc5ffa15e 100644
> --- a/gcc/c/c-parser.c
> +++ b/gcc/c/c-parser.c
> @@ -171,6 +171,8 @@ struct GTY(()) c_parser {
>    /* How many look-ahead tokens are available (0 - 4, or
>       more if parsing from pre-lexed tokens).  */
>    unsigned int tokens_avail;
> +  /* nesting depth in expression (parentheses / squares) */

Start sentences with a capital, and end with full stop space space.  I
realise this isn't a full sentence, but the comment right above does this
as well ;-)

> @@ -763,6 +765,22 @@ c_parser_next_tokens_start_declaration (c_parser *parser)
>    return false;
>  }
> 
> +/* Nesting start token */
> +
> +static bool c_parser_is_nesting_start (c_parser *parser)
> +{
> +    return c_parser_next_token_is (parser, CPP_OPEN_PAREN) ||
> +           c_parser_next_token_is (parser, CPP_OPEN_SQUARE);

Indents should use tabs for every leading eight spaces.

> @@ -2228,7 +2264,10 @@ c_parser_declaration_or_fndef (c_parser
> *parser, bool fndef_ok,
>          }
>        else
>          {
> -          c_parser_error (parser, "expected %<,%> or %<;%>");
> +          if (c_parser_unmatched_p (parser))
> +            complain_about_unmatched_token (parser);

Should this say something like "expected ) or , or ;"?

> +          else
> +            c_parser_error (parser, "expected %<,%> or %<;%>");
>            c_parser_skip_to_end_of_block_or_statement (parser);
>            return;
>          }


Segher

  reply	other threads:[~2019-01-05  8:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 20:25 Daniel Marjamäki
2019-01-05  8:50 ` Segher Boessenkool [this message]
2019-01-05 17:02   ` Daniel Marjamäki
2019-01-05 19:44     ` Daniel Marjamäki
2019-01-08 20:29       ` Daniel Marjamäki
2019-01-08 20:44         ` Joseph Myers
2019-01-10 10:39     ` Segher Boessenkool

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=20190105085023.GJ14180@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=daniel.marjamaki@gmail.com \
    --cc=gcc@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).