Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:29:48

0001 /* Copyright (C) 2017-2022 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_DEPRECATED_REGISTER \
0057   DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
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 # define DIAGNOSTIC_ERROR_SWITCH \
0067   DIAGNOSTIC_ERROR ("-Wswitch")
0068 
0069 #elif defined (__GNUC__) /* GCC */
0070 
0071 # if __GNUC__ >= 7
0072 #  define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
0073    DIAGNOSTIC_IGNORE ("-Wregister")
0074 # endif
0075 
0076 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
0077   DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
0078 
0079 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
0080   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
0081 
0082 /* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch
0083    remains enabled at the error level even after a pop.  Therefore, don't
0084    use it for GCC < 5.  */
0085 # if __GNUC__ >= 5
0086 #  define DIAGNOSTIC_ERROR_SWITCH DIAGNOSTIC_ERROR ("-Wswitch")
0087 # endif
0088 
0089 #endif
0090 
0091 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
0092 # define DIAGNOSTIC_IGNORE_SELF_MOVE
0093 #endif
0094 
0095 #ifndef DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0096 # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
0097 #endif
0098 
0099 #ifndef DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
0100 # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
0101 #endif
0102 
0103 #ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0104 # define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
0105 #endif
0106 
0107 #ifndef DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0108 # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
0109 #endif
0110 
0111 #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0112 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
0113 #endif
0114 
0115 #ifndef DIAGNOSTIC_ERROR_SWITCH
0116 # define DIAGNOSTIC_ERROR_SWITCH
0117 #endif
0118 
0119 #endif /* DIAGNOSTICS_H */