Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:16:41

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 #elif defined (__GNUC__) /* GCC */
0080 
0081 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
0082   DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
0083 
0084 # if __GNUC__ >= 7
0085 #  define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister")
0086 # endif
0087 
0088 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
0089   DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
0090 
0091 # if __GNUC__ >= 11
0092 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD \
0093   DIAGNOSTIC_IGNORE ("-Wstringop-overread")
0094 #endif
0095 
0096 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
0097   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
0098 
0099 # if __GNUC__ >= 5
0100 #  define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \
0101    DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
0102 # endif
0103 
0104 # if __GNUC__ >= 13
0105 #  define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
0106 # endif
0107 
0108 /* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch
0109    remains enabled at the error level even after a pop.  Therefore, don't
0110    use it for GCC < 5.  */
0111 # if __GNUC__ >= 5
0112 #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
0113 # endif
0114 
0115 #endif
0116 
0117 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
0118 # define DIAGNOSTIC_IGNORE_SELF_MOVE
0119 #endif
0120 
0121 #ifndef DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0122 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0123 #endif
0124 
0125 #ifndef DIAGNOSTIC_IGNORE_REGISTER
0126 # define DIAGNOSTIC_IGNORE_REGISTER
0127 #endif
0128 
0129 #ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0130 # define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0131 #endif
0132 
0133 #ifndef DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0134 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0135 #endif
0136 
0137 #ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
0138 # define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
0139 #endif
0140 
0141 #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0142 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0143 #endif
0144 
0145 #ifndef DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
0146 # define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
0147 #endif
0148 
0149 #ifndef DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
0150 # define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
0151 #endif
0152 
0153 #ifndef DIAGNOSTIC_ERROR_SWITCH
0154 # define DIAGNOSTIC_ERROR_SWITCH
0155 #endif
0156 
0157 #endif /* DIAGNOSTICS_H */