[cfe-commits] r172587 - /cfe/trunk/docs/LanguageExtensions.rst

Douglas Gregor dgregor at apple.com
Tue Jan 15 17:12:31 PST 2013


Author: dgregor
Date: Tue Jan 15 19:12:31 2013
New Revision: 172587

URL: http://llvm.org/viewvc/llvm-project?rev=172587&view=rev
Log:
Document the redeclaration and overriding restrictions on the
availability attribute.

Modified:
    cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=172587&r1=172586&r2=172587&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Jan 15 19:12:31 2013
@@ -439,7 +439,7 @@
 Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
 fails because ``f()`` is no longer available.
 
-The availablility attribute is a comma-separated list starting with the
+The availability attribute is a comma-separated list starting with the
 platform name and then including clauses specifying important milestones in the
 declaration's lifetime (in any order) along with additional information.  Those
 clauses can be:
@@ -488,6 +488,33 @@
 can determine whether the declaration is present by checking whether the
 address of that declaration is non-NULL.
 
+If there a multiple declarations of the same entity, the availability
+attributes must either match on a per-platform basis or later
+declarations must not have availability attributes for that
+platform. For example:
+
+.. code-block:: c
+
+  void g(void) __attribute__((availability(macosx,introduced=10.4)));
+  void g(void) __attribute__((availability(macosx,introduced=10.4))); // okay, matches
+  void g(void) __attribute__((availability(ios,introduced=4.0))); // okay, adds a new platform
+  void g(void); // okay, inherits both macosx and ios availability from above.
+  void g(void) __attribute__((availability(macosx,introduced=10.5))); // error: mismatch
+
+When one method overrides another, the overriding method can be more widely available than the overridden method, e.g.,:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method __attribute__((availability(macosx,introduced=10.4)));
+  - (id)method2 __attribute__((availability(macosx,introduced=10.4)));
+  @end
+
+  @interface B : A
+  - (id)method __attribute__((availability(macosx,introduced=10.3))); // okay: method moved into base class later
+  - (id)method __attribute__((availability(macosx,introduced=10.5))); // error: this method was available via the base class in 10.4
+  @end
+
 Checks for Standard Language Features
 =====================================
 





More information about the cfe-commits mailing list