From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33999 invoked by alias); 5 Jan 2019 08:50:32 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 33984 invoked by uid 89); 5 Jan 2019 08:50:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=segher, HCc:U*gcc, tabs, eight X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 05 Jan 2019 08:50:29 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x058oP3L016362; Sat, 5 Jan 2019 02:50:25 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x058oOKp016361; Sat, 5 Jan 2019 02:50:24 -0600 Date: Sat, 05 Jan 2019 08:50:00 -0000 From: Segher Boessenkool To: Daniel =?iso-8859-1?Q?Marjam=E4ki?= Cc: gcc@gcc.gnu.org Subject: Re: Improve syntax error Message-ID: <20190105085023.GJ14180@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00015.txt.bz2 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