summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-01-07 19:21:03 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-01-07 19:21:03 +0000
commitc41cf0598f076f8f6cd2223c739592a91fe78717 (patch)
tree43bee48748627ae5dabf535eebcd4aeb068fde35
parent68d31ce5ff33c987104431efa45c30cfe53df27f (diff)
downloadbcm5719-llvm-c41cf0598f076f8f6cd2223c739592a91fe78717.tar.gz
bcm5719-llvm-c41cf0598f076f8f6cd2223c739592a91fe78717.zip
objective-C: when searching for declarations in protocol
list of classes, etc., make sure to look into protocol definitions. // rdar://12958878 llvm-svn: 171777
-rw-r--r--clang/lib/AST/DeclObjC.cpp12
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp5
-rw-r--r--clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m21
3 files changed, 34 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 12e5d8c3042..62b4f5ea82c 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1352,15 +1352,19 @@ void ObjCProtocolDecl::startDefinition() {
}
void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM) const {
- for (ObjCProtocolDecl::prop_iterator P = prop_begin(),
- E = prop_end(); P != E; ++P) {
+ const ObjCProtocolDecl *PDecl = this;
+ if (!isThisDeclarationADefinition() && getDefinition())
+ PDecl = getDefinition();
+
+ for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
+ E = PDecl->prop_end(); P != E; ++P) {
ObjCPropertyDecl *Prop = *P;
// Insert into PM if not there already.
PM.insert(std::make_pair(Prop->getIdentifier(), Prop));
}
// Scan through protocol's protocols.
- for (ObjCProtocolDecl::protocol_iterator PI = protocol_begin(),
- E = protocol_end(); PI != E; ++PI)
+ for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
+ E = PDecl->protocol_end(); PI != E; ++PI)
(*PI)->collectPropertiesToImplement(PM);
}
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 64b000ee9ab..d22d7a14f60 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1593,6 +1593,11 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
NSIDecl = IDecl->lookupInheritedClass(&Context.Idents.get("NSProxy"));
}
+ // If this is a forward protocol declaration, get its definition.
+ if (!PDecl->isThisDeclarationADefinition() &&
+ PDecl->getDefinition())
+ PDecl = PDecl->getDefinition();
+
// If a method lookup fails locally we still need to look and see if
// the method was implemented by a base class or an inherited
// protocol. This lookup is slow, but occurs rarely in correct code
diff --git a/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m b/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
new file mode 100644
index 00000000000..1010cd75cde
--- /dev/null
+++ b/clang/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-default-synthesize-properties %s
+// rdar://12958878
+
+@interface NSObject @end
+
+@protocol DVTInvalidation
+- (void)invalidate; // expected-note {{method 'invalidate' declared here}}
+@property int Prop; // expected-note {{property declared here}}
+@end
+
+
+
+@protocol DVTInvalidation;
+
+@interface IBImageCatalogDocument : NSObject <DVTInvalidation> // expected-note {{required for direct or indirect protocol 'DVTInvalidation'}}
+@end
+
+@implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}} \
+ // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'invalidate' in protocol not implemented}}
+@end
OpenPOWER on IntegriCloud