1 /* Language-independent APIs to enable/disable per-location warnings.
3 Copyright (C) 2021 Free Software Foundation, Inc.
4 Contributed by Martin Sebor <msebor@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef DIAGNOSTIC_SPEC_H_INCLUDED
23 #define DIAGNOSTIC_SPEC_H_INCLUDED
27 /* A "bitset" of warning groups. */
34 /* Middle end warnings about invalid accesses. */
36 /* Front end/lexical warnings. */
38 /* Warnings about null pointers. */
40 /* Warnings about uninitialized reads. */
42 /* Warnings about arithmetic overflow. */
44 /* All other unclassified warnings. */
46 /* All groups of warnings. */
47 NW_ALL
= (NW_ACCESS
| NW_LEXICAL
| NW_NONNULL
48 | NW_UNINIT
| NW_VFLOW
| NW_OTHER
)
51 nowarn_spec_t (): m_bits () { }
53 nowarn_spec_t (opt_code
);
55 /* Return the raw bitset. */
56 operator unsigned() const
61 /* Return true if the bitset is clear. */
62 bool operator!() const
67 /* Return the inverse of the bitset. */
68 nowarn_spec_t
operator~() const
70 nowarn_spec_t
res (*this);
71 res
.m_bits
&= ~NW_ALL
;
75 /* Set *THIS to the bitwise OR of *THIS and RHS. */
76 nowarn_spec_t
& operator|= (const nowarn_spec_t
&rhs
)
82 /* Set *THIS to the bitwise AND of *THIS and RHS. */
83 nowarn_spec_t
& operator&= (const nowarn_spec_t
&rhs
)
89 /* Set *THIS to the bitwise exclusive OR of *THIS and RHS. */
90 nowarn_spec_t
& operator^= (const nowarn_spec_t
&rhs
)
97 /* Bitset of warning groups. */
101 /* Return the bitwise OR of LHS and RHS. */
104 operator| (const nowarn_spec_t
&lhs
, const nowarn_spec_t
&rhs
)
106 return nowarn_spec_t (lhs
) |= rhs
;
109 /* Return the bitwise AND of LHS and RHS. */
112 operator& (const nowarn_spec_t
&lhs
, const nowarn_spec_t
&rhs
)
114 return nowarn_spec_t (lhs
) &= rhs
;
117 /* Return true if LHS is equal RHS. */
120 operator== (const nowarn_spec_t
&lhs
, const nowarn_spec_t
&rhs
)
122 return static_cast<unsigned>(lhs
) == static_cast<unsigned>(rhs
);
125 /* Return true if LHS is not equal RHS. */
128 operator!= (const nowarn_spec_t
&lhs
, const nowarn_spec_t
&rhs
)
130 return !(lhs
== rhs
);
133 typedef int_hash
<location_t
, 0, UINT_MAX
> xint_hash_t
;
134 typedef hash_map
<xint_hash_t
, nowarn_spec_t
> xint_hash_map_t
;
136 /* A mapping from a 'location_t' to the warning spec set for it. */
137 extern GTY(()) xint_hash_map_t
*nowarn_map
;
139 #endif // DIAGNOSTIC_SPEC_H_INCLUDED