]> granicus.if.org Git - clang/commitdiff
[Sema][ObjC] Do not DiagnoseUseOfDecl in LookupMemberExpr
authorSteven Wu <stevenwu@apple.com>
Thu, 24 May 2018 01:01:43 +0000 (01:01 +0000)
committerSteven Wu <stevenwu@apple.com>
Thu, 24 May 2018 01:01:43 +0000 (01:01 +0000)
Summary:
Remove the call to DiagnoseUseOfDecl in LookupMemberExpr because:
1. LookupMemberExpr eagerly lookup both getter and setter, reguardless
if they are used or not. It causes wrong diagnostics if you are only
using getter.
2. LookupMemberExpr only diagnoses getter, but not setter.
3. ObjCPropertyOpBuilder already DiagnoseUseOfDecl when building getter
and setter. Doing it again in LookupMemberExpr causes duplicated
diagnostics.

rdar://problem/38479756

Reviewers: erik.pilkington, arphaman, doug.gregor

Reviewed By: arphaman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47280

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333148 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprMember.cpp
test/SemaObjC/property-deprecated-warning.m

index c91b15e29fc8c40a052d7bb165f4a7a398bc9942..3a8fee862c918e91a879024421699f92e17cb911 100644 (file)
@@ -1490,9 +1490,6 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
         }
 
         if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(PMDecl)) {
-          // Check the use of this method.
-          if (S.DiagnoseUseOfDecl(OMD, MemberLoc))
-            return ExprError();
           Selector SetterSel =
             SelectorTable::constructSetterSelector(S.PP.getIdentifierTable(),
                                                    S.PP.getSelectorTable(),
index 8cf4f9731bc47e70954237201df764fe44c218f0..0591c78fba4aa6be267b035aad675286921048ea 100644 (file)
@@ -167,3 +167,14 @@ void testUserAccessorAttributes(Foo *foo) {
        foo.x = foo.x; // expected-error {{property access is using 'x' method which is unavailable}} \
                       // expected-warning {{property access is using 'setX:' method which is deprecated}}
 }
+
+// test implicit property does not emit duplicated warning.
+@protocol Foo
+- (int)size __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'size' has been explicitly marked deprecated here}}
+- (void)setSize: (int)x __attribute__((availability(ios,deprecated=2.0))); // expected-note {{'setSize:' has been explicitly marked deprecated here}}
+@end
+
+void testImplicitProperty(id<Foo> object) {
+  object.size = object.size; // expected-warning {{'size' is deprecated: first deprecated in iOS 3.0}} \
+                             // expected-warning {{'setSize:' is deprecated: first deprecated in iOS 2.0}}
+}