DIAG(err_duplicate_class_def, ERROR,
"duplicate interface declaration for class '%0'")
DIAG(warn_undef_protocolref, WARNING,
- "cannot find protocol definition for '%0', referenced by '%1'")
+ "cannot find protocol definition for '%0'")
DIAG(err_duplicate_protocol_def, ERROR,
"duplicate protocol declaration of '%0'")
DIAG(err_undef_interface, ERROR,
/// issues error if they are not declared. It returns list of valid
/// protocols found.
virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
+ bool WarnOnDeclarations,
const IdentifierLocPair *ProtocolId,
unsigned NumProtocols,
- llvm::SmallVectorImpl<DeclTy*> &Protocols) {
+ llvm::SmallVectorImpl<DeclTy*> &ResProtos) {
}
//===----------------------- Obj-C Expressions --------------------------===//
ParseObjCProtocolReferences(ProtocolRefs, EndProtoLoc);
llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
- Actions.FindProtocolDeclaration(Loc,
+ Actions.FindProtocolDeclaration(Loc, false,
&ProtocolRefs[0], ProtocolRefs.size(),
ProtocolDecl);
DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs;
ParseObjCProtocolReferences(ProtocolRefs, EndProtoLoc);
llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
- Actions.FindProtocolDeclaration(Loc,
+ Actions.FindProtocolDeclaration(Loc, false,
&ProtocolRefs[0], ProtocolRefs.size(),
ProtocolDecl);
DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
unsigned NumElts);
virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
+ bool WarnOnDeclarations,
const IdentifierLocPair *ProtocolId,
unsigned NumProtocols,
llvm::SmallVectorImpl<DeclTy *> &Protocols);
else {
if (RefPDecl->isForwardDecl())
Diag(ProtocolNames[i].second, diag::warn_undef_protocolref,
- ProtocolNames[i].first->getName(), ClassName->getName());
+ ProtocolNames[i].first->getName());
RefProtos.push_back(RefPDecl);
}
}
else {
if (RefPDecl->isForwardDecl())
Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref,
- ProtoRefNames[i].first->getName(), ProtocolName->getName());
+ ProtoRefNames[i].first->getName());
Protocols.push_back(RefPDecl);
}
}
/// issuer error if they are not declared. It returns list of protocol
/// declarations in its 'Protocols' argument.
void
-Sema::FindProtocolDeclaration(SourceLocation TypeLoc,
+Sema::FindProtocolDeclaration(SourceLocation TypeLoc, bool WarnOnDeclarations,
const IdentifierLocPair *ProtocolId,
unsigned NumProtocols,
llvm::SmallVectorImpl<DeclTy*> &Protocols) {
for (unsigned i = 0; i != NumProtocols; ++i) {
- if (ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first])
- Protocols.push_back(PDecl);
- else
+ ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first];
+ if (!PDecl) {
Diag(ProtocolId[i].second, diag::err_undeclared_protocol,
ProtocolId[i].first->getName());
+ continue;
+ }
+
+ // If this is a forward declaration and we are supposed to warn in this
+ // case, do it.
+ if (WarnOnDeclarations && PDecl->isForwardDecl())
+ Diag(ProtocolId[i].second, diag::warn_undef_protocolref,
+ ProtocolId[i].first->getName());
+ Protocols.push_back(PDecl);
}
}
else {
if (RefPDecl->isForwardDecl())
Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref,
- ProtoRefNames[i].first->getName(), CategoryName->getName());
+ ProtoRefNames[i].first->getName());
RefProtocols.push_back(RefPDecl);
}
}
@protocol p1,p2,p3;
-@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1', referenced by 'Category1'}}
+@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}}
@end
@interface MyClass1 (Category1) // expected-warning {{duplicate interface declaration for category 'MyClass1(Category1)'}}
@protocol p3 @end
-@interface MyClass1 (Category) <p2, p3> @end // expected-warning {{cannot find protocol definition for 'p2', referenced by 'Category'}}
+@interface MyClass1 (Category) <p2, p3> @end // expected-warning {{cannot find protocol definition for 'p2'}}
@interface MyClass (Category) @end // expected-error {{cannot find interface declaration for 'MyClass'}}
@protocol SUPER;
-@interface SUPER <SUPER> @end // expected-warning {{cannot find protocol definition for 'SUPER', referenced by 'SUPER'}}
+@interface SUPER <SUPER> @end // expected-warning {{cannot find protocol definition for 'SUPER'}}
typedef int INTF; // expected-error {{previous definition is here}}
@interface I1 <p1> @end
-@interface E1 <p2> @end // expected-warning {{cannot find protocol definition for 'p2', referenced by 'E1'}}
+@interface E1 <p2> @end // expected-warning {{cannot find protocol definition for 'p2'}}
@protocol p2 @end
@interface I2 <p1,p2> @end
-@interface E2 <p1,p2,p3> @end // expected-warning {{cannot find protocol definition for 'p3', referenced by 'E2'}}
+@interface E2 <p1,p2,p3> @end // expected-warning {{cannot find protocol definition for 'p3'}}
@class U1, U2;
- (INTF1<p1>*) meth;
@end
-@protocol PROTO2<p1> // expected-warning {{cannot find protocol definition for 'p1', referenced by 'PROTO2'}}
+@protocol PROTO2<p1> // expected-warning {{cannot find protocol definition for 'p1'}}
@end
@protocol p1 @end
@protocol p2 <p1>
@end
-@protocol PROTO4 <p1, p2, PROTO, PROTO3, p3> // expected-warning {{cannot find protocol definition for 'p3', referenced by 'PROTO4'}}
+@protocol PROTO4 <p1, p2, PROTO, PROTO3, p3> // expected-warning {{cannot find protocol definition for 'p3'}}
@end