[cfe-commits] r140406 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjC/attr-availability.m

Douglas Gregor dgregor at apple.com
Fri Sep 23 13:23:42 PDT 2011


Author: dgregor
Date: Fri Sep 23 15:23:42 2011
New Revision: 140406

URL: http://llvm.org/viewvc/llvm-project?rev=140406&view=rev
Log:
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>.

Added:
    cfe/trunk/test/SemaObjC/attr-availability.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=140406&r1=140405&r2=140406&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 23 15:23:42 2011
@@ -1493,9 +1493,11 @@
   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)) {

Added: cfe/trunk/test/SemaObjC/attr-availability.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability.m?rev=140406&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-availability.m (added)
+++ cfe/trunk/test/SemaObjC/attr-availability.m Fri Sep 23 15:23:42 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+ at interface A
+- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2)));
+ at end
+
+ at interface B : A
+- (void)method;
+ at end
+
+void f(A *a, B *b) {
+  [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}}
+  [b method];
+}





More information about the cfe-commits mailing list