[cfe-commits] r146147 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Parser/missing-end-4.m

Erik Verbruggen erikjv at me.com
Thu Dec 8 01:58:43 PST 2011


Author: erikjv
Date: Thu Dec  8 03:58:43 2011
New Revision: 146147

URL: http://llvm.org/viewvc/llvm-project?rev=146147&view=rev
Log:
Fix: allow @protocol forward declarations inside @implementation-s.

Added:
    cfe/trunk/test/Parser/missing-end-4.m
Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=146147&r1=146146&r2=146147&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Dec  8 03:58:43 2011
@@ -1343,7 +1343,6 @@
                                              ParsedAttributes &attrs) {
   assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
          "ParseObjCAtProtocolDeclaration(): Expected @protocol");
-  CheckNestedObjCContexts(AtLoc);
   ConsumeToken(); // the "protocol" identifier
 
   if (Tok.is(tok::code_completion)) {
@@ -1367,6 +1366,8 @@
                                                    attrs.getList());
   }
 
+  CheckNestedObjCContexts(AtLoc);
+
   if (Tok.is(tok::comma)) { // list of forward declarations.
     SmallVector<IdentifierLocPair, 8> ProtocolRefs;
     ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));

Added: cfe/trunk/test/Parser/missing-end-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/missing-end-4.m?rev=146147&view=auto
==============================================================================
--- cfe/trunk/test/Parser/missing-end-4.m (added)
+++ cfe/trunk/test/Parser/missing-end-4.m Thu Dec  8 03:58:43 2011
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface X1
+ at end
+ at implementation X1 // expected-note {{implementation started here}}
+ at interface Y1 // expected-error {{missing '@end'}}
+ at end
+ at end // expected-error {{'@end' must appear in an Objective-C context}}
+
+ at interface X2
+ at end
+ at implementation X2 // expected-note {{implementation started here}}
+ at protocol Y2 // expected-error {{missing '@end'}}
+ at end
+ at end // expected-error {{'@end' must appear in an Objective-C context}}
+
+ at interface X6 // expected-note {{class started here}}
+ at interface X7 // expected-error {{missing '@end'}}
+ at end
+ at end // expected-error {{'@end' must appear in an Objective-C context}}
+
+ at protocol P1 // expected-note {{protocol started here}}
+ at interface P2 // expected-error {{missing '@end'}}
+ at end
+ at end // expected-error {{'@end' must appear in an Objective-C context}}
+
+ at interface X4 // expected-note {{class started here}}
+ at implementation X4 // expected-error {{missing '@end'}}
+ at end
+ at end // expected-error {{'@end' must appear in an Objective-C context}}
+
+ at interface I
+ at end
+ at implementation I
+ at protocol P; // forward declarations of protocols in @implementations is allowed
+ at class C; // forward declarations of classes in @implementations is allowed
+- (C<P>*) MyMeth {}
+ at end
+
+ at interface I2 {}
+ at protocol P2; // expected-error {{illegal interface qualifier}}
+ at class C2; // expected-error {{illegal interface qualifier}}
+ at end
+
+ at interface I3
+ at end
+ at implementation I3
+- Meth {}
++ Cls {}
+ at protocol P3;
+ at end





More information about the cfe-commits mailing list