]> granicus.if.org Git - clang/commitdiff
Objective-C [qoi]: Provide improved parse diagnostics when
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Mar 2013 20:27:40 +0000 (20:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Mar 2013 20:27:40 +0000 (20:27 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177435 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseObjc.cpp
test/Parser/missing-closing-rbrace.m [new file with mode: 0644]

index 2656a8bb8bea5ce3a9d9c0ca5a0e468a6e4f6b9d..55afaa54552658d1933910f32eb119ef5817de63 100644 (file)
@@ -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<
index ddb6a707f561a0bc606e0077087d05b1e3fd62e9..b95b41f722d264c789c4c88a0b7c819a1f290e8b 100644 (file)
@@ -1288,6 +1288,10 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl,
         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;
diff --git a/test/Parser/missing-closing-rbrace.m b/test/Parser/missing-closing-rbrace.m
new file mode 100644 (file)
index 0000000..ae1291e
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: //6854840
+@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'}}