diff options
| author | Alejandro Colomar <alx@kernel.org> | 2025-11-11 13:44:35 +0100 |
|---|---|---|
| committer | Alejandro Colomar <alx@kernel.org> | 2025-11-11 13:54:26 +0100 |
| commit | e26592fe3f701bf68eba35dcd99258d3d61d030d (patch) | |
| tree | ad191a0b8ed36a87dcdb2a850e8f7ed534dfdc40 | |
| parent | c3f4b582d6f44edc7229c3786c76606c3a94e76d (diff) | |
| download | man-pages-master.tar.gz | |
Signed-off-by: Alejandro Colomar <alx@kernel.org>
| -rw-r--r-- | man/man3attr/gnu::warning.3attr | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/man/man3attr/gnu::warning.3attr b/man/man3attr/gnu::warning.3attr new file mode 100644 index 0000000000..b84f7de9c8 --- /dev/null +++ b/man/man3attr/gnu::warning.3attr @@ -0,0 +1,57 @@ +.\" Copyright, the authors of the Linux man-pages project +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH gnu::warning 3attr (date) "Linux man-pages (unreleased)" +.SH NAME +gnu::warning, gnu::error +\- +diagnose function calls not removed by optimizations +.SH SYNOPSIS +.nf +.BI [[gnu::warning( msg )]] +.BI [[gnu::error( msg )]] +.fi +.SH DESCRIPTION +This attribute can be applied to a function. +If the function call is not removed by optimizations, +a diagnostic is emitted. +The diagnostic contains the message +.I msg +and the location of the call in the source code. +.P +.B [[gnu::error()]] +terminates the compilation +after emitting the diagnostic. +.SH VERSIONS +.TP +.BI __attribute__((warning( msg ))) +.TQ +.BI __attribute__((error( msg ))) +.SH STANDARDS +GNU. +.SH HISTORY +gcc 4.3, +g++ 4.3, +clang 14, +clang++ 14. +.SH CAVEATS +This diagnostic is emitted by the compiler, +so it doesn't take into account linker optimizations. +.SH EXAMPLES +.EX +#include <stdlib.h> +\& +[[gnu::warning("foo")]] void dontcall(void); +\& +int +main(void) +{ + dontcall(); // Warning. +\& + if (0) + dontcall(); // No warning. +\& + exit(EXIT_SUCCESS); +} +.EE |
