r186047 - Fix documentation:

Richard Smith richard-llvm at metafoo.co.uk
Wed Jul 10 17:27:05 PDT 2013


Author: rsmith
Date: Wed Jul 10 19:27:05 2013
New Revision: 186047

URL: http://llvm.org/viewvc/llvm-project?rev=186047&view=rev
Log:
Fix documentation:

  #if defined(__has_foo("X")) && __has_foo("X")

is not a correct way to portably use __has_foo, because it is expanded to

  #if 0 && 0("X")

... which is ill-formed.

Also add a missing ')'.

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=186047&r1=186046&r2=186047&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Jul 10 19:27:05 2013
@@ -159,12 +159,16 @@ include paths, or 0 otherwise:
   # include "myinclude.h"
   #endif
 
+To test for this feature, use ``#if defined(__has_include)``:
+
+.. code-block:: c++
+
   // To avoid problem with non-clang compilers not having this macro.
-  #if defined(__has_include) && __has_include("myinclude.h")
+  #if defined(__has_include)
+  #if __has_include("myinclude.h")
   # include "myinclude.h"
   #endif
-
-To test for this feature, use ``#if defined(__has_include)``.
+  #endif
 
 .. _langext-__has_include_next:
 
@@ -185,9 +189,11 @@ or 0 otherwise:
   #endif
 
   // To avoid problem with non-clang compilers not having this macro.
-  #if defined(__has_include_next) && __has_include_next("myinclude.h")
+  #if defined(__has_include_next)
+  #if __has_include_next("myinclude.h")
   # include_next "myinclude.h"
   #endif
+  #endif
 
 Note that ``__has_include_next``, like the GNU extension ``#include_next``
 directive, is intended for use in headers only, and will issue a warning if
@@ -1695,7 +1701,7 @@ are accepted with the ``__attribute__((f
 <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
+<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.





More information about the cfe-commits mailing list