r175110 - Document Clang's support for [[gnu::...]] attributes.

Richard Smith richard-llvm at metafoo.co.uk
Wed Feb 13 16:13:35 PST 2013


Author: rsmith
Date: Wed Feb 13 18:13:34 2013
New Revision: 175110

URL: http://llvm.org/viewvc/llvm-project?rev=175110&view=rev
Log:
Document Clang's support for [[gnu::...]] attributes.

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=175110&r1=175109&r2=175110&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Feb 13 18:13:34 2013
@@ -1488,8 +1488,8 @@ C11's ``<stdatomic.h>`` header.  These b
 Non-standard C++11 Attributes
 =============================
 
-Clang supports one non-standard C++11 attribute.  It resides in the ``clang``
-attribute namespace.
+Clang's non-standard C++11 attributes live in the ``clang`` attribute
+namespace.
 
 The ``clang::fallthrough`` attribute
 ------------------------------------
@@ -1536,6 +1536,28 @@ Here is an example:
     r();
   }
 
+``gnu::`` attributes
+--------------------
+
+Clang also supports GCC's ``gnu`` attribute namespace. All GCC attributes which
+are accepted with the ``__attribute__((foo))`` syntax are also accepted as
+``[[gnu::foo]]``. This only extends to attributes which are specified by GCC
+(see the list of `GCC function attributes
+<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_, `GCC variable
+attributes <http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html>`_, and
+`GCC type attributes
+<http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html>`_. As with the GCC
+implementation, these attributes must appertain to the *declarator-id* in a
+declaration, which means they must go either at the start of the declaration or
+immediately after the name being declared.
+
+For example, this applies the GNU ``unused`` attribute to ``a`` and ``f``, and
+also applies the GNU ``noreturn`` attribute to ``f``.
+
+.. code-block:: c++
+
+  [[gnu::unused]] int a, f [[gnu::noreturn]] ();
+
 Target-Specific Extensions
 ==========================
 





More information about the cfe-commits mailing list