]> granicus.if.org Git - clang/commitdiff
Return NULL on invalid protocol.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 8 Oct 2007 16:07:03 +0000 (16:07 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 8 Oct 2007 16:07:03 +0000 (16:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42754 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp

index 0b812cdd4890cd3ccffbc3bd5db3be13cf680487..574f1f616674d9c059e397e31137f2627e299d11 100644 (file)
@@ -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