>
> On Sun, Jan 15, 2012 at 10:08 AM, Dmitri Gribenko <[email protected]>wrote:
>
>> 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.
>
>
Taking your advice, I made a new error (err_extraneous_closing_brace) in
include/clang/Basic/DiagnosticParseKinds.td, switched the first case in
lib/Parse/Parser.cpp to using the new error, and updated the test cases
(again, all tests pass).

- Jason "s1n" Switzer
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp	(revision 148209)
+++ lib/Parse/Parser.cpp	(working copy)
@@ -552,7 +552,7 @@
     // TODO: Invoke action for top-level semicolon.
     return DeclGroupPtrTy();
   case tok::r_brace:
-    Diag(Tok, diag::err_expected_external_declaration);
+    Diag(Tok, diag::err_extraneous_closing_brace);
     ConsumeBrace();
     return DeclGroupPtrTy();
   case tok::eof:
Index: test/Parser/recovery.c
===================================================================
--- test/Parser/recovery.c	(revision 148209)
+++ test/Parser/recovery.c	(working copy)
@@ -16,7 +16,7 @@
 
 
 // PR3172
-} // expected-error {{expected external declaration}}
+} // expected-error {{extraneous closing brace ('}')}}
 
 
 // rdar://6094870
Index: test/Parser/objc-quirks.m
===================================================================
--- test/Parser/objc-quirks.m	(revision 148209)
+++ test/Parser/objc-quirks.m	(working copy)
@@ -7,7 +7,7 @@
 // rdar://6480479
 @interface A // expected-note {{class started here}}
 }; // expected-error {{missing '@end'}} \
-// expected-error {{expected external declaration}} \
+// expected-error {{extraneous closing brace ('}')}} \
 // expected-warning{{extra ';' outside of a function}}
 
 
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td	(revision 148209)
+++ include/clang/Basic/DiagnosticParseKinds.td	(working copy)
@@ -119,6 +119,7 @@
 def err_expected_expression : Error<"expected expression">;
 def err_expected_type : Error<"expected a type">;
 def err_expected_external_declaration : Error<"expected external declaration">;
+def err_extraneous_closing_brace : Error<"extraneous closing brace ('}')">;
 def err_expected_ident : Error<"expected identifier">;
 def err_expected_ident_lparen : Error<"expected identifier or '('">;
 def err_expected_ident_lbrace : Error<"expected identifier or '{'">;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to