Blame include/libc-diag.h

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