diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-23 20:23:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-23 20:23:42 +0000 |
commit | c193dd84414c32b7c66f5b68176401665c0d2301 (patch) | |
tree | 144e546ee8ed9b39a5b9c96573c5b8de0072a4b1 | |
parent | f1f8b1a404d9ce6f0eb78e97b598a220d8ca9090 (diff) |
Don't propagate the 'availability' attribute through declaration
merging for overrides. One might want to make a method's availability
in a superclass different from that of its subclass. Fixes
<rdar://problem/10166223>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140406 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | test/SemaObjC/attr-availability.m | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3878341ca7..da0fa3e12a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1493,9 +1493,11 @@ static void mergeDeclAttributes(Decl *newDecl, const Decl *oldDecl, for (specific_attr_iterator<InheritableAttr> i = oldDecl->specific_attr_begin<InheritableAttr>(), e = oldDecl->specific_attr_end<InheritableAttr>(); i != e; ++i) { - // Ignore deprecated and unavailable attributes if requested. + // Ignore deprecated/unavailable/availability attributes if requested. if (!mergeDeprecation && - (isa<DeprecatedAttr>(*i) || isa<UnavailableAttr>(*i))) + (isa<DeprecatedAttr>(*i) || + isa<UnavailableAttr>(*i) || + isa<AvailabilityAttr>(*i))) continue; if (!DeclHasAttr(newDecl, *i)) { diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m new file mode 100644 index 0000000000..8511d131e1 --- /dev/null +++ b/test/SemaObjC/attr-availability.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +@interface A +- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); +@end + +@interface B : A +- (void)method; +@end + +void f(A *a, B *b) { + [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}} + [b method]; +} |