[cfe-commits] [PATCH] Bug 6484 - Improve diagnostics for dangling '}'

Dmitri Gribenko gribozavr at gmail.com
Sun Jan 15 08:08:24 PST 2012


On Sun, Jan 15, 2012 at 5:55 PM, Jason Switzer <jswitzer at gmail.com> wrote:
> Attached is a patch for bug 6464
> (http://llvm.org/bugs/show_bug.cgi?id=6484). This adds to the existing
> error message to indicate there may be a stray/extraneous closing
> brace ('}'). It also updates the 2 test cases I found (all tests
> pass).

A nice idea, but the implementation is not really correct.  Please
take a look at Parser::ParseExternalDeclaration in
llvm/tools/clan/lib/Parse/Parser.cpp:
err_expected_external_declaration is emitted in three cases, and only
one is the case of extra brace.  For example,
$ cat > a.c
+
$ clang a.c
a.c:1:1: error: expected external declaration
+
^
1 error generated.

So I think you should add other (new) error message and change the
relevant case in Parser.cpp.

Dmitri Gribenko

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/




More information about the cfe-commits mailing list