[cfe-commits] r96479 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/stand-alone-implementation.m

Fariborz Jahanian fjahanian at apple.com
Wed Feb 17 09:00:08 PST 2010


Author: fjahanian
Date: Wed Feb 17 11:00:07 2010
New Revision: 96479

URL: http://llvm.org/viewvc/llvm-project?rev=96479&view=rev
Log:
Allow for declaration and use of ivars in a stand-alone
implementation (toward radar 7547942).


Added:
    cfe/trunk/test/SemaObjC/stand-alone-implementation.m
Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=96479&r1=96478&r2=96479&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Feb 17 11:00:07 2010
@@ -823,6 +823,12 @@
   if (IDecl->isImplicitInterfaceDecl()) {
     IDecl->setIVarList(ivars, numIvars, Context);
     IDecl->setLocEnd(RBrace);
+    // Add ivar's to class's DeclContext.
+    for (unsigned i = 0, e = numIvars; i != e; ++i) {
+      ivars[i]->setLexicalDeclContext(IDecl);
+      IDecl->addDecl(ivars[i]);
+    }
+    
     return;
   }
   // If implementation has empty ivar list, just return.

Added: cfe/trunk/test/SemaObjC/stand-alone-implementation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/stand-alone-implementation.m?rev=96479&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/stand-alone-implementation.m (added)
+++ cfe/trunk/test/SemaObjC/stand-alone-implementation.m Wed Feb 17 11:00:07 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// radar 7547942
+// Allow injection of ivars into implementation's implicit class.
+
+ at implementation INTFSTANDALONE // expected-warning {{cannot find interface declaration for 'INTFSTANDALONE'}}
+{
+  id IVAR1;
+  id IVAR2;
+}
+- (id) Meth { return IVAR1; }
+ at end
+





More information about the cfe-commits mailing list