]>
Commit | Line | Data |
---|---|---|
a0f6b076 | 1 | /* Declaration for error-reporting function for Bison. |
7d424de1 | 2 | |
7d6bad19 | 3 | Copyright (C) 2000-2002, 2006, 2009-2013 Free Software Foundation, |
575619af | 4 | Inc. |
a0f6b076 | 5 | |
f16b0819 PE |
6 | This program is free software: you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation, either version 3 of the License, or | |
9 | (at your option) any later version. | |
a0f6b076 AD |
10 | |
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
f16b0819 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
a0f6b076 AD |
18 | |
19 | #ifndef COMPLAIN_H_ | |
ee000ba4 | 20 | # define COMPLAIN_H_ 1 |
a0f6b076 | 21 | |
ee000ba4 AD |
22 | # include "location.h" |
23 | ||
46bdb8ec | 24 | /* Sub-messages indent. */ |
a99ec53e | 25 | # define SUB_INDENT (4) |
46bdb8ec | 26 | |
d0f11c1b VS |
27 | /*-------------. |
28 | | --warnings. | | |
29 | `-------------*/ | |
30 | ||
808e523d | 31 | /** The bits assigned to each warning type. */ |
6fb8b256 | 32 | typedef enum |
d0f11c1b | 33 | { |
808e523d AD |
34 | warning_midrule_values, /**< Unset or unused midrule values. */ |
35 | warning_yacc, /**< POSIXME. */ | |
36 | warning_conflicts_sr, /**< S/R conflicts. */ | |
37 | warning_conflicts_rr, /**< R/R conflicts. */ | |
f68a49ed | 38 | warning_empty_rule, /**< Implicitly empty rules. */ |
808e523d AD |
39 | warning_deprecated, /**< Obsolete constructs. */ |
40 | warning_precedence, /**< Useless precedence and associativity. */ | |
41 | warning_other, /**< All other warnings. */ | |
cc2235ac | 42 | |
808e523d AD |
43 | warnings_size /**< The number of warnings. Must be last. */ |
44 | } warning_bit; | |
45 | ||
12bc1c9e AD |
46 | /** Whether -Werror was set. */ |
47 | extern bool warnings_are_errors; | |
48 | ||
49 | /** Decode a single argument from -W. | |
50 | * | |
51 | * \param arg the subarguments to decode. | |
52 | * If null, then activate all the flags. | |
53 | * \param no length of the potential "no-" prefix. | |
54 | * Can be 0 or 3. If 3, negate the action of the subargument. | |
55 | * \param err length of a potential "error=". | |
56 | * Can be 0 or 6. If 6, treat the subargument as a CATEGORY. | |
57 | * | |
58 | * If VALUE != 0 then KEY sets flags and no-KEY clears them. | |
59 | * If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all | |
60 | * flags from \c all. Thus no-none = all and no-all = none. | |
61 | */ | |
62 | void warning_argmatch (char const *arg, size_t no, size_t err); | |
63 | ||
64 | /** Decode a comma-separated list of arguments from -W. | |
65 | * | |
66 | * \param args comma separated list of effective subarguments to decode. | |
67 | * If 0, then activate all the flags. | |
68 | */ | |
69 | void warnings_argmatch (char *args); | |
70 | ||
71 | ||
72 | /*-----------. | |
73 | | complain. | | |
74 | `-----------*/ | |
75 | ||
76 | /** Initialize this module. */ | |
77 | void complain_init (void); | |
78 | ||
808e523d AD |
79 | typedef enum |
80 | { | |
81 | /**< Issue no warnings. */ | |
82 | Wnone = 0, | |
83 | ||
84 | Wmidrule_values = 1 << warning_midrule_values, | |
85 | Wyacc = 1 << warning_yacc, | |
86 | Wconflicts_sr = 1 << warning_conflicts_sr, | |
87 | Wconflicts_rr = 1 << warning_conflicts_rr, | |
88 | Wdeprecated = 1 << warning_deprecated, | |
f68a49ed | 89 | Wempty_rule = 1 << warning_empty_rule, |
808e523d AD |
90 | Wprecedence = 1 << warning_precedence, |
91 | Wother = 1 << warning_other, | |
b6403170 | 92 | |
9503b0a4 TR |
93 | Werror = 1 << 10, /** This bit is no longer used. */ |
94 | ||
b6403170 VS |
95 | complaint = 1 << 11, /**< All complaints. */ |
96 | fatal = 1 << 12, /**< All fatal errors. */ | |
97 | silent = 1 << 13, /**< Do not display the warning type. */ | |
ea9e670d | 98 | no_caret = 1 << 14, /**< Do not display caret location. */ |
9503b0a4 TR |
99 | |
100 | /**< All above warnings. */ | |
101 | Wall = ~complaint & ~fatal & ~silent | |
6fb8b256 | 102 | } warnings; |
d0f11c1b | 103 | |
42d101da AD |
104 | /** Whether the warnings of \a flags are all unset. |
105 | (Never enabled, never disabled). */ | |
106 | bool warning_is_unset (warnings flags); | |
d0f11c1b | 107 | |
bb8e56ff | 108 | /** Make a complaint, with maybe a location. */ |
b999409e | 109 | void complain (location const *loc, warnings flags, char const *message, ...) |
66381412 AR |
110 | __attribute__ ((__format__ (__printf__, 3, 4))); |
111 | ||
782e8187 | 112 | /** Likewise, but with an \a argc/argv interface. */ |
c6c8de16 TR |
113 | void complain_args (location const *loc, warnings w, unsigned *indent, |
114 | int argc, char *arg[]); | |
782e8187 | 115 | |
6fb8b256 | 116 | /** Make a complaint with location and some indentation. */ |
b999409e TR |
117 | void complain_indent (location const *loc, warnings flags, unsigned *indent, |
118 | char const *message, ...) | |
6fb8b256 | 119 | __attribute__ ((__format__ (__printf__, 4, 5))); |
a0f6b076 | 120 | |
697a8022 | 121 | |
1dc927a7 AD |
122 | /** Report an obsolete syntax, suggest the updated one. */ |
123 | void deprecated_directive (location const *loc, | |
124 | char const *obsolete, char const *updated); | |
125 | ||
697a8022 TR |
126 | /** Warnings treated as errors shouldn't stop the execution as regular errors |
127 | should (because due to their nature, it is safe to go on). Thus, there are | |
128 | three possible execution statuses. */ | |
129 | typedef enum | |
130 | { | |
131 | status_none, | |
132 | status_warning_as_error, | |
133 | status_complaint | |
134 | } err_status; | |
135 | ||
23eb2a69 | 136 | /** Whether an error was reported. */ |
697a8022 | 137 | extern err_status complaint_status; |
a0f6b076 | 138 | |
a0f6b076 | 139 | #endif /* !COMPLAIN_H_ */ |