r178775 - Objective-C: Issue deprecated warning when using a
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 4 11:45:52 PDT 2013
Author: fjahanian
Date: Thu Apr 4 13:45:52 2013
New Revision: 178775
URL: http://llvm.org/viewvc/llvm-project?rev=178775&view=rev
Log:
Objective-C: Issue deprecated warning when using a
deprecated typedef to subclass or invoke a class method.
// rdar://13569424
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=178775&r1=178774&r2=178775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr 4 13:45:52 2013
@@ -521,8 +521,14 @@ ActOnStartClassInterface(SourceLocation
dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
QualType T = TDecl->getUnderlyingType();
if (T->isObjCObjectType()) {
- if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface())
+ if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface()) {
SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
+ // This handles the following case:
+ // @interface NewI @end
+ // typedef NewI DeprI __attribute__((deprecated("blah")))
+ // @interface SI : DeprI /* warn here */ @end
+ (void)DiagnoseUseOfDecl(const_cast<TypedefNameDecl*>(TDecl), SuperLoc);
+ }
}
}
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=178775&r1=178774&r2=178775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Apr 4 13:45:52 2013
@@ -1786,9 +1786,11 @@ Sema::ObjCMessageKind Sema::getObjCMessa
QualType T;
if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(ND))
T = Context.getObjCInterfaceType(Class);
- else if (TypeDecl *Type = dyn_cast<TypeDecl>(ND))
+ else if (TypeDecl *Type = dyn_cast<TypeDecl>(ND)) {
T = Context.getTypeDeclType(Type);
- else
+ DiagnoseUseOfDecl(Type, NameLoc);
+ }
+ else
return ObjCInstanceMessage;
// We have a class message, and T is the type we're
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=178775&r1=178774&r2=178775&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Thu Apr 4 13:45:52 2013
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
@interface A {
int X __attribute__((deprecated)); // expected-note 2 {{declared here}}
@@ -135,3 +136,21 @@ typedef struct {
@property footype c; // expected-warning {{'footype' is deprecated}}
@property footype d __attribute((deprecated));
@end
+
+// rdar://13569424
+ at interface NewI
++(void)cmeth;
+ at end
+
+typedef NewI DeprI __attribute__((deprecated("blah"))); // expected-note 4 {{'DeprI' declared here}}
+
+ at interface SI : DeprI // expected-warning {{'DeprI' is deprecated: blah}}
+-(DeprI*)meth; // expected-warning {{'DeprI' is deprecated: blah}}
+ at end
+
+ at implementation SI
+-(DeprI*)meth { // expected-warning {{'DeprI' is deprecated: blah}}
+ [DeprI cmeth]; // expected-warning {{'DeprI' is deprecated: blah}}
+ return 0;
+}
+ at end
More information about the cfe-commits
mailing list