]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/man3attr/gnu::warning.3attr: Add page
authorAlejandro Colomar <alx@kernel.org>
Tue, 11 Nov 2025 12:44:35 +0000 (13:44 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 11 Nov 2025 12:54:26 +0000 (13:54 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man3attr/gnu::warning.3attr [new file with mode: 0644]

diff --git a/man/man3attr/gnu::warning.3attr b/man/man3attr/gnu::warning.3attr
new file mode 100644 (file)
index 0000000..b84f7de
--- /dev/null
@@ -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