diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-10-08 16:07:03 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-10-08 16:07:03 +0000 |
commit | 0332b6c83856d24cd1bbf734322843fcc83fa379 (patch) | |
tree | 6a09ba46d78127bbc1091baf73e4fcec208e083a | |
parent | 13afd24bed2dc6d8f731b3919ef2e1c22ceca9c4 (diff) |
Return NULL on invalid protocol.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42754 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaDecl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 0b812cdd48..574f1f6166 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1065,11 +1065,14 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S, ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); ObjcCategoryDecl *CDecl = new ObjcCategoryDecl(AtInterfaceLoc, NumProtoRefs, CategoryName); + bool err = false; CDecl->setClassInterface(IDecl); /// Check that class of this category is already completely declared. - if (!IDecl || IDecl->isForwardDecl()) + if (!IDecl || IDecl->isForwardDecl()) { Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); + err = true; + } else { /// Check for duplicate interface declaration for this category ObjcCategoryDecl *CDeclChain; @@ -1078,6 +1081,7 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S, if (CDeclChain->getIdentifier() == CategoryName) { Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(), CategoryName->getName()); + err = true; break; } } @@ -1089,14 +1093,16 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S, for (unsigned int i = 0; i != NumProtoRefs; i++) { ObjcProtocolDecl* RefPDecl = getObjCProtocolDecl(S, ProtoRefNames[i], CategoryLoc); - if (!RefPDecl || RefPDecl->isForwardDecl()) + if (!RefPDecl || RefPDecl->isForwardDecl()) { Diag(CategoryLoc, diag::err_undef_protocolref, ProtoRefNames[i]->getName(), CategoryName->getName()); + err = true; + } CDecl->setCatReferencedProtocols((int)i, RefPDecl); } - return CDecl; + return err ? 0 : CDecl; } /// ActOnStartCategoryImplementation - Perform semantic checks on the |