Thanks!

I will take care of the indentation and fix the comment.

> I think the indentation warnings should catch that?

I get this:

void f()
{
  }
} // <- error: expected identifier or '(' before '}' token

I ran with -Wall -Wextra -pedantic and did not see a indentation
warning. Am I missing some indentation warning? The error message I
get is a little misplaced. I think it's fine to warn about that } but
it could also say in the error message that the problem is probably
the previous }

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

No none of those suggestions will solve the error.

Look at this code:

    int x = 3) + 0;

Writing a ) or , or ; will not fix the syntax error. You have to
remove the ) or add a ( somewhere.



Den lör 5 jan. 2019 kl 09:50 skrev Segher Boessenkool
<seg...@kernel.crashing.org>:
>
> 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 via email to