steven_wu created this revision. steven_wu added reviewers: erik.pilkington, arphaman, doug.gregor.
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 Repository: rC Clang https://reviews.llvm.org/D47280 Files: lib/Sema/SemaExprMember.cpp test/SemaObjC/property-deprecated-warning.m Index: test/SemaObjC/property-deprecated-warning.m =================================================================== --- test/SemaObjC/property-deprecated-warning.m +++ test/SemaObjC/property-deprecated-warning.m @@ -167,3 +167,14 @@ 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}} +} Index: lib/Sema/SemaExprMember.cpp =================================================================== --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -1490,9 +1490,6 @@ } 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: test/SemaObjC/property-deprecated-warning.m =================================================================== --- test/SemaObjC/property-deprecated-warning.m +++ test/SemaObjC/property-deprecated-warning.m @@ -167,3 +167,14 @@ 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}} +} Index: lib/Sema/SemaExprMember.cpp =================================================================== --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -1490,9 +1490,6 @@ } 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(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits