|
|
51f0aa |
Partial backport of this upstream commit:
|
|
|
51f0aa |
|
|
|
51f0aa |
commit e15f7de60c26bb75fe1923b17c5f0461164d1a41
|
|
|
51f0aa |
Author: Zack Weinberg <zackw@panix.com>
|
|
|
51f0aa |
Date: Sun Nov 20 20:46:30 2016 -0500
|
|
|
51f0aa |
|
|
|
51f0aa |
Split DIAG_* macros to new header libc-diag.h.
|
|
|
51f0aa |
|
|
|
51f0aa |
Only the include/libc-diag.h header file is added.
|
|
|
51f0aa |
|
|
|
51f0aa |
diff --git a/include/libc-diag.h b/include/libc-diag.h
|
|
|
51f0aa |
new file mode 100644
|
|
|
51f0aa |
index 0000000000000000..db138c63b1573256
|
|
|
51f0aa |
--- /dev/null
|
|
|
51f0aa |
+++ b/include/libc-diag.h
|
|
|
51f0aa |
@@ -0,0 +1,74 @@
|
|
|
51f0aa |
+/* Macros for controlling diagnostic output from the compiler.
|
|
|
51f0aa |
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
|
|
51f0aa |
+ This file is part of the GNU C Library.
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
51f0aa |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
51f0aa |
+ License as published by the Free Software Foundation; either
|
|
|
51f0aa |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
51f0aa |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
51f0aa |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
51f0aa |
+ Lesser General Public License for more details.
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
51f0aa |
+ License along with the GNU C Library; if not, see
|
|
|
51f0aa |
+ <http://www.gnu.org/licenses/>. */
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+#ifndef _LIBC_DIAG_H
|
|
|
51f0aa |
+#define _LIBC_DIAG_H 1
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Ignore the value of an expression when a cast to void does not
|
|
|
51f0aa |
+ suffice (in particular, for a call to a function declared with
|
|
|
51f0aa |
+ attribute warn_unused_result). */
|
|
|
51f0aa |
+#define ignore_value(x) \
|
|
|
51f0aa |
+ ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* The macros to control diagnostics are structured like this, rather
|
|
|
51f0aa |
+ than a single macro that both pushes and pops diagnostic state and
|
|
|
51f0aa |
+ takes the affected code as an argument, because the GCC pragmas
|
|
|
51f0aa |
+ work by disabling the diagnostic for a range of source locations
|
|
|
51f0aa |
+ and do not work when all the pragmas and the affected code are in a
|
|
|
51f0aa |
+ single macro expansion. */
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Push diagnostic state. */
|
|
|
51f0aa |
+#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Pop diagnostic state. */
|
|
|
51f0aa |
+#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+#define _DIAG_STR1(s) #s
|
|
|
51f0aa |
+#define _DIAG_STR(s) _DIAG_STR1(s)
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Ignore the diagnostic OPTION. VERSION is the most recent GCC
|
|
|
51f0aa |
+ version for which the diagnostic has been confirmed to appear in
|
|
|
51f0aa |
+ the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
|
|
|
51f0aa |
+ just MAJOR for GCC 5 and later). Uses of this pragma should be
|
|
|
51f0aa |
+ reviewed when the GCC version given is no longer supported for
|
|
|
51f0aa |
+ building glibc; the version number should always be on the same
|
|
|
51f0aa |
+ source line as the macro name, so such uses can be found with grep.
|
|
|
51f0aa |
+ Uses should come with a comment giving more details of the
|
|
|
51f0aa |
+ diagnostic, and an architecture on which it is seen if possibly
|
|
|
51f0aa |
+ optimization-related and not in architecture-specific code. This
|
|
|
51f0aa |
+ macro should only be used if the diagnostic seems hard to fix (for
|
|
|
51f0aa |
+ example, optimization-related false positives). */
|
|
|
51f0aa |
+#define DIAG_IGNORE_NEEDS_COMMENT(version, option) \
|
|
|
51f0aa |
+ _Pragma (_DIAG_STR (GCC diagnostic ignored option))
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
|
|
|
51f0aa |
+ diagnostic OPTION but only if optimizations for size are enabled.
|
|
|
51f0aa |
+ This is required because different warnings may be generated for
|
|
|
51f0aa |
+ different optimization levels. For example a key piece of code may
|
|
|
51f0aa |
+ only generate a warning when compiled at -Os, but at -O2 you could
|
|
|
51f0aa |
+ still want the warning to be enabled to catch errors. In this case
|
|
|
51f0aa |
+ you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
|
|
|
51f0aa |
+ only for -Os. */
|
|
|
51f0aa |
+#ifdef __OPTIMIZE_SIZE__
|
|
|
51f0aa |
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) \
|
|
|
51f0aa |
+ _Pragma (_DIAG_STR (GCC diagnostic ignored option))
|
|
|
51f0aa |
+#else
|
|
|
51f0aa |
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
|
|
|
51f0aa |
+#endif
|
|
|
51f0aa |
+
|
|
|
51f0aa |
+#endif /* libc-diag.h */
|