]> granicus.if.org Git - clang/commitdiff
references to completely undeclared protocols should be errors.
authorChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 18:34:02 +0000 (18:34 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 18:34:02 +0000 (18:34 +0000)
References to forward definitions should be warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53863 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDeclObjC.cpp

index bc171091f3f932ad57c98addf9dfe346c1f7a7dd..a7c750a27589f81c6a1c1a64bcf9bd94670cea74 100644 (file)
@@ -421,6 +421,8 @@ DIAG(err_undef_superclass, ERROR,
      "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,
index 5188740af62ab2c2592e9a2e74062bfea82a5141..6880eec9af6d89c45ffa8d92a971658d680fe17f 100644 (file)
@@ -134,10 +134,12 @@ Sema::DeclTy *Sema::ActOnStartClassInterface(
     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 @@ Sema::DeclTy *Sema::ActOnStartProtocolInterface(
     /// 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 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface(
     /// 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);
     }