def warn_deprecated_fwdclass_message : Warning<
"%0 maybe deprecated because receiver type is unknown">,
InGroup<DeprecatedDeclarations>;
+def warn_depercated_def : Warning<
+ "Implementing deprecated %select{method|class|category}0">,
+ InGroup<DeprecatedImplementations>, DefaultIgnore;
def err_unavailable : Error<"%0 is unavailable">;
def err_unavailable_message : Error<"%0 is unavailable: %1">;
def warn_unavailable_fwdclass_message : Warning<
if ((*PI)->getIdentifier())
PushOnScopeChains(*PI, FnBodyScope);
}
+ // Warn on implementating deprecated methods under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, MDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) {
+ if (ObjCMethodDecl *IMD =
+ IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()))
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IMD))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(MDecl->getLocation(), DIAG) << 0;
+ Diag(IMD->getLocation(), diag::note_method_declared_at);
+ }
+ }
}
Decl *Sema::
<< CatName;
Diag(CatIDecl->getImplementation()->getLocation(),
diag::note_previous_definition);
- } else
+ } else {
CatIDecl->setImplementation(CDecl);
+ // Warn on implementating category of deprecated class under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, CDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(CDecl->getLocation(), DIAG) << 2;
+ Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
+ }
+
+ }
}
CheckObjCDeclScope(CDecl);
} else { // add it to the list.
IDecl->setImplementation(IMPDecl);
PushOnScopeChains(IMPDecl, TUScope);
+ // Warn on implementating deprecated class under
+ // -Wdeprecated-implementations flag.
+ // FIXME. Refactor using common routine.
+ unsigned DIAG = diag::warn_depercated_def;
+ if (Diags.getDiagnosticLevel(DIAG, IMPDecl->getLocation())
+ != Diagnostic::Ignored)
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
+ if (ND->getAttr<DeprecatedAttr>()) {
+ Diag(IMPDecl->getLocation(), DIAG) << 1;
+ Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
+ }
}
return IMPDecl;
}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify %s
+// rdar://8973810
+
+@protocol P
+- (void) D __attribute__((deprecated)); // expected-note {{method declared here}}
+@end
+
+@interface A <P>
++ (void)F __attribute__((deprecated)); // expected-note {{method declared here}}
+@end
+
+@interface A()
+- (void) E __attribute__((deprecated)); // expected-note {{method declared here}}
+@end
+
+@implementation A
++ (void)F { } // expected-warning {{Implementing deprecated method}}
+- (void) D {} // expected-warning {{Implementing deprecated method}}
+- (void) E {} // expected-warning {{Implementing deprecated method}}
+@end
+
+__attribute__((deprecated))
+@interface CL // expected-note 2 {{class declared here}}
+@end
+
+@implementation CL // expected-warning {{Implementing deprecated class}}
+@end
+
+@implementation CL ( SomeCategory ) // expected-warning {{Implementing deprecated category}}
+@end
+
+@interface CL_SUB : CL // expected-warning {{'CL' is deprecated}}
+@end
+
+@interface BASE
+- (void) B __attribute__((deprecated)); // expected-note {{method declared here}}
+@end
+
+@interface SUB : BASE
+@end
+
+@implementation SUB
+- (void) B {} // expected-warning {{Implementing deprecated method}}
+@end
+