r177435 - Objective-C [qoi]: Provide improved parse diagnostics when

Fariborz Jahanian fjahanian at apple.com
Tue Mar 19 13:27:40 PDT 2013


Author: fjahanian
Date: Tue Mar 19 15:27:40 2013
New Revision: 177435

URL: http://llvm.org/viewvc/llvm-project?rev=177435&view=rev
Log:
Objective-C [qoi]: Provide improved parse diagnostics when
closing rbrace is missing in an ObjC class declaration.
Can do beter than this, but it involves addition of
overhead which will be present in correct code.
// rdar://6854840

Added:
    cfe/trunk/test/Parser/missing-closing-rbrace.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=177435&r1=177434&r2=177435&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Mar 19 15:27:40 2013
@@ -406,6 +406,8 @@ def err_missing_catch_finally : Error<
 def err_objc_concat_string : Error<"unexpected token after Objective-C string">;
 def err_expected_objc_container : Error<
   "'@end' must appear in an Objective-C context">;
+def err_objc_unexpected_atend : Error<
+  "'@end' appears where closing brace '}' is expected">;
 def error_property_ivar_decl : Error<
   "property synthesize requires specification of an ivar">;
 def err_synthesized_property_name : Error<

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=177435&r1=177434&r2=177435&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Mar 19 15:27:40 2013
@@ -1288,6 +1288,10 @@ void Parser::ParseObjCClassInstanceVaria
         visibility = Tok.getObjCKeywordID();
         ConsumeToken();
         continue;
+      case tok::objc_end:
+        Diag(Tok, diag::err_objc_unexpected_atend);
+        ConsumeToken();
+        continue;
       default:
         Diag(Tok, diag::err_objc_illegal_visibility_spec);
         continue;

Added: cfe/trunk/test/Parser/missing-closing-rbrace.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/missing-closing-rbrace.m?rev=177435&view=auto
==============================================================================
--- cfe/trunk/test/Parser/missing-closing-rbrace.m (added)
+++ cfe/trunk/test/Parser/missing-closing-rbrace.m Tue Mar 19 15:27:40 2013
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: //6854840
+ at interface A {@end // expected-error {{'@end' appears where closing brace '}' is expected}}\
+                   // expected-note {{to match this '{'}}\
+                   // expected-note {{class started here}}
+		   // expected-error {{expected '}'}} expected-error {{missing '@end'}}





More information about the cfe-commits mailing list