issue the note if it is because message is sent to a forward class
declaration in delayed diagnostic. // rdar://
10290322
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151942
91177308-0d34-0410-b5e6-
96231b3b80d8
void Destroy();
static DelayedDiagnostic makeDeprecation(SourceLocation Loc,
- const NamedDecl *D,
- StringRef Msg);
+ const NamedDecl *D,
+ const ObjCInterfaceDecl *UnknownObjCClass,
+ StringRef Msg);
static DelayedDiagnostic makeAccess(SourceLocation Loc,
const AccessedEntity &Entity) {
assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
return QualType::getFromOpaquePtr(ForbiddenTypeData.OperandType);
}
+
+ const ObjCInterfaceDecl *getUnknownObjCClass() const {
+ return DeprecationData.UnknownObjCClass;
+ }
private:
union {
/// Deprecation.
struct {
const NamedDecl *Decl;
+ const ObjCInterfaceDecl *UnknownObjCClass;
const char *Message;
size_t MessageLen;
} DeprecationData;
using namespace sema;
DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc,
- const NamedDecl *D,
- StringRef Msg) {
+ const NamedDecl *D,
+ const ObjCInterfaceDecl *UnknownObjCClass,
+ StringRef Msg) {
DelayedDiagnostic DD;
DD.Kind = Deprecation;
DD.Triggered = false;
DD.Loc = Loc;
DD.DeprecationData.Decl = D;
+ DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
char *MessageData = 0;
if (Msg.size()) {
MessageData = new char [Msg.size()];
Diag(DD.Loc, diag::warn_deprecated_message)
<< DD.getDeprecationDecl()->getDeclName()
<< DD.getDeprecationMessage();
+ else if (DD.getUnknownObjCClass()) {
+ Diag(DD.Loc, diag::warn_deprecated_fwdclass_message)
+ << DD.getDeprecationDecl()->getDeclName();
+ Diag(DD.getUnknownObjCClass()->getLocation(), diag::note_forward_class);
+ }
else
Diag(DD.Loc, diag::warn_deprecated)
<< DD.getDeprecationDecl()->getDeclName();
const ObjCInterfaceDecl *UnknownObjCClass) {
// Delay if we're currently parsing a declaration.
if (DelayedDiagnostics.shouldDelayDiagnostics()) {
- DelayedDiagnostics.add(DelayedDiagnostic::makeDeprecation(Loc, D, Message));
+ DelayedDiagnostics.add(DelayedDiagnostic::makeDeprecation(Loc, D,
+ UnknownObjCClass,
+ Message));
return;
}
--- /dev/null
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10290322
+
+@class ABGroupImportFilesScope; // expected-note {{forward declaration of class here}}
+
+@interface I1
+- (id) filenames __attribute__((deprecated));
+@end
+
+@interface I2
+- (id) Meth : (ABGroupImportFilesScope*) scope;
+- (id) filenames __attribute__((deprecated));
+- (id)initWithAccount: (id)account filenames:(id)filenames;
+@end
+
+@implementation I2
+- (id) Meth : (ABGroupImportFilesScope*) scope
+{
+ id p = [self initWithAccount : 0 filenames :[scope filenames]]; // expected-warning {{'filenames' maybe deprecated because receiver type is unknown}}
+ return 0;
+}
+- (id) filenames { return 0; }
+- (id)initWithAccount: (id)account filenames:(id)filenames { return 0; }
+@end