[cfe-commits] r42754 - /cfe/trunk/Sema/SemaDecl.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Oct 8 09:07:03 PDT 2007


Author: fjahanian
Date: Mon Oct  8 11:07:03 2007
New Revision: 42754

URL: http://llvm.org/viewvc/llvm-project?rev=42754&view=rev
Log:
Return NULL on invalid protocol.

Modified:
    cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42754&r1=42753&r2=42754&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Mon Oct  8 11:07:03 2007
@@ -1065,11 +1065,14 @@
   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 @@
       if (CDeclChain->getIdentifier() == CategoryName) {
         Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(),
              CategoryName->getName());
+        err = true;
         break;
       }
     }
@@ -1089,14 +1093,16 @@
   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





More information about the cfe-commits mailing list