diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2018-11-20 15:23:07 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2018-11-20 15:23:07 +0000 |
commit | 6201557b184c0c448e395cad186cc28335950b7c (patch) | |
tree | f7b3fd7a10eb65eeb4d37bd0fa712e74a7fd7812 /clang/docs | |
parent | 9a0ed200729538b2032353d92c9c821373457973 (diff) |
Update the documentation for attribute feature tests.
This clarifies that __has_cpp_attribute is no longer always an extension since it's now available in C++2a. Also, Both __has_cpp_attribute and __has_c_attribute can accept attribute scope tokens with alternative spelling (clang vs _Clang and gnu vs __gnu__).
llvm-svn: 347312
Diffstat (limited to 'clang/docs')
-rw-r--r-- | clang/docs/LanguageExtensions.rst | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index a52a112d550d..0d358ad51a20 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -112,18 +112,22 @@ of ``cxx_rvalue_references``. ``__has_cpp_attribute`` ----------------------- -This function-like macro takes a single argument that is the name of a -C++11-style attribute. The argument can either be a single identifier, or a -scoped identifier. If the attribute is supported, a nonzero value is returned. -If the attribute is a standards-based attribute, this macro returns a nonzero -value based on the year and month in which the attribute was voted into the -working draft. If the attribute is not supported by the current compliation -target, this macro evaluates to 0. It can be used like this: +This function-like macro is available in C++2a by default, and is provided as an +extension in earlier language standards. It takes a single argument that is the +name of a double-square-bracket-style attribute. The argument can either be a +single identifier or a scoped identifier. If the attribute is supported, a +nonzero value is returned. If the attribute is a standards-based attribute, this +macro returns a nonzero value based on the year and month in which the attribute +was voted into the working draft. See `WG21 SD-6 +<https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations>`_ +for the list of values returned for standards-based attributes. If the attribute +is not supported by the current compliation target, this macro evaluates to 0. +It can be used like this: .. code-block:: c++ - #ifndef __has_cpp_attribute // Optional of course. - #define __has_cpp_attribute(x) 0 // Compatibility with non-clang compilers. + #ifndef __has_cpp_attribute // For backwards compatibility + #define __has_cpp_attribute(x) 0 #endif ... @@ -134,10 +138,11 @@ target, this macro evaluates to 0. It can be used like this: #endif ... -The attribute identifier (but not scope) can also be specified with a preceding -and following ``__`` (double underscore) to avoid interference from a macro with -the same name. For instance, ``gnu::__const__`` can be used instead of -``gnu::const``. +The attribute scope tokens ``clang`` and ``_Clang`` are interchangeable, as are +the attribute scope tokens ``gnu`` and ``__gnu__``. Attribute tokens in either +of these namespaces can be specified with a preceding and following ``__`` +(double underscore) to avoid interference from a macro with the same name. For +instance, ``gnu::__const__`` can be used instead of ``gnu::const``. ``__has_c_attribute`` --------------------- @@ -162,11 +167,11 @@ current compilation target, this macro evaluates to 0. It can be used like this: #endif ... -The attribute identifier (but not scope) can also be specified with a preceding -and following ``__`` (double underscore) to avoid interference from a macro with -the same name. For instance, ``gnu::__const__`` can be used instead of -``gnu::const``. - +The attribute scope tokens ``clang`` and ``_Clang`` are interchangeable, as are +the attribute scope tokens ``gnu`` and ``__gnu__``. Attribute tokens in either +of these namespaces can be specified with a preceding and following ``__`` +(double underscore) to avoid interference from a macro with the same name. For +instance, ``gnu::__const__`` can be used instead of ``gnu::const``. ``__has_attribute`` ------------------- |