[cfe-commits] r53863 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDeclObjC.cpp

Chris Lattner sabre at nondot.org
Mon Jul 21 11:34:02 PDT 2008


Author: lattner
Date: Mon Jul 21 13:34:02 2008
New Revision: 53863

URL: http://llvm.org/viewvc/llvm-project?rev=53863&view=rev
Log:
references to completely undeclared protocols should be errors.  
References to forward definitions should be warnings.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=53863&r1=53862&r2=53863&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Jul 21 13:34:02 2008
@@ -421,6 +421,8 @@
      "cannot find interface declaration for '%0', superclass of '%1'")
 DIAG(err_duplicate_class_def, ERROR,
      "duplicate interface declaration for class '%0'")
+DIAG(err_undef_protocolref, ERROR,
+     "cannot find protocol definition for '%0', referenced by '%1'")
 DIAG(warn_undef_protocolref, WARNING,
      "cannot find protocol definition for '%0', referenced by '%1'")
 DIAG(err_duplicate_protocol_def, ERROR,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=53863&r1=53862&r2=53863&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Jul 21 13:34:02 2008
@@ -134,10 +134,12 @@
     llvm::SmallVector<ObjCProtocolDecl*, 8> RefProtos;
     for (unsigned int i = 0; i != NumProtocols; i++) {
       ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtocolNames[i]];
-      if (!RefPDecl || RefPDecl->isForwardDecl())
+      if (!RefPDecl)
+        Diag(EndProtoLoc, diag::err_undef_protocolref,
+             ProtocolNames[i]->getName(), ClassName->getName());
+      else if (RefPDecl->isForwardDecl())
         Diag(EndProtoLoc, diag::warn_undef_protocolref,
-             ProtocolNames[i]->getName(),
-             ClassName->getName());
+             ProtocolNames[i]->getName(), ClassName->getName());
       else
         RefProtos.push_back(RefPDecl);
     }
@@ -218,10 +220,13 @@
     /// Check then save referenced protocols.
     for (unsigned int i = 0; i != NumProtoRefs; i++) {
       ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtoRefNames[i]];
-      if (!RefPDecl || RefPDecl->isForwardDecl())
+      if (!RefPDecl)
+        Diag(ProtocolLoc, diag::err_undef_protocolref,
+             ProtoRefNames[i]->getName(), ProtocolName->getName());
+      else if (RefPDecl->isForwardDecl())
         Diag(ProtocolLoc, diag::warn_undef_protocolref,
-             ProtoRefNames[i]->getName(),
-             ProtocolName->getName());
+             ProtoRefNames[i]->getName(), ProtocolName->getName());
+      
       PDecl->setReferencedProtocols(i, RefPDecl);
     }
     PDecl->setLocEnd(EndProtoLoc);
@@ -426,11 +431,12 @@
     /// Check and then save the referenced protocols.
     for (unsigned int i = 0; i != NumProtoRefs; i++) {
       ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtoRefNames[i]];
-      if (!RefPDecl || RefPDecl->isForwardDecl()) {
+      if (!RefPDecl)
+        Diag(CategoryLoc, diag::err_undef_protocolref,
+             ProtoRefNames[i]->getName(), CategoryName->getName());
+      else if (RefPDecl->isForwardDecl())
         Diag(CategoryLoc, diag::warn_undef_protocolref,
-             ProtoRefNames[i]->getName(),
-             CategoryName->getName());
-      }
+             ProtoRefNames[i]->getName(), CategoryName->getName());
       if (RefPDecl)
         RefProtocols.push_back(RefPDecl);
     }





More information about the cfe-commits mailing list