From 20912d644a5eddcdf130e1ade03e884c19774978 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 17 Feb 2010 17:00:07 +0000 Subject: [PATCH] Allow for declaration and use of ivars in a stand-alone implementation (toward radar 7547942). llvm-svn: 96479 --- clang/lib/Sema/SemaDeclObjC.cpp | 6 ++++++ clang/test/SemaObjC/stand-alone-implementation.m | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 clang/test/SemaObjC/stand-alone-implementation.m diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 1e9b56a90ed6..465c4a9ee187 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -823,6 +823,12 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, 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. diff --git a/clang/test/SemaObjC/stand-alone-implementation.m b/clang/test/SemaObjC/stand-alone-implementation.m new file mode 100644 index 000000000000..c33b66a37bc3 --- /dev/null +++ b/clang/test/SemaObjC/stand-alone-implementation.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// radar 7547942 +// Allow injection of ivars into implementation's implicit class. + +@implementation INTFSTANDALONE // expected-warning {{cannot find interface declaration for 'INTFSTANDALONE'}} +{ + id IVAR1; + id IVAR2; +} +- (id) Meth { return IVAR1; } +@end +