diff options
| author | Erik Verbruggen <erikjv@me.com> | 2011-12-06 09:25:23 +0000 |
|---|---|---|
| committer | Erik Verbruggen <erikjv@me.com> | 2011-12-06 09:25:23 +0000 |
| commit | c6c8d9356dc04afc149d3bab16c99ccefa2cbc5e (patch) | |
| tree | 86ac1194f34efe6109075ff1958c2a0202ed3d4c /clang/lib/Sema | |
| parent | 6572e0f2033dc950d1dafbc60365f7f5534dac32 (diff) | |
| download | bcm5719-llvm-c6c8d9356dc04afc149d3bab16c99ccefa2cbc5e.tar.gz bcm5719-llvm-c6c8d9356dc04afc149d3bab16c99ccefa2cbc5e.zip | |
Extend warnings for missing '@end'.
Fixes PR2709.
llvm-svn: 145928
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index afcf3cc63ae..b271ae66a10 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2148,15 +2148,39 @@ void Sema::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, } } +Sema::ObjCContainerKind Sema::getObjCContainerKind() const { + switch (CurContext->getDeclKind()) { + case Decl::ObjCInterface: + return Sema::OCK_Interface; + case Decl::ObjCProtocol: + return Sema::OCK_Protocol; + case Decl::ObjCCategory: + if (dyn_cast<ObjCCategoryDecl>(CurContext)->IsClassExtension()) + return Sema::OCK_ClassExtension; + else + return Sema::OCK_Category; + case Decl::ObjCImplementation: + return Sema::OCK_Implementation; + case Decl::ObjCCategoryImpl: + return Sema::OCK_CategoryImplementation; + + default: + return Sema::OCK_None; + } +} + // Note: For class/category implemenations, allMethods/allProperties is // always null. -void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, - Decl **allMethods, unsigned allNum, - Decl **allProperties, unsigned pNum, - DeclGroupPtrTy *allTUVars, unsigned tuvNum) { +Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, + Decl **allMethods, unsigned allNum, + Decl **allProperties, unsigned pNum, + DeclGroupPtrTy *allTUVars, unsigned tuvNum) { + + if (getObjCContainerKind() == Sema::OCK_None) + return 0; + + assert(AtEnd.isValid() && "Invalid location for '@end'"); - if (!CurContext->isObjCContainer()) - return; ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(CurContext); Decl *ClassDecl = cast<Decl>(OCD); @@ -2165,15 +2189,6 @@ void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, || isa<ObjCProtocolDecl>(ClassDecl); bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl); - if (!isInterfaceDeclKind && AtEnd.isInvalid()) { - // FIXME: This is wrong. We shouldn't be pretending that there is - // an '@end' in the declaration. - SourceLocation L = OCD->getAtStartLoc(); - AtEnd.setBegin(L); - AtEnd.setEnd(L); - Diag(L, diag::err_missing_atend); - } - // FIXME: Remove these and use the ObjCContainerDecl/DeclContext. llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap; llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap; @@ -2335,6 +2350,8 @@ void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, (*I)->setTopLevelDeclInObjCContainer(); Consumer.HandleTopLevelDeclInObjCContainer(DG); } + + return ClassDecl; } |

