]> granicus.if.org Git - clang/commitdiff
Diagnose if an implementation implements a forward class
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 23 Apr 2009 21:49:04 +0000 (21:49 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 23 Apr 2009 21:49:04 +0000 (21:49 +0000)
declaration (and avoid issuing bogus error later on).

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

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/class-impl-1.m
test/SemaObjC/synchronized.m

index 3c544ed377c9cda65ed9db29823b15e6bbfe4911..6702eb9a7a23e2d4ce505df82b11393ab7aa530d 100644 (file)
@@ -623,8 +623,10 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
   }  else {
     // Is there an interface declaration of this class; if not, warn!
     IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
-    if (!IDecl)
+    if (!IDecl || IDecl->isForwardDecl()) {
       Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
+      IDecl = 0;
+    }
   }
   
   // Check that super class name is valid class name
index 5cd8a75104359a8cc282a7bd8f05611e5bd48bca..5a67bef3d605bbfc02260566f8ceec52f08f35a3 100644 (file)
@@ -31,3 +31,10 @@ typedef int INTF3; // expected-note {{previous definition is here}}
 
 @implementation INTF4 @end // expected-warning {{cannot find interface declaration for 'INTF4'}}
 
+@class INTF5;
+
+@implementation INTF5 {  // expected-warning {{cannot find interface declaration for 'INTF5'}}
+  int x;
+}
+@end
+
index e8e668fd8bc4732138e1b4e01ab765df41431e0b..7131265b5bb7bbf35de68e81888c36cf638e0477 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: clang-cc -fsyntax-only -verify %s
 
-@class PBXTrackableTaskManager;
+@interface PBXTrackableTaskManager @end
 
 @implementation PBXTrackableTaskManager
 - (id) init {}