Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:19

0001 /* Copyright (C) 2017-2024 Free Software Foundation, Inc.
0002 
0003    This program is free software; you can redistribute it and/or modify
0004    it under the terms of the GNU General Public License as published by
0005    the Free Software Foundation; either version 3 of the License, or
0006    (at your option) any later version.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0011    GNU General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
0015 
0016 #ifndef DIAGNOSTICS_H
0017 #define DIAGNOSTICS_H
0018 
0019 /* If at all possible, fix the source rather than using these macros
0020    to silence warnings.  If you do use these macros be aware that
0021    you'll need to condition their use on particular compiler versions,
0022    which can be done for gcc using ansidecl.h's GCC_VERSION macro.
0023 
0024    gcc versions between 4.2 and 4.6 do not allow pragma control of
0025    diagnostics inside functions, giving a hard error if you try to use
0026    the finer control available with later versions.
0027    gcc prior to 4.2 warns about diagnostic push and pop.
0028 
0029    The other macros have restrictions too, for example gcc-5, gcc-6
0030    and gcc-7 warn that -Wstringop-truncation is unknown, unless you
0031    also add DIAGNOSTIC_IGNORE ("-Wpragma").  */
0032 
0033 #ifdef __GNUC__
0034 # define DIAGNOSTIC_PUSH _Pragma ("GCC diagnostic push")
0035 # define DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop")
0036 
0037 /* Stringification.  */
0038 # define DIAGNOSTIC_STRINGIFY_1(x) #x
0039 # define DIAGNOSTIC_STRINGIFY(x) DIAGNOSTIC_STRINGIFY_1 (x)
0040 
0041 # define DIAGNOSTIC_IGNORE(option) \
0042   _Pragma (DIAGNOSTIC_STRINGIFY (GCC diagnostic ignored option))
0043 # define DIAGNOSTIC_ERROR(option) \
0044   _Pragma (DIAGNOSTIC_STRINGIFY (GCC diagnostic error option))
0045 #else
0046 # define DIAGNOSTIC_PUSH
0047 # define DIAGNOSTIC_POP
0048 # define DIAGNOSTIC_IGNORE(option)
0049 #endif
0050 
0051 #if defined (__clang__) /* clang */
0052 
0053 # define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
0054 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
0055   DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
0056 # define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister")
0057 
0058 # if __has_warning ("-Wenum-compare-switch")
0059 #  define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
0060    DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
0061 # endif
0062 
0063 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
0064   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
0065 
0066 # if __has_warning ("-Wuser-defined-warnings")
0067 #  define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS \
0068    DIAGNOSTIC_IGNORE ("-Wuser-defined-warnings")
0069 # endif
0070 
0071 # if __has_warning ("-Wunused-but-set-variable")
0072 #  define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \
0073    DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
0074 # endif
0075 
0076 # define DIAGNOSTIC_ERROR_SWITCH \
0077   DIAGNOSTIC_ERROR ("-Wswitch")
0078 
0079 # if __has_warning ("-Wenum-constexpr-conversion")
0080 #  define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \
0081    DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion")
0082 # endif
0083 
0084 #elif defined (__GNUC__) /* GCC */
0085 
0086 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
0087   DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
0088 
0089 # if __GNUC__ >= 7
0090 #  define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister")
0091 # endif
0092 
0093 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
0094   DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
0095 
0096 # if __GNUC__ >= 11
0097 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD \
0098   DIAGNOSTIC_IGNORE ("-Wstringop-overread")
0099 #endif
0100 
0101 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
0102   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
0103 
0104 # if __GNUC__ >= 5
0105 #  define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \
0106    DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
0107 # endif
0108 
0109 # if __GNUC__ >= 13
0110 #  define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
0111 # endif
0112 
0113 /* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch
0114    remains enabled at the error level even after a pop.  Therefore, don't
0115    use it for GCC < 5.  */
0116 # if __GNUC__ >= 5
0117 #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
0118 # endif
0119 
0120 #endif
0121 
0122 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
0123 # define DIAGNOSTIC_IGNORE_SELF_MOVE
0124 #endif
0125 
0126 #ifndef DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0127 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0128 #endif
0129 
0130 #ifndef DIAGNOSTIC_IGNORE_REGISTER
0131 # define DIAGNOSTIC_IGNORE_REGISTER
0132 #endif
0133 
0134 #ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0135 # define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0136 #endif
0137 
0138 #ifndef DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0139 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0140 #endif
0141 
0142 #ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
0143 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
0144 #endif
0145 
0146 #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0147 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0148 #endif
0149 
0150 #ifndef DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
0151 # define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
0152 #endif
0153 
0154 #ifndef DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
0155 # define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
0156 #endif
0157 
0158 #ifndef DIAGNOSTIC_ERROR_SWITCH
0159 # define DIAGNOSTIC_ERROR_SWITCH
0160 #endif
0161 
0162 #ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
0163 # define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION
0164 #endif
0165 
0166 #endif /* DIAGNOSTICS_H */