diff options
| author | Andy Gibbs <andyg1001@hotmail.co.uk> | 2013-04-17 16:16:16 +0000 |
|---|---|---|
| committer | Andy Gibbs <andyg1001@hotmail.co.uk> | 2013-04-17 16:16:16 +0000 |
| commit | 9c2ccd622fe14bc7f0d752cda7263423722f441c (patch) | |
| tree | 700fc1596d7188adf7b18cf4bd893052f8100ab7 /clang/docs | |
| parent | 2d5c341cee4aa4695d7650b9b55613a4c3964d35 (diff) | |
| download | bcm5719-llvm-9c2ccd622fe14bc7f0d752cda7263423722f441c.tar.gz bcm5719-llvm-9c2ccd622fe14bc7f0d752cda7263423722f441c.zip | |
Implemented #pragma GCC warning/error in the same mould as #pragma message.
llvm-svn: 179687
Diffstat (limited to 'clang/docs')
| -rw-r--r-- | clang/docs/UsersManual.rst | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 97784f1b1bc..3dc07aba901 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -652,6 +652,31 @@ supports the GCC pragma, Clang and GCC do not support the exact same set of warnings, so even when using GCC compatible #pragmas there is no guarantee that they will have identical behaviour on both compilers. +In addition to controlling warnings and errors generated by the compiler, it is +possible to generate custom warning and error messages through the following +pragmas: + +.. code-block:: c + + // The following will produce warning messages + #pragma message "some diagnostic message" + #pragma GCC warning "TODO: replace deprecated feature" + + // The following will produce an error message + #pragma GCC error "Not supported" + +These pragmas operate similarly to the ``#warning`` and ``#error`` preprocessor +directives, except that they may also be embedded into preprocessor macros via +the C99 ``_Pragma`` operator, for example: + +.. code-block:: c + + #define STR(X) #X + #define DEFER(M,...) M(__VA_ARGS__) + #define CUSTOM_ERROR(X) _Pragma(STR(GCC error(X " at line " DEFER(STR,__LINE__)))) + + CUSTOM_ERROR("Feature not available"); + Controlling Diagnostics in System Headers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |

