xref: /aosp_15_r20/external/libpcap/diag-control.h (revision 8b26181f966a6af5cf6981a6f474313de533bb28)
1*8b26181fSAndroid Build Coastguard Worker /* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
2*8b26181fSAndroid Build Coastguard Worker /*
3*8b26181fSAndroid Build Coastguard Worker  * Copyright (c) 1993, 1994, 1995, 1996, 1997
4*8b26181fSAndroid Build Coastguard Worker  *	The Regents of the University of California.  All rights reserved.
5*8b26181fSAndroid Build Coastguard Worker  *
6*8b26181fSAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
7*8b26181fSAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
8*8b26181fSAndroid Build Coastguard Worker  * are met:
9*8b26181fSAndroid Build Coastguard Worker  * 1. Redistributions of source code must retain the above copyright
10*8b26181fSAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
11*8b26181fSAndroid Build Coastguard Worker  * 2. Redistributions in binary form must reproduce the above copyright
12*8b26181fSAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in the
13*8b26181fSAndroid Build Coastguard Worker  *    documentation and/or other materials provided with the distribution.
14*8b26181fSAndroid Build Coastguard Worker  * 3. All advertising materials mentioning features or use of this software
15*8b26181fSAndroid Build Coastguard Worker  *    must display the following acknowledgement:
16*8b26181fSAndroid Build Coastguard Worker  *	This product includes software developed by the Computer Systems
17*8b26181fSAndroid Build Coastguard Worker  *	Engineering Group at Lawrence Berkeley Laboratory.
18*8b26181fSAndroid Build Coastguard Worker  * 4. Neither the name of the University nor of the Laboratory may be used
19*8b26181fSAndroid Build Coastguard Worker  *    to endorse or promote products derived from this software without
20*8b26181fSAndroid Build Coastguard Worker  *    specific prior written permission.
21*8b26181fSAndroid Build Coastguard Worker  *
22*8b26181fSAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*8b26181fSAndroid Build Coastguard Worker  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*8b26181fSAndroid Build Coastguard Worker  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*8b26181fSAndroid Build Coastguard Worker  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*8b26181fSAndroid Build Coastguard Worker  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*8b26181fSAndroid Build Coastguard Worker  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*8b26181fSAndroid Build Coastguard Worker  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*8b26181fSAndroid Build Coastguard Worker  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*8b26181fSAndroid Build Coastguard Worker  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*8b26181fSAndroid Build Coastguard Worker  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*8b26181fSAndroid Build Coastguard Worker  * SUCH DAMAGE.
33*8b26181fSAndroid Build Coastguard Worker  */
34*8b26181fSAndroid Build Coastguard Worker 
35*8b26181fSAndroid Build Coastguard Worker #ifndef _diag_control_h
36*8b26181fSAndroid Build Coastguard Worker #define _diag_control_h
37*8b26181fSAndroid Build Coastguard Worker 
38*8b26181fSAndroid Build Coastguard Worker #include "pcap/compiler-tests.h"
39*8b26181fSAndroid Build Coastguard Worker 
40*8b26181fSAndroid Build Coastguard Worker #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) || PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
41*8b26181fSAndroid Build Coastguard Worker   /*
42*8b26181fSAndroid Build Coastguard Worker    * Clang and GCC both support this way of putting pragmas into #defines.
43*8b26181fSAndroid Build Coastguard Worker    * We use it only if we have a compiler that supports it; see below
44*8b26181fSAndroid Build Coastguard Worker    * for the code that uses it and the #defines that control whether
45*8b26181fSAndroid Build Coastguard Worker    * that code is used.
46*8b26181fSAndroid Build Coastguard Worker    */
47*8b26181fSAndroid Build Coastguard Worker   #define PCAP_DO_PRAGMA(x) _Pragma (#x)
48*8b26181fSAndroid Build Coastguard Worker #endif
49*8b26181fSAndroid Build Coastguard Worker 
50*8b26181fSAndroid Build Coastguard Worker /*
51*8b26181fSAndroid Build Coastguard Worker  * Suppress "enum value not explicitly handled in switch" warnings.
52*8b26181fSAndroid Build Coastguard Worker  * We may have to build on multiple different Windows SDKs, so we
53*8b26181fSAndroid Build Coastguard Worker  * may not be able to include all enum values in a switch, as they
54*8b26181fSAndroid Build Coastguard Worker  * won't necessarily be defined on all the SDKs, and, unlike
55*8b26181fSAndroid Build Coastguard Worker  * #defines, there's no easy way to test whether a given enum has
56*8b26181fSAndroid Build Coastguard Worker  * a given value.  It *could* be done by the configure script or
57*8b26181fSAndroid Build Coastguard Worker  * CMake tests.
58*8b26181fSAndroid Build Coastguard Worker  */
59*8b26181fSAndroid Build Coastguard Worker #if defined(_MSC_VER)
60*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_ENUM_SWITCH \
61*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(push)) \
62*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4061))
63*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_ENUM_SWITCH \
64*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(pop))
65*8b26181fSAndroid Build Coastguard Worker #else
66*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_ENUM_SWITCH
67*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_ENUM_SWITCH
68*8b26181fSAndroid Build Coastguard Worker #endif
69*8b26181fSAndroid Build Coastguard Worker 
70*8b26181fSAndroid Build Coastguard Worker /*
71*8b26181fSAndroid Build Coastguard Worker  * Suppress "switch statement has only a default case" warnings.
72*8b26181fSAndroid Build Coastguard Worker  * There's a switch in bpf_filter.c that only has additional
73*8b26181fSAndroid Build Coastguard Worker  * cases on Linux.
74*8b26181fSAndroid Build Coastguard Worker  */
75*8b26181fSAndroid Build Coastguard Worker #if defined(_MSC_VER)
76*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEFAULT_ONLY_SWITCH \
77*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(push)) \
78*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4065))
79*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEFAULT_ONLY_SWITCH \
80*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(pop))
81*8b26181fSAndroid Build Coastguard Worker #else
82*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEFAULT_ONLY_SWITCH
83*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEFAULT_ONLY_SWITCH
84*8b26181fSAndroid Build Coastguard Worker #endif
85*8b26181fSAndroid Build Coastguard Worker 
86*8b26181fSAndroid Build Coastguard Worker /*
87*8b26181fSAndroid Build Coastguard Worker  * Suppress Flex, narrowing, and deprecation warnings.
88*8b26181fSAndroid Build Coastguard Worker  */
89*8b26181fSAndroid Build Coastguard Worker #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
90*8b26181fSAndroid Build Coastguard Worker   /*
91*8b26181fSAndroid Build Coastguard Worker    * This is Clang 2.8 or later; we can use "clang diagnostic
92*8b26181fSAndroid Build Coastguard Worker    * ignored -Wxxx" and "clang diagnostic push/pop".
93*8b26181fSAndroid Build Coastguard Worker    *
94*8b26181fSAndroid Build Coastguard Worker    * Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation,
95*8b26181fSAndroid Build Coastguard Worker    * at least according to the GCC 7.3 documentation.  Apparently, Flex
96*8b26181fSAndroid Build Coastguard Worker    * generates code that upsets at least some versions of Clang's
97*8b26181fSAndroid Build Coastguard Worker    * -Wdocumentation.
98*8b26181fSAndroid Build Coastguard Worker    *
99*8b26181fSAndroid Build Coastguard Worker    * (This could be clang-cl, which defines _MSC_VER, so test this
100*8b26181fSAndroid Build Coastguard Worker    * before testing _MSC_VER.)
101*8b26181fSAndroid Build Coastguard Worker    */
102*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FLEX \
103*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic push) \
104*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \
105*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \
106*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") \
107*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \
108*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \
109*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
110*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FLEX \
111*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic pop)
112*8b26181fSAndroid Build Coastguard Worker 
113*8b26181fSAndroid Build Coastguard Worker   /*
114*8b26181fSAndroid Build Coastguard Worker    * Suppress the only narrowing warnings you get from Clang.
115*8b26181fSAndroid Build Coastguard Worker    */
116*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_NARROWING \
117*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic push) \
118*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32")
119*8b26181fSAndroid Build Coastguard Worker 
120*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_NARROWING \
121*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic pop)
122*8b26181fSAndroid Build Coastguard Worker 
123*8b26181fSAndroid Build Coastguard Worker   /*
124*8b26181fSAndroid Build Coastguard Worker    * Suppress deprecation warnings.
125*8b26181fSAndroid Build Coastguard Worker    */
126*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEPRECATION \
127*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic push) \
128*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
129*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEPRECATION \
130*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(clang diagnostic pop)
131*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FORMAT_TRUNCATION
132*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FORMAT_TRUNCATION
133*8b26181fSAndroid Build Coastguard Worker #elif defined(_MSC_VER)
134*8b26181fSAndroid Build Coastguard Worker   /*
135*8b26181fSAndroid Build Coastguard Worker    * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX))
136*8b26181fSAndroid Build Coastguard Worker    * and __pragma(warning(push/pop)).
137*8b26181fSAndroid Build Coastguard Worker    *
138*8b26181fSAndroid Build Coastguard Worker    * Suppress signed-vs-unsigned comparison, narrowing, and unreachable
139*8b26181fSAndroid Build Coastguard Worker    * code warnings.
140*8b26181fSAndroid Build Coastguard Worker    */
141*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FLEX \
142*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(push)) \
143*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4127)) \
144*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4242)) \
145*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4244)) \
146*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4702))
147*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FLEX \
148*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(pop))
149*8b26181fSAndroid Build Coastguard Worker 
150*8b26181fSAndroid Build Coastguard Worker   /*
151*8b26181fSAndroid Build Coastguard Worker    * Suppress narrowing warnings.
152*8b26181fSAndroid Build Coastguard Worker    */
153*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_NARROWING \
154*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(push)) \
155*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4242)) \
156*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4311))
157*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_NARROWING \
158*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(pop))
159*8b26181fSAndroid Build Coastguard Worker 
160*8b26181fSAndroid Build Coastguard Worker   /*
161*8b26181fSAndroid Build Coastguard Worker    * Suppress deprecation warnings.
162*8b26181fSAndroid Build Coastguard Worker    */
163*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEPRECATION \
164*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(push)) \
165*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(disable:4996))
166*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEPRECATION \
167*8b26181fSAndroid Build Coastguard Worker     __pragma(warning(pop))
168*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FORMAT_TRUNCATION
169*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FORMAT_TRUNCATION
170*8b26181fSAndroid Build Coastguard Worker #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
171*8b26181fSAndroid Build Coastguard Worker   /*
172*8b26181fSAndroid Build Coastguard Worker    * This is GCC 4.6 or later, or a compiler claiming to be that.
173*8b26181fSAndroid Build Coastguard Worker    * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
174*8b26181fSAndroid Build Coastguard Worker    * and "GCC diagnostic push/pop" (introduced in 4.6).
175*8b26181fSAndroid Build Coastguard Worker    */
176*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FLEX \
177*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic push) \
178*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wsign-compare") \
179*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunused-parameter") \
180*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
181*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FLEX \
182*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic pop)
183*8b26181fSAndroid Build Coastguard Worker 
184*8b26181fSAndroid Build Coastguard Worker   /*
185*8b26181fSAndroid Build Coastguard Worker    * GCC currently doesn't issue any narrowing warnings.
186*8b26181fSAndroid Build Coastguard Worker    */
187*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_NARROWING
188*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_NARROWING
189*8b26181fSAndroid Build Coastguard Worker 
190*8b26181fSAndroid Build Coastguard Worker   /*
191*8b26181fSAndroid Build Coastguard Worker    * Suppress deprecation warnings.
192*8b26181fSAndroid Build Coastguard Worker    */
193*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEPRECATION \
194*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic push) \
195*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
196*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEPRECATION \
197*8b26181fSAndroid Build Coastguard Worker     PCAP_DO_PRAGMA(GCC diagnostic pop)
198*8b26181fSAndroid Build Coastguard Worker 
199*8b26181fSAndroid Build Coastguard Worker   /*
200*8b26181fSAndroid Build Coastguard Worker    * Suppress format-truncation= warnings.
201*8b26181fSAndroid Build Coastguard Worker    * GCC 7.1 had introduced this warning option. Earlier versions (at least
202*8b26181fSAndroid Build Coastguard Worker    * one particular copy of GCC 4.6.4) treat the request as a warning.
203*8b26181fSAndroid Build Coastguard Worker    */
204*8b26181fSAndroid Build Coastguard Worker   #if PCAP_IS_AT_LEAST_GNUC_VERSION(7,1)
205*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_FORMAT_TRUNCATION \
206*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic push) \
207*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=")
208*8b26181fSAndroid Build Coastguard Worker     #define DIAG_ON_FORMAT_TRUNCATION \
209*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic pop)
210*8b26181fSAndroid Build Coastguard Worker   #else
211*8b26181fSAndroid Build Coastguard Worker    #define DIAG_OFF_FORMAT_TRUNCATION
212*8b26181fSAndroid Build Coastguard Worker    #define DIAG_ON_FORMAT_TRUNCATION
213*8b26181fSAndroid Build Coastguard Worker   #endif
214*8b26181fSAndroid Build Coastguard Worker #else
215*8b26181fSAndroid Build Coastguard Worker   /*
216*8b26181fSAndroid Build Coastguard Worker    * Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later
217*8b26181fSAndroid Build Coastguard Worker    * or a compiler claiming to be that; there's nothing we know of that
218*8b26181fSAndroid Build Coastguard Worker    * we can do.
219*8b26181fSAndroid Build Coastguard Worker    */
220*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FLEX
221*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FLEX
222*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_NARROWING
223*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_NARROWING
224*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_DEPRECATION
225*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_DEPRECATION
226*8b26181fSAndroid Build Coastguard Worker   #define DIAG_OFF_FORMAT_TRUNCATION
227*8b26181fSAndroid Build Coastguard Worker   #define DIAG_ON_FORMAT_TRUNCATION
228*8b26181fSAndroid Build Coastguard Worker #endif
229*8b26181fSAndroid Build Coastguard Worker 
230*8b26181fSAndroid Build Coastguard Worker #ifdef YYBYACC
231*8b26181fSAndroid Build Coastguard Worker   /*
232*8b26181fSAndroid Build Coastguard Worker    * Berkeley YACC.
233*8b26181fSAndroid Build Coastguard Worker    *
234*8b26181fSAndroid Build Coastguard Worker    * It generates a global declaration of yylval, or the appropriately
235*8b26181fSAndroid Build Coastguard Worker    * prefixed version of yylval, in grammar.h, *even though it's been
236*8b26181fSAndroid Build Coastguard Worker    * told to generate a pure parser, meaning it doesn't have any global
237*8b26181fSAndroid Build Coastguard Worker    * variables*.  Bison doesn't do this.
238*8b26181fSAndroid Build Coastguard Worker    *
239*8b26181fSAndroid Build Coastguard Worker    * That causes a warning due to the local declaration in the parser
240*8b26181fSAndroid Build Coastguard Worker    * shadowing the global declaration.
241*8b26181fSAndroid Build Coastguard Worker    *
242*8b26181fSAndroid Build Coastguard Worker    * So, if the compiler warns about that, we turn off -Wshadow warnings.
243*8b26181fSAndroid Build Coastguard Worker    *
244*8b26181fSAndroid Build Coastguard Worker    * In addition, the generated code may have functions with unreachable
245*8b26181fSAndroid Build Coastguard Worker    * code, so suppress warnings about those.
246*8b26181fSAndroid Build Coastguard Worker    */
247*8b26181fSAndroid Build Coastguard Worker   #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
248*8b26181fSAndroid Build Coastguard Worker     /*
249*8b26181fSAndroid Build Coastguard Worker      * This is Clang 2.8 or later (including clang-cl, so test this
250*8b26181fSAndroid Build Coastguard Worker      * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
251*8b26181fSAndroid Build Coastguard Worker      */
252*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
253*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \
254*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
255*8b26181fSAndroid Build Coastguard Worker   #elif defined(_MSC_VER)
256*8b26181fSAndroid Build Coastguard Worker     /*
257*8b26181fSAndroid Build Coastguard Worker      * This is Microsoft Visual Studio; we can use
258*8b26181fSAndroid Build Coastguard Worker      * __pragma(warning(disable:XXXX)).
259*8b26181fSAndroid Build Coastguard Worker      */
260*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
261*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4702))
262*8b26181fSAndroid Build Coastguard Worker   #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
263*8b26181fSAndroid Build Coastguard Worker     /*
264*8b26181fSAndroid Build Coastguard Worker      * This is GCC 4.6 or later, or a compiler claiming to be that.
265*8b26181fSAndroid Build Coastguard Worker      * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2,
266*8b26181fSAndroid Build Coastguard Worker      * but it may not actually work very well prior to 4.6).
267*8b26181fSAndroid Build Coastguard Worker      */
268*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
269*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wshadow") \
270*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
271*8b26181fSAndroid Build Coastguard Worker   #else
272*8b26181fSAndroid Build Coastguard Worker     /*
273*8b26181fSAndroid Build Coastguard Worker      * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler
274*8b26181fSAndroid Build Coastguard Worker      * claiming to be that; there's nothing we know of that we can do.
275*8b26181fSAndroid Build Coastguard Worker      */
276*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC
277*8b26181fSAndroid Build Coastguard Worker   #endif
278*8b26181fSAndroid Build Coastguard Worker #else
279*8b26181fSAndroid Build Coastguard Worker   /*
280*8b26181fSAndroid Build Coastguard Worker    * Bison.
281*8b26181fSAndroid Build Coastguard Worker    *
282*8b26181fSAndroid Build Coastguard Worker    * The generated code may have functions with unreachable code and
283*8b26181fSAndroid Build Coastguard Worker    * switches with only a default case, so suppress warnings about those.
284*8b26181fSAndroid Build Coastguard Worker    */
285*8b26181fSAndroid Build Coastguard Worker   #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
286*8b26181fSAndroid Build Coastguard Worker     /*
287*8b26181fSAndroid Build Coastguard Worker      * This is Clang 2.8 or later (including clang-cl, so test this
288*8b26181fSAndroid Build Coastguard Worker      * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx".
289*8b26181fSAndroid Build Coastguard Worker      */
290*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
291*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
292*8b26181fSAndroid Build Coastguard Worker   #elif defined(_MSC_VER)
293*8b26181fSAndroid Build Coastguard Worker     /*
294*8b26181fSAndroid Build Coastguard Worker      * This is Microsoft Visual Studio; we can use
295*8b26181fSAndroid Build Coastguard Worker      * __pragma(warning(disable:XXXX)).
296*8b26181fSAndroid Build Coastguard Worker      *
297*8b26181fSAndroid Build Coastguard Worker      * Suppress some /Wall warnings.
298*8b26181fSAndroid Build Coastguard Worker      */
299*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
300*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4065)) \
301*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4127)) \
302*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4242)) \
303*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4244)) \
304*8b26181fSAndroid Build Coastguard Worker       __pragma(warning(disable:4702))
305*8b26181fSAndroid Build Coastguard Worker   #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
306*8b26181fSAndroid Build Coastguard Worker     /*
307*8b26181fSAndroid Build Coastguard Worker      * This is GCC 4.6 or later, or a compiler claiming to be that.
308*8b26181fSAndroid Build Coastguard Worker      * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2,
309*8b26181fSAndroid Build Coastguard Worker      * but it may not actually work very well prior to 4.6).
310*8b26181fSAndroid Build Coastguard Worker      */
311*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC \
312*8b26181fSAndroid Build Coastguard Worker       PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code")
313*8b26181fSAndroid Build Coastguard Worker   #else
314*8b26181fSAndroid Build Coastguard Worker     /*
315*8b26181fSAndroid Build Coastguard Worker      * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler
316*8b26181fSAndroid Build Coastguard Worker      * claiming to be that; there's nothing we know of that we can do.
317*8b26181fSAndroid Build Coastguard Worker      */
318*8b26181fSAndroid Build Coastguard Worker     #define DIAG_OFF_BISON_BYACC
319*8b26181fSAndroid Build Coastguard Worker   #endif
320*8b26181fSAndroid Build Coastguard Worker #endif
321*8b26181fSAndroid Build Coastguard Worker 
322*8b26181fSAndroid Build Coastguard Worker /*
323*8b26181fSAndroid Build Coastguard Worker  * GCC needs this on AIX for longjmp().
324*8b26181fSAndroid Build Coastguard Worker  */
325*8b26181fSAndroid Build Coastguard Worker #if PCAP_IS_AT_LEAST_GNUC_VERSION(5,1)
326*8b26181fSAndroid Build Coastguard Worker   /*
327*8b26181fSAndroid Build Coastguard Worker    * Beware that the effect of this builtin is more than just squelching the
328*8b26181fSAndroid Build Coastguard Worker    * warning! GCC trusts it enough for the process to segfault if the control
329*8b26181fSAndroid Build Coastguard Worker    * flow reaches the builtin (an infinite empty loop in the same context would
330*8b26181fSAndroid Build Coastguard Worker    * squelch the warning and ruin the process too, albeit in a different way).
331*8b26181fSAndroid Build Coastguard Worker    * So please remember to use this very carefully.
332*8b26181fSAndroid Build Coastguard Worker    */
333*8b26181fSAndroid Build Coastguard Worker   #define PCAP_UNREACHABLE __builtin_unreachable();
334*8b26181fSAndroid Build Coastguard Worker #else
335*8b26181fSAndroid Build Coastguard Worker   #define PCAP_UNREACHABLE
336*8b26181fSAndroid Build Coastguard Worker #endif
337*8b26181fSAndroid Build Coastguard Worker 
338*8b26181fSAndroid Build Coastguard Worker #endif /* _diag_control_h */
339